Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

refactor(notices): move OpenRouter free-tier error feedback into the notice system

Steven Enamakelc1ded4d8f6c9
diff --git a/app/src/components/notices/useAppNotices.ts b/app/src/components/notices/useAppNotices.ts
index 85834994aa..34a0451468 100644
--- a/app/src/components/notices/useAppNotices.ts
+++ b/app/src/components/notices/useAppNotices.ts
@@ -125,6 +125,18 @@ export function useAppNotices(): AppNotice[] {
setDismissed(prev => new Set(prev).add(id));
}, []);
+ // The OpenRouter switch can fail, and the banner this replaced showed that
+ // failure inline. Surfacing it as its own notice keeps that feedback rather
+ // than letting the click look like it silently did nothing.
+ const [openRouterFailed, setOpenRouterFailed] = useState(false);
+ const useOpenRouterFree = useCallback(() => {
+ setOpenRouterFailed(false);
+ void applyOpenRouterFreeModels().catch((error: unknown) => {
+ console.warn('[notices] applyOpenRouterFreeModels failed', error);
+ setOpenRouterFailed(true);
+ });
+ }, []);
+
const runErrorAction = useCallback(
(entry: UserActionableError) => {
if (entry.action !== 'dismiss') navigate(ACTION_ROUTE[entry.action]);
@@ -229,11 +241,17 @@ export function useAppNotices(): AppNotice[] {
// The free-tier escape hatch the banner carried. Kept because it is the
// only remediation that does not require a payment method.
secondaryActionLabel: t('openrouterFree.cta'),
- onSecondaryAction: () => {
- void applyOpenRouterFreeModels().catch((error: unknown) => {
- console.warn('[notices] applyOpenRouterFreeModels failed', error);
- });
- },
+ onSecondaryAction: useOpenRouterFree,
+ });
+ }
+
+ if (openRouterFailed) {
+ notices.push({
+ id: 'openrouter-free:failed',
+ severity: 'warning',
+ title: t('openrouterFree.cta'),
+ body: t('openrouterFree.error'),
+ onDismiss: () => setOpenRouterFailed(false),
});
}
@@ -249,7 +267,9 @@ export function useAppNotices(): AppNotice[] {
isFreeTier,
isNearLimit,
navigate,
+ openRouterFailed,
runErrorAction,
+ useOpenRouterFree,
t,
shouldShowBudgetCompletedMessage,
teamUsage,
diff --git a/app/src/features/conversations/Conversations.tsx b/app/src/features/conversations/Conversations.tsx
index 4d497aeae1..ec4d8d7af8 100644
--- a/app/src/features/conversations/Conversations.tsx
+++ b/app/src/features/conversations/Conversations.tsx
@@ -18,8 +18,6 @@ import QueuedFollowups from '../../components/chat/QueuedFollowups';
import WorkflowProposalCard from '../../components/chat/WorkflowProposalCard';
import { ConfirmationModal } from '../../components/intelligence/ConfirmationModal';
import { SidebarContent } from '../../components/layout/shell/SidebarSlot';
-import UpsellBanner from '../../components/upsell/UpsellBanner';
-import { dismissBanner, shouldShowBanner } from '../../components/upsell/upsellDismissState';
import { AssistantUiChat } from '../../features/conversations/components/AssistantUiChat';
import { selectBackgroundProcesses } from '../../features/conversations/components/BackgroundProcessesPanel';
import {
@@ -62,7 +60,6 @@ import {
validateAndReadFile,
} from '../../lib/attachments';
import { useT } from '../../lib/i18n/I18nContext';
-import { applyOpenRouterFreeModels } from '../../services/api/openrouterFreeModels';
import { threadApi } from '../../services/api/threadApi';
import { fetchThreadTokenUsage } from '../../services/api/threadUsageApi';
import {
@@ -338,7 +335,6 @@ const Conversations = ({
);
const sendAdvisoryRef = useRef(sendAdvisory);
sendAdvisoryRef.current = sendAdvisory;
- const [openRouterStatus, setOpenRouterStatus] = useState<'idle' | 'saving' | 'error'>('idle');
// Threads whose send is mid-flight (dispatched locally, backend not yet
// accepted). A Set so concurrent sends to different threads each track their
// own pending state instead of clobbering a single slot.
@@ -581,17 +577,6 @@ const Conversations = ({
}
};
- const handleUseOpenRouterFree = async () => {
- setOpenRouterStatus('saving');
- try {
- await applyOpenRouterFreeModels();
- setOpenRouterStatus('idle');
- } catch (err) {
- console.warn('[chat] applyOpenRouterFreeModels failed', err);
- setOpenRouterStatus('error');
- }
- };
-
const handleStartEditTitle = (threadId: string) => {
const thr = threads.find(t => t.id === threadId);
debug('[chat] thread rename: start thread=%s', threadId);
@@ -2044,11 +2029,6 @@ const Conversations = ({
: 'absolute inset-x-0 bottom-0 z-20 mx-auto w-full max-w-195 px-4 pb-4 pt-6'
}>
<>
- {openRouterStatus === 'error' && (
- <div className="mb-3 rounded-lg border border-coral-200 bg-coral-50 px-3 py-2 text-xs text-coral-700">
- {t('openrouterFree.error')}
- </div>
- )}
{/* Cycle usage pill moved into ChatComposer toolbar */}
</>
@@ -2510,11 +2490,6 @@ const Conversations = ({
const assistantComposerHeader = (
<>
- {openRouterStatus === 'error' && (
- <div className="rounded-lg border border-coral-200 bg-coral-50 px-3 py-2 text-xs text-coral-700">
- {t('openrouterFree.error')}
- </div>
- )}
{attachError && (
<div className="rounded-lg border border-coral-200 bg-coral-50 px-3 py-2">
<p className="text-xs text-coral-500" data-chat-send-error-code={attachError.code}>