The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(desktop): error card review follow-ups — Continue sends, billing card always shown, one action policy
kshitijk4poor92213f976785
diff --git a/apps/desktop/src/app/chat/composer/hooks/use-reveal-status-drawer.test.ts b/apps/desktop/src/app/chat/composer/hooks/use-reveal-status-drawer.test.tsdeleted file mode 100644index 8d99fe66011..00000000000--- a/apps/desktop/src/app/chat/composer/hooks/use-reveal-status-drawer.test.ts+++ /dev/null@@ -1,32 +0,0 @@-import { renderHook } from '@testing-library/react'-import { describe, expect, it, vi } from 'vitest'--import { useRevealStatusDrawer } from './use-status-drawer'--describe('useRevealStatusDrawer', () => {- it('opens a collapsed drawer once per new alert, then respects the user collapsing it again', () => {- const toggle = vi.fn()-- const { rerender } = renderHook(- ({ collapsed, token }: { collapsed: boolean; token: number | null }) =>- useRevealStatusDrawer(token, collapsed, toggle),- { initialProps: { collapsed: true, token: null as number | null } }- )-- expect(toggle).not.toHaveBeenCalled()-- rerender({ collapsed: true, token: 1 })- expect(toggle).toHaveBeenCalledTimes(1)-- // The user hides it again for the same wall: it stays hidden.- rerender({ collapsed: false, token: 1 })- rerender({ collapsed: true, token: 1 })- expect(toggle).toHaveBeenCalledTimes(1)-- // A new wall reveals it again; an already-open drawer is left alone.- rerender({ collapsed: true, token: 2 })- expect(toggle).toHaveBeenCalledTimes(2)- rerender({ collapsed: false, token: 3 })- expect(toggle).toHaveBeenCalledTimes(2)- })-})diff --git a/apps/desktop/src/app/chat/composer/hooks/use-status-drawer.ts b/apps/desktop/src/app/chat/composer/hooks/use-status-drawer.tsindex 8672534b4da..ea408eabc4e 100644--- a/apps/desktop/src/app/chat/composer/hooks/use-status-drawer.ts+++ b/apps/desktop/src/app/chat/composer/hooks/use-status-drawer.ts@@ -1,8 +1,7 @@import { useStore } from '@nanostores/react'-import { useEffect, useId, useState } from 'react'+import { useId, useState } from 'react'import { useStoreSelector } from '@/lib/use-session-slice'-import { $billingBlock } from '@/store/billing-block'import { $collapsedStatusDrawers, setStatusDrawerCollapsed, statusDrawerKey } from '@/store/composer-status-drawer'import { $activeConnectionId } from '@/store/connections'import { $activeGatewayProfile, normalizeProfileKey } from '@/store/profile'@@ -11,8 +10,7 @@ import { knownOwnerForSession } from '@/store/session-states'import { useComposerScope } from '../scope'-/** `statusSessionId`: the chat the status stack speaks for (an out-of-credits wall there opens it). */-export function useStatusDrawer(sessionKey: string | null, statusSessionId?: string | null) {+export function useStatusDrawer(sessionKey: string | null) {const scope = useComposerScope()const activeProfile = useStore($activeGatewayProfile)const activeConnection = useStore($activeConnectionId)@@ -39,43 +37,20 @@ export function useStatusDrawer(sessionKey: string | null, statusSessionId?: strconst collapsed = key ? saved : draft.key === draftKey && draft.collapsed- const toggle = () => {- if (key) {- setStatusDrawerCollapsed(key, !collapsed)- } else {- setDraft({ key: draftKey, collapsed: !collapsed })- }- }-- // An out-of-credits wall for this chat is the drawer's banner (the turn's card defers to it).- const billingWallAt = useStoreSelector($billingBlock, block =>- statusSessionId && block?.sessionId === statusSessionId ? block.at : null- )-- useRevealStatusDrawer(billingWallAt, collapsed, toggle)-// Stable ids for the two drawer regions (status stack, coding row) their toggles control.const statusDrawerId = useId()const codingDrawerId = useId()- return { codingDrawerId, collapsed, statusDrawerId, toggle }-}--/** Open a collapsed drawer once per new `token` (e.g. an out-of-credits wall for this chat):- * the drawer is that alert's one surface, so it must not arrive hidden. A later collapse- * by the user sticks until the next token. */-export function useRevealStatusDrawer(token: number | null, collapsed: boolean, toggle: () => void) {- const [revealed, setRevealed] = useState<number | null>(null)-- useEffect(() => {- if (token === null || revealed === token) {- return- }-- setRevealed(token)-- if (collapsed) {- toggle()+ return {+ codingDrawerId,+ collapsed,+ statusDrawerId,+ toggle: () => {+ if (key) {+ setStatusDrawerCollapsed(key, !collapsed)+ } else {+ setDraft({ key: draftKey, collapsed: !collapsed })+ }}- }, [collapsed, revealed, toggle, token])+ }}diff --git a/apps/desktop/src/app/chat/composer/index.tsx b/apps/desktop/src/app/chat/composer/index.tsxindex 8c99047e28a..ff92f9a73da 100644--- a/apps/desktop/src/app/chat/composer/index.tsx+++ b/apps/desktop/src/app/chat/composer/index.tsx@@ -192,7 +192,7 @@ export function ChatBar({const awaitingInput = useStore(scope.$awaitingInput)const blockingPrompt = useStore(useMemo(() => sessionBlockingPrompt(sessionId ?? null), [sessionId]))const activeQueueSessionKey = useComposerQueueScopeKey(queueSessionKey, sessionId, freshDraftKey)- const statusDrawer = useStatusDrawer(activeQueueSessionKey, sessionId)+ const statusDrawer = useStatusDrawer(activeQueueSessionKey)const { codingDrawerId, collapsed: statusDrawerCollapsed, statusDrawerId, toggle: toggleStatusDrawer } = statusDrawerconst requestBusyConfig = useCallback<GatewayRequester>(diff --git a/apps/desktop/src/app/session/hooks/use-message-stream/agent-init-error.test.tsx b/apps/desktop/src/app/session/hooks/use-message-stream/agent-init-error.test.tsxindex 872da23a57d..a3661af1d0d 100644--- a/apps/desktop/src/app/session/hooks/use-message-stream/agent-init-error.test.tsx+++ b/apps/desktop/src/app/session/hooks/use-message-stream/agent-init-error.test.tsx@@ -70,8 +70,12 @@ describe('useMessageStream agent-init error surfacing (#63078)', () => {expect(state.busy).toBe(false)expect(state.awaitingResponse).toBe(false)- // One event, one surface: the card is on screen, so no toast repeats it.- expect($notifications.get().find(n => n.kind === 'error')).toBeUndefined()+ // The card's copy for a bare error is generic, so the server's plain,+ // actionable sentence still gets the toast — as the message itself, not+ // demoted to a detail line under a generic gloss.+ const toast = $notifications.get().find(n => n.kind === 'error' && n.message.includes('was not sent'))+ expect(toast).toBeDefined()+ expect(toast!.detail).toBeUndefined()})it('merges the terminal error frame into the card the agent-init error event already painted', async () => {mountStream()diff --git a/apps/desktop/src/app/session/hooks/use-message-stream/gateway-event/message-stream.ts b/apps/desktop/src/app/session/hooks/use-message-stream/gateway-event/message-stream.tsindex 37436269622..ff66ab1b366 100644--- a/apps/desktop/src/app/session/hooks/use-message-stream/gateway-event/message-stream.ts+++ b/apps/desktop/src/app/session/hooks/use-message-stream/gateway-event/message-stream.ts@@ -39,7 +39,7 @@ function firstBillingLine(text: string): string {* composer. A wall in a session that is NOT on screen also raises one sticky,* billing-specific toast — never the generic "Hermes error" — with a smart CTA* (Nous → in-app Settings → Billing, other providers → their billing page); on- * screen the banner alone carries it (one event, one surface).+ * screen the banner and the turn's card carry it, so no toast repeats them.*/function surfaceBillingBlock(sessionId: string, raw: unknown, toast: boolean): void {if (!raw || typeof raw !== 'object') {diff --git a/apps/desktop/src/app/session/hooks/use-message-stream/gateway-event/status.test.ts b/apps/desktop/src/app/session/hooks/use-message-stream/gateway-event/status.test.tsindex 25cff89e452..ae6091c742b 100644--- a/apps/desktop/src/app/session/hooks/use-message-stream/gateway-event/status.test.ts+++ b/apps/desktop/src/app/session/hooks/use-message-stream/gateway-event/status.test.ts@@ -113,12 +113,21 @@ describe('gateway `error` event → error card + toast', () => {expect(toast.detail).toBeUndefined()})- it('raises no toast for the session on screen: its card already says it (one event, one surface)', () => {- const { ctx, failAssistantMessage } = errorContext('Hermes could not finish this turn. Try again.')+ it('raises no toast for the session on screen when its card explains the code (one event, one surface)', () => {+ const { ctx, failAssistantMessage } = errorContext('[Errno 28] No space left on device')handleStatusEvent({ ...ctx, isActiveEvent: true })expect(failAssistantMessage).toHaveBeenCalledTimes(1)expect($notifications.get()).toEqual([])})++ it("still toasts a bare error's server sentence on screen: the card copy is generic", () => {+ const sentence = 'Another Hermes process holds the auth store lock. Wait for it to finish or close it, then retry.'+ const { ctx } = errorContext(sentence)++ handleStatusEvent({ ...ctx, isActiveEvent: true })++ expect($notifications.get()).toEqual([expect.objectContaining({ message: sentence })])+ })})diff --git a/apps/desktop/src/app/session/hooks/use-message-stream/gateway-event/status.ts b/apps/desktop/src/app/session/hooks/use-message-stream/gateway-event/status.tsindex 01a58a451bb..facc9829e57 100644--- a/apps/desktop/src/app/session/hooks/use-message-stream/gateway-event/status.ts+++ b/apps/desktop/src/app/session/hooks/use-message-stream/gateway-event/status.ts@@ -29,13 +29,24 @@ export function isFallbackSwitchStatus(kind: string | undefined, text: string):return /model fallback|provider fallback|switched to fallback|switching to fallback/i.test(text)}-/** The toast for a gateway `error` in a session that is NOT on screen (its card can't be seen).- * The stable id collapses the same error from multiple background threads into one toast. For- * a recovered code the message is the card's glossed sentence with the raw gateway text as the+/** The toast for a gateway `error`, raised only when the card can't fully say it: a session off+ * screen, or a bare error (no recovered code) whose card copy is generic — the server's own+ * sentence is often the fix (e.g. which process holds a lock). On screen, a recovered code's+ * card already explains it (one event, one surface). The stable id collapses the same error+ * from multiple threads into one toast. For a recovered code the message is the card's glossed sentence with the raw gateway text as the* dimmed detail; otherwise the server copy is the message and there is no detail to repeat.* No Retry action: assistant-ui's reload is per-thread, and for the codes recovered here a* retry would fail identically anyway. */-function toastBackgroundGatewayError(errorMessage: string, surface: ErrorSurface | null, toastMessage: string): void {+function toastGatewayError(+ errorMessage: string,+ surface: ErrorSurface | null,+ toastMessage: string,+ onScreen: boolean+): void {+ if (onScreen && surface) {+ return+ }+if (surface?.code === 'disk_full') {notifyError(new Error(errorMessage), translateNow('notifications.errors.diskFull'))@@ -353,10 +364,8 @@ export function handleStatusEvent(ctx: GatewayEventContext): boolean {if (looksLikeProviderSetup) {requestDesktopOnboarding(errorMessage)- } else if (!isActiveEvent) {- // One event, one surface: the inline card already explains this failure- // where the user is acting; the toast is only for a session off screen.- toastBackgroundGatewayError(errorMessage, surface, toastMessage)+ } else {+ toastGatewayError(errorMessage, surface, toastMessage, isActiveEvent)}if (sessionId) {diff --git a/apps/desktop/src/app/session/hooks/use-prompt-actions/owner-forward.test.tsx b/apps/desktop/src/app/session/hooks/use-prompt-actions/owner-forward.test.tsxindex 19fa77154a9..fd556e2a80b 100644--- a/apps/desktop/src/app/session/hooks/use-prompt-actions/owner-forward.test.tsx+++ b/apps/desktop/src/app/session/hooks/use-prompt-actions/owner-forward.test.tsx@@ -2,7 +2,7 @@ import { JsonRpcGatewayError } from '@hermes/shared'import { cleanup } from '@testing-library/react'import { afterEach, describe, expect, it, vi } from 'vitest'-import { errorRecoveryPlan, type ErrorSurface } from '@/lib/error-surface'+import { errorCardOffers, type ErrorSurface } from '@/lib/error-surface'import { $composerAttachments } from '@/store/composer'import { clearNotifications } from '@/store/notifications'import { $connection, $currentCwd } from '@/store/session'@@ -132,7 +132,7 @@ describe('usePromptActions gateway-owner queue (#140385)', () => {expect(await handle!.submitText('continue here')).toBe(false)const bubble = (latest?.messages as { errorSurface?: ErrorSurface }[]).at(-1)expect(bubble?.errorSurface).toEqual({ layer: 'gateway', code: 'SESSION_OWNER_UNCONFIRMED', retryable: false })- expect(errorRecoveryPlan(bubble?.errorSurface).retry).toBe(false)+ expect(errorCardOffers(bubble?.errorSurface, 'retry')).toBe(false)})it('shows a prompt the legacy backend forwarded to the gateway owner as queued, not as a failed turn (#140385)', async () => {diff --git a/apps/desktop/src/app/session/hooks/use-prompt-actions/utils.test.ts b/apps/desktop/src/app/session/hooks/use-prompt-actions/utils.test.tsindex 09fa8279211..93c670f9cac 100644--- a/apps/desktop/src/app/session/hooks/use-prompt-actions/utils.test.ts+++ b/apps/desktop/src/app/session/hooks/use-prompt-actions/utils.test.ts@@ -3,7 +3,7 @@ import { JsonRpcGatewayError } from '@hermes/shared'import { afterEach, describe, expect, it, vi } from 'vitest'import type { ChatMessage } from '@/lib/chat-messages'-import { errorRecoveryPlan } from '@/lib/error-surface'+import { errorCardActions } from '@/lib/error-surface'import {acquireSubmitInFlight,@@ -148,7 +148,7 @@ describe('ownershipErrorSurface', () => {const { errorSurface } = ownershipErrorSurface(err)expect(errorSurface).toEqual({ layer: 'gateway', code: 'session_read_only', retryable: false })- expect(errorRecoveryPlan(errorSurface)).toMatchObject({ retry: false, startNewSession: true })+ expect(errorCardActions(errorSurface)).toEqual({ primary: 'start_new_session' })})})diff --git a/apps/desktop/src/assets/error-card/close.svg b/apps/desktop/src/assets/error-card/close.svgdeleted file mode 100644index fc75fdbafa6..00000000000--- a/apps/desktop/src/assets/error-card/close.svg+++ /dev/null@@ -1,5 +0,0 @@-<svg preserveAspectRatio="none" overflow="visible" style="display: block;" width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">-<g id="close">-<path id="Union" d="M4.66699 12.667H3.33301V11.333H4.66699V12.667ZM12.667 12.667H11.333V11.333H12.667V12.667ZM6 10V11.333H4.66699V10H6ZM11.333 11.333H10V10H11.333V11.333ZM7.33301 10H6V8.66699H7.33301V10ZM10 10H8.66699V8.66699H10V10ZM8.66699 8.66699H7.33301V7.33301H8.66699V8.66699ZM7.33301 7.33301H6V6H7.33301V7.33301ZM10 7.33301H8.66699V6H10V7.33301ZM6 6H4.66699V4.66699H6V6ZM11.333 6H10V4.66699H11.333V6ZM4.66699 4.66699H3.33301V3.33301H4.66699V4.66699ZM12.667 4.66699H11.333V3.33301H12.667V4.66699Z" fill="#17212F" fill-opacity="0.6"/>-</g>-</svg>diff --git a/apps/desktop/src/components/assistant-ui/thread/assistant-message.test.tsx b/apps/desktop/src/components/assistant-ui/thread/assistant-message.test.tsxindex 5c88068debf..bb5cc3268b1 100644--- a/apps/desktop/src/components/assistant-ui/thread/assistant-message.test.tsx+++ b/apps/desktop/src/components/assistant-ui/thread/assistant-message.test.tsx@@ -25,9 +25,13 @@ import { Thread } from '.'const requestFreshSession = vi.hoisted(() => vi.fn())const startManualProviderOAuth = vi.hoisted(() => vi.fn())const requestModelMenuToggle = vi.hoisted(() => vi.fn<() => boolean>(() => true))+const requestComposerSubmit = vi.hoisted(() => vi.fn<(text: string, options?: unknown) => boolean>(() => true))+const requestComposerInsert = vi.hoisted(() => vi.fn())vi.mock('@/app/chat/composer/focus', async importOriginal => ({...(await importOriginal<Record<string, unknown>>()),+ requestComposerInsert: (text: string, options?: unknown) => requestComposerInsert(text, options),+ requestComposerSubmit: (text: string, options?: unknown) => requestComposerSubmit(text, options),requestModelMenuToggle: () => requestModelMenuToggle()}))@@ -490,7 +494,22 @@ describe('error card layout (Error System Overhaul)', () => {expect(screen.queryByRole('button', { name: en.assistant.thread.dismissError })).toBeNull()})- it('speaks for an out-of-credits turn only when the banner is not up for this chat', async () => {+ it('Continue sends "continue" through this chat\'s composer, or leaves it in the input', async () => {+ const truncated = () => failedMessage({ code: 'truncated', layer: 'provider', provider: 'openai', retryable: true })+ const view = render(<Harness assistant={truncated()} />)++ fireEvent.click(await screen.findByRole('button', { name: en.assistant.thread.errorContinue }))+ expect(requestComposerSubmit).toHaveBeenCalledWith('continue', { target: 'main' })+ expect(requestComposerInsert).not.toHaveBeenCalled()+ view.unmount()++ requestComposerSubmit.mockReturnValueOnce(false)+ render(<Harness assistant={truncated()} />)+ fireEvent.click(await screen.findByRole('button', { name: en.assistant.thread.errorContinue }))+ expect(requestComposerInsert).toHaveBeenCalledWith('continue', { target: 'main' })+ })++ it('names an out-of-credits turn on its card too: the banner may be off screen', async () => {render(<MemoryRouter><Harnessdiff --git a/apps/desktop/src/components/assistant-ui/thread/assistant-message.tsx b/apps/desktop/src/components/assistant-ui/thread/assistant-message.tsxindex df4b4902de5..bd538ab73b3 100644--- a/apps/desktop/src/components/assistant-ui/thread/assistant-message.tsx+++ b/apps/desktop/src/components/assistant-ui/thread/assistant-message.tsx@@ -13,12 +13,16 @@ import { useStore } from '@nanostores/react'import { type FC, type ReactNode, useCallback, useContext, useEffect, useId, useMemo, useState } from 'react'import { useInRouterContext, useNavigate } from 'react-router'-import { requestModelMenuToggle } from '@/app/chat/composer/focus'+import {+ type ComposerTarget,+ requestComposerInsert,+ requestComposerSubmit,+ requestModelMenuToggle+} from '@/app/chat/composer/focus'import { useComposerScope } from '@/app/chat/composer/scope'import { useSessionView } from '@/app/chat/session-view'import { SETTINGS_ROUTE } from '@/app/routes'import { useBillingApi } from '@/app/settings/billing/api'-import errorCardCloseIcon from '@/assets/error-card/close.svg'import { dispatchedTo } from '@/components/assistant-ui/thread/agent-delivery'import { ChangedFilesCard } from '@/components/assistant-ui/thread/changed-files-card'import {@@ -45,13 +49,12 @@ import { Codicon } from '@/components/ui/codicon'import { CopyButton } from '@/components/ui/copy-button'import { useI18n } from '@/i18n'import type { Translations } from '@/i18n/types'-import { writeClipboardText } from '@/lib/clipboard'import {ERROR_SETUP_GUIDE_URLS,type ErrorActionId,errorCardActions,errorCardSeverity,- errorRecoveryPlan,+ errorCardShowsDiagnostics,type ErrorSurface,formatCountdown,formatErrorDiagnostics,@@ -71,7 +74,8 @@ import {MoreHorizontal,RefreshCwIcon,SmilePlusIcon,- VolumeXIcon+ VolumeXIcon,+ XIcon} from '@/lib/icons'import { extractPreviewTargets } from '@/lib/preview-targets'import { markAssistantIdSpoken } from '@/lib/spoken-reply'@@ -79,7 +83,7 @@ import { $touchPointer } from '@/lib/touch-interaction'import { useEnterAnimation } from '@/lib/use-enter-animation'import { cn } from '@/lib/utils'import { playSpeechText, stopVoicePlayback } from '@/lib/voice-playback'-import { $billingBlock, requestBillingSettings } from '@/store/billing-block'+import { requestBillingSettings } from '@/store/billing-block'import { DESKTOP_BUTTON_ACTIONS, recordAction } from '@/store/desktop-metrics'import { openFreeTierSignIn } from '@/store/free-tier-sign-in'import { notifyError } from '@/store/notifications'@@ -952,25 +956,10 @@ const ErrorCard: FC<{ onDismiss?: () => void }> = ({ onDismiss }) => {const errorText = useErrorText()const [detailsOpen, setDetailsOpen] = useState(false)const detailsId = useId()- const runtimeId = useStore(useSessionView().$runtimeId)- const billingBlock = useStore($billingBlock)-- // Out of credits: the banner above the composer owns it while it is up for this chat.- // Without it (no descriptor, dismissed, another chat's wall) the card says it. A plan's- // usage limit always gets the card: its buttons are the switch / credits actions.- if (- surface?.layer === 'billing' &&- surface.code !== 'usage_window' &&- billingBlock &&- billingBlock.sessionId === runtimeId- ) {- return null- }-const { body, title } = errorCardText(copy, surface)const severity = errorCardSeverity(surface)// A plan limit is not a fault: no diagnostics to bury the actions that fix it.- const diagnostics = errorRecoveryPlan(surface).diagnostics+ const diagnostics = errorCardShowsDiagnostics(surface)return (<ErrorPrimitive.Root className="aui-error-card" data-severity={severity} data-slot="aui_error-card" role="alert">@@ -1000,55 +989,13 @@ const ErrorCard: FC<{ onDismiss?: () => void }> = ({ onDismiss }) => {)}{severity === 'degraded' && onDismiss && (<button aria-label={copy.dismissError} className="aui-error-card-close" onClick={onDismiss} type="button">- <img alt="" height={16} src={errorCardCloseIcon} width={16} />+ <XIcon aria-hidden className="size-4" /></button>)}</ErrorPrimitive.Root>)}-// Nous DS CopyButton glyph: pixelarticons "copy-sharp" at rest, "check" for the-// 2s feedback window, 70% opacity at rest and full under the cursor.-const ErrorCopyGlyph: FC<{ label: string; text: string }> = ({ label, text }) => {- const { t } = useI18n()- const [copied, setCopied] = useState(false)-- useEffect(() => {- if (!copied) {- return- }-- const timer = window.setTimeout(() => setCopied(false), 2000)-- return () => window.clearTimeout(timer)- }, [copied])-- const name = copied ? t.common.copied : label-- return (- <button- aria-label={name}- className="aui-error-copy-glyph"- data-copied={copied || undefined}- onClick={() =>- void writeClipboardText(text).then(- () => setCopied(true),- () => undefined- )- }- type="button"- >- <svg aria-hidden fill="currentColor" height="16" viewBox="0 0 24 24" width="16">- {copied ? (- <path d="M10 18H8v-2h2v2Zm-2-2H6v-2h2v2Zm4-2v2h-2v-2h2Zm-6 0H4v-2h2v2Zm8 0h-2v-2h2v2Zm2-2h-2v-2h2v2Zm2-2h-2V8h2v2Zm2-2h-2V6h2v2Z" />- ) : (- <path d="M6 6h16v2H6zM2 2h16v2H2zm4 6h2v12H6zM2 4h2v12H2zm4 16h16v2H6zM20 8h2v12h-2zm-4-4h2v2h-2zM2 16h4v2H2z" />- )}- </svg>- </button>- )-}-// Dark block: the raw error, then Copy / Open logs / Send diagnostics as text links.const ErrorDetailsBlock: FC<{ errorText: string; hidden: boolean; id: string; surface?: ErrorSurface }> = ({errorText,@@ -1079,7 +1026,7 @@ const ErrorDetailsBlock: FC<{ errorText: string; hidden: boolean; id: string; su<code className="aui-error-details-raw" data-selectable-text="true">{errorText}</code>- <ErrorCopyGlyph label={copy.errorCopyRaw} text={errorText} />+ <CopyButton appearance="icon" className="aui-error-copy-glyph" label={copy.errorCopyRaw} text={errorText} /></div>)}<div className="aui-error-details-links">@@ -1124,7 +1071,6 @@ const ErrorCardActionRow: FC<{ surface?: ErrorSurface }> = ({ surface }) => {}interface ErrorActionContext {- aui: ReturnType<typeof useAui>className: stringcopy: Translations['assistant']['thread']gatewayProfile: string | null | undefined@@ -1132,6 +1078,15 @@ interface ErrorActionContext {link: booleanownerProfile: string | null | undefinedsurface?: ErrorSurface+ target: ComposerTarget+}++// Continue a cut-off reply: send "continue" through this chat's composer as if typed. When no+// composer can take a submit right now, leave the word in the input for the user to send.+function continueCutOffReply(target: ComposerTarget) {+ if (!requestComposerSubmit('continue', { target })) {+ requestComposerInsert('continue', { target })+ }}const textButton = (className: string, onClick: () => void, label: ReactNode) => (@@ -1208,12 +1163,8 @@ const ERROR_ACTION_RENDERERS: Record<ErrorActionId, (ctx: ErrorActionContext) =>copy.errorOpenHermesFolder): null,- continue: ({ aui, className, copy }) =>- textButton(- className,- () => aui.thread().append({ content: [{ text: 'continue', type: 'text' }], role: 'user' }),- copy.errorContinue- ),+ continue: ({ className, copy, target }) =>+ textButton(className, () => continueCutOffReply(target), copy.errorContinue),open_provider_settings: ({ className, copy, surface }) => {const url = providerSettingsUrl(surface)@@ -1246,13 +1197,12 @@ const ErrorActionControl: FC<{variant: 'link' | 'primary'}> = ({ action, inRouter, surface, variant }) => {const { t } = useI18n()- const aui = useAui()+ const { target } = useComposerScope()const gatewayProfile = useStore($activeGatewayProfile)const ownerProfile = useOwnerProfile()const link = variant === 'link'return ERROR_ACTION_RENDERERS[action]({- aui,// Nous DS Button (portal /ds/components/button): the one action is `secondary`,// the optional second one is `ghost`.className: link ? 'aui-error-btn aui-error-btn-ghost' : 'aui-error-btn aui-error-btn-secondary',@@ -1261,7 +1211,8 @@ const ErrorActionControl: FC<{inRouter,link,ownerProfile,- surface+ surface,+ target})}diff --git a/apps/desktop/src/components/billing-banner.tsx b/apps/desktop/src/components/billing-banner.tsxindex 45bbcdc590b..c82592f7680 100644--- a/apps/desktop/src/components/billing-banner.tsx+++ b/apps/desktop/src/components/billing-banner.tsx@@ -17,9 +17,9 @@ function firstLine(text: string): string {* one piece with the composer card (no bordered alert-in-a-card). It never* disables the composer — slash commands (`/topup`, `/model`, `/login`) stay* usable — it only offers recovery: Nous opens Settings → Billing in-app, other- * providers deep-link out. It is the one surface for the active chat; a wall in a- * background chat also raises a sticky toast, and the turn's card only speaks when- * this banner is not up for that chat.+ * providers deep-link out. The failed turn's card also names the wall (it can't+ * know whether this banner is on screen: a collapsed drawer, a popped-out+ * composer); a wall in a background chat also raises a sticky toast.*/export function BillingBanner({ sessionId }: { sessionId: null | string }) {const active = useStore($billingBlock)diff --git a/apps/desktop/src/i18n/ar_assistant.ts b/apps/desktop/src/i18n/ar_assistant.tsindex f43686341e6..c6e8c9235fa 100644--- a/apps/desktop/src/i18n/ar_assistant.ts+++ b/apps/desktop/src/i18n/ar_assistant.ts@@ -133,7 +133,7 @@ export const arAssistant = {truncated: {title: 'انقطع الرد قبل اكتماله',body: (_provider, model) =>- `بلغ ${model || 'النموذج'} حد الإخراج قبل أن ينتهي، لذا لم يُنفَّذ شيء. اختر «متابعة» ليكمل من حيث توقف.`+ `توقف ${model || 'النموذج'} قبل أن ينتهي، لذا لم تُنفَّذ خطوته الأخيرة. اختر «متابعة» ليكمل من حيث توقف.`},invalid_response: {title: 'تعذّرت قراءة الرد',diff --git a/apps/desktop/src/i18n/de.ts b/apps/desktop/src/i18n/de.tsindex 4e0fdf08b82..f79a027ba56 100644--- a/apps/desktop/src/i18n/de.ts+++ b/apps/desktop/src/i18n/de.ts@@ -4942,7 +4942,7 @@ export const deOverrides = {truncated: {title: 'Die Antwort wurde abgeschnitten',body: (_provider, model) =>- `${model || 'Das Modell'} hat sein Ausgabelimit vor dem Ende erreicht, daher wurde nichts ausgeführt. Wählen Sie „Fortsetzen“, um dort weiterzumachen, wo es aufgehört hat.`+ `${model || 'Das Modell'} hat vor dem Ende aufgehört, daher wurde sein letzter Schritt nicht ausgeführt. Wählen Sie „Fortsetzen“, um dort weiterzumachen, wo es aufgehört hat.`},invalid_response: {title: 'Antwort nicht lesbar',diff --git a/apps/desktop/src/i18n/en_error_codes.ts b/apps/desktop/src/i18n/en_error_codes.tsindex 743c175223b..55bb6496649 100644--- a/apps/desktop/src/i18n/en_error_codes.ts+++ b/apps/desktop/src/i18n/en_error_codes.ts@@ -87,7 +87,7 @@ export const enErrorCodes: ThreadCopy['errorCodes'] = {truncated: {title: 'The reply was cut short',body: (_provider, model) =>- `${model || 'The model'} hit its output limit before finishing, so nothing was run. Continue to pick up where it stopped.`+ `${model || 'The model'} stopped before finishing, so its last step didn't run. Continue to pick up where it stopped.`},invalid_response: {title: "Couldn't read the reply",diff --git a/apps/desktop/src/i18n/es.ts b/apps/desktop/src/i18n/es.tsindex b2eb566b4ca..2efe8f1ae77 100644--- a/apps/desktop/src/i18n/es.ts+++ b/apps/desktop/src/i18n/es.ts@@ -4928,7 +4928,7 @@ export const esOverrides = {truncated: {title: 'La respuesta quedó incompleta',body: (_provider: string, model: string) =>- `${model || 'El modelo'} alcanzó su límite de salida antes de terminar, así que no se ejecutó nada. Continúa para retomarlo donde se detuvo.`+ `${model || 'El modelo'} se detuvo antes de terminar, así que su último paso no se ejecutó. Continúa para retomarlo donde se detuvo.`},invalid_response: {title: 'No se pudo leer la respuesta',diff --git a/apps/desktop/src/i18n/fr.ts b/apps/desktop/src/i18n/fr.tsindex a350134108d..52703b4ca9e 100644--- a/apps/desktop/src/i18n/fr.ts+++ b/apps/desktop/src/i18n/fr.ts@@ -4950,7 +4950,7 @@ export const frOverrides = {truncated: {title: 'La réponse a été écourtée',body: (_provider, model) =>- `${model || 'Le modèle'} a atteint sa limite de sortie avant la fin ; rien n'a donc été exécuté. Continuez pour reprendre là où il s'est arrêté.`+ `${model || 'Le modèle'} s'est arrêté avant la fin ; sa dernière étape n'a donc pas été exécutée. Continuez pour reprendre là où il s'est arrêté.`},invalid_response: {title: 'Impossible de lire la réponse',diff --git a/apps/desktop/src/i18n/ja_error_codes.ts b/apps/desktop/src/i18n/ja_error_codes.tsindex 909be319849..7e4d0e8e908 100644--- a/apps/desktop/src/i18n/ja_error_codes.ts+++ b/apps/desktop/src/i18n/ja_error_codes.ts@@ -55,7 +55,7 @@ export const jaErrorCodes: Partial<ThreadCopy['errorCodes']> = {truncated: {title: '返信が途中で切れました',body: (_provider, model) =>- `${model || 'モデル'} が完了前に出力上限に達したため、何も実行されませんでした。「続行」で中断したところから再開できます。`+ `${model || 'モデル'} が完了前に停止したため、最後のステップは実行されませんでした。「続行」で中断したところから再開できます。`},loop_error: {title: 'Hermes はこのステップを完了できませんでした',diff --git a/apps/desktop/src/i18n/zh-hant_assistant.ts b/apps/desktop/src/i18n/zh-hant_assistant.tsindex e5b9c1ae4e6..f9b2919eae3 100644--- a/apps/desktop/src/i18n/zh-hant_assistant.ts+++ b/apps/desktop/src/i18n/zh-hant_assistant.ts@@ -153,7 +153,7 @@ export const zhHantAssistant = {truncated: {title: '回覆被截斷',body: (_provider, model) =>- `${model || '模型'}在完成前達到輸出上限,因此沒有執行任何動作。按「繼續」即可從中斷處接續。`+ `${model || '模型'}在完成前停止,因此最後一步沒有執行。按「繼續」即可從中斷處接續。`},invalid_response: {title: '無法讀取回覆',diff --git a/apps/desktop/src/i18n/zh_error_codes.ts b/apps/desktop/src/i18n/zh_error_codes.tsindex 7aa154edb65..d697989c19d 100644--- a/apps/desktop/src/i18n/zh_error_codes.ts+++ b/apps/desktop/src/i18n/zh_error_codes.ts@@ -38,8 +38,7 @@ export const zhErrorCodes: Partial<ThreadCopy['errorCodes']> = {},truncated: {title: '回复被截断',- body: (_provider, model) =>- `${model || '模型'} 在完成前达到了输出上限,因此未执行任何操作。点击“继续”从中断处接着生成。`+ body: (_provider, model) => `${model || '模型'} 在完成前停止,因此最后一步没有执行。点击“继续”从中断处接着生成。`},loop_error: {title: 'Hermes 无法完成此步骤',diff --git a/apps/desktop/src/lib/error-surface.test.ts b/apps/desktop/src/lib/error-surface.test.tsindex f8ea7d01d9c..998ef4d2e20 100644--- a/apps/desktop/src/lib/error-surface.test.ts+++ b/apps/desktop/src/lib/error-surface.test.ts@@ -5,8 +5,9 @@ import { en } from '@/i18n/en'import {ERROR_CODE_KEYS,errorCardActions,+ errorCardOffers,errorCardSeverity,- errorRecoveryPlan,+ errorCardShowsDiagnostics,type ErrorSurface,formatErrorDiagnostics,formatResetClock,@@ -148,7 +149,7 @@ describe('error copy never names a hidden Retry', () => {retryable: false}- expect(errorRecoveryPlan(surface).retry).toBe(true)+ expect(errorCardOffers(surface, 'retry')).toBe(true)})it('a WAF block names the firewall and the User-Agent fix, not the key and not a retry', () => {@@ -179,11 +180,7 @@ describe('free-tier refusals', () => {it('carries the backend sentence and offers the free sign-in, never an OAuth re-login', () => {expect(surface.message).toBe('Using Hermes without signing in is switched off right now. To sign in: /login.')- const plan = errorRecoveryPlan(surface)- expect(plan.signInFreeTier).toBe(true)- expect(plan.signInAgain).toBe(false)- expect(plan.retry).toBe(false)- expect(plan.switchProvider).toBe(true)+ expect(errorCardActions(surface)).toEqual({ primary: 'sign_in_free_tier' })})it('renders the backend sentence as the body under its own title', () => {@@ -197,7 +194,7 @@ describe('free-tier refusals', () => {expect(errorCardText(en.assistant.thread, bare).body).toBe(en.assistant.thread.errorCodes.free_tier_rate_limited.body)- expect(errorRecoveryPlan(bare).retry).toBe(true)+ expect(errorCardOffers(bare, 'retry')).toBe(true)})})@@ -206,7 +203,7 @@ describe('cron session read-only (#141348)', () => {const surface = parseErrorSurface({ layer: 'gateway', code: 'cron_session_read_only', retryable: false })expect(errorCardText(en.assistant.thread, surface)).toEqual(en.assistant.thread.errorCodes.cron_session_read_only)- expect(errorRecoveryPlan(surface)).toMatchObject({ retry: false, startNewSession: true })+ expect(errorCardActions(surface)).toEqual({ primary: 'start_new_session' })})})@@ -221,7 +218,7 @@ describe('usage-window refusal', () => {expect(body).not.toBe(errorCardText(en.assistant.thread, plain).body)})- it('an older backend (no structured limit): Open billing, Retry and the model menu; no diagnostics', () => {+ it('an older backend (no structured limit): Open billing and the model menu; no diagnostics', () => {const surface = parseErrorSurface({code: 'usage_window',layer: 'billing',@@ -229,15 +226,13 @@ describe('usage-window refusal', () => {retryable: true})!- const plan = errorRecoveryPlan(surface)- expect(plan.openBilling && plan.retry && plan.switchProvider).toBe(true)- expect(plan.switchToModel || plan.useCredits).toBe(false)- expect(plan.diagnostics).toBe(false)+ expect(errorCardActions(surface)).toEqual({ primary: 'open_billing', secondary: 'choose_model' })+ expect(errorCardShowsDiagnostics(surface)).toBe(false)expect(surface.resetsAt).toBe(1_800_000_000)- // Every other billing failure keeps today's card.- const plain = errorRecoveryPlan(parseErrorSurface({ code: 'billing', layer: 'billing', retryable: false }))- expect(plain.openBilling).toBe(false)- expect(plain.diagnostics).toBe(true)+ // Out of credits is a fault worth diagnosing.+ expect(errorCardShowsDiagnostics(parseErrorSurface({ code: 'billing', layer: 'billing', retryable: false }))).toBe(+ true+ )})it('with a structured limit: one-click Switch to <model> and Use credits, no provider menu', () => {@@ -262,35 +257,27 @@ describe('usage-window refusal', () => {{ label: 'bad', model: 'bad', note: '', provider: 'nous' }]})- const plan = errorRecoveryPlan(surface)- expect(plan.switchToModel && plan.useCredits && plan.retry).toBe(true)- expect(plan.openBilling || plan.switchProvider || plan.diagnostics).toBe(false)+ expect(errorCardActions(surface)).toEqual({ primary: 'switch_to_model', secondary: 'use_credits' })// No balance: Add credits (Billing) instead of Use credits.- const add = errorRecoveryPlan(- parseErrorSurface({- code: 'usage_window',- layer: 'billing',- retryable: true,- usage_limit: { credits: { action: 'add_credits' }, suggestions: [] }- })- )+ const add = parseErrorSurface({+ code: 'usage_window',+ layer: 'billing',+ retryable: true,+ usage_limit: { credits: { action: 'add_credits' }, suggestions: [] }+ })- expect(add.openBilling).toBe(true)- expect(add.useCredits || add.switchToModel || add.switchProvider).toBe(false)+ expect(errorCardActions(add)).toEqual({ primary: 'open_billing' })// Keep going off and no balance: both steps live on the Billing page, so Open billing (not Use credits).- const both = errorRecoveryPlan(- parseErrorSurface({- code: 'usage_window',- layer: 'billing',- retryable: true,- usage_limit: { credits: { action: 'add_credits_and_keep_going' }, suggestions: [] }- })- )+ const both = parseErrorSurface({+ code: 'usage_window',+ layer: 'billing',+ retryable: true,+ usage_limit: { credits: { action: 'add_credits_and_keep_going' }, suggestions: [] }+ })- expect(both.openBilling).toBe(true)- expect(both.useCredits || both.switchToModel || both.switchProvider).toBe(false)+ expect(errorCardActions(both)).toEqual({ primary: 'open_billing' })})it('falls back to its own table body when an older backend sent no sentence', () => {@@ -328,14 +315,12 @@ describe('limit reset (#98852)', () => {})describe('out of credits (not a window plan)', () => {- it('keeps the card unchanged for Nous and other providers alike', () => {+ it('offers Billing, then another provider, for Nous and other providers alike', () => {for (const provider of ['nous', 'example']) {- const plan = errorRecoveryPlan(- parseErrorSurface({ code: 'billing', layer: 'billing', provider, retryable: false })!- )+ const surface = parseErrorSurface({ code: 'billing', layer: 'billing', provider, retryable: false })- expect(plan.openBilling).toBe(false)- expect(plan.switchProvider && plan.diagnostics).toBe(true)+ expect(errorCardActions(surface)).toEqual({ primary: 'open_billing', secondary: 'switch_provider' })+ expect(errorCardShowsDiagnostics(surface)).toBe(true)}})})@@ -360,6 +345,11 @@ describe('error card actions: one main action, at most one second option', () =>primary: 'open_billing',secondary: 'retry_at_reset'})+ // The reset has passed: the allowance is back, so a plain Retry.+ expect(at({ ...limit('add_credits', []), resets_at: later - 1200 })).toEqual({+ primary: 'open_billing',+ secondary: 'retry'+ })// An older backend sends no structured limit: Billing, or another model.expect(at({ code: 'usage_window', layer: 'billing', retryable: true })).toEqual({primary: 'open_billing',diff --git a/apps/desktop/src/lib/error-surface.ts b/apps/desktop/src/lib/error-surface.tsindex 76bc2a84d89..be80f85478b 100644--- a/apps/desktop/src/lib/error-surface.ts+++ b/apps/desktop/src/lib/error-surface.ts@@ -290,111 +290,13 @@ export function errorCardKey(surface: ErrorSurface | null | undefined): ErrorCar: { layer: surface.layer }}-/** Which recovery buttons the error card offers for a failure. Every flag- * maps to an EXISTING handler in the app; the card only decides visibility. */-export interface ErrorRecoveryPlan {- /** assistant-ui reload of the failed turn. */- retry: boolean- /** Open the model picker (model_not_found). */- chooseModel: boolean- /** Run /compress on this session (context too long). */- compress: boolean- /** requestFreshSession — when this session cannot continue as-is. */- startNewSession: boolean- /** Open the preceding user message in the edit composer (safety refusal). */- editMessage: boolean- /** Reveal the Hermes data folder so the user can free space (disk_full). */- openHermesFolder: boolean- /** Settings → Keys deep link (auth, api_key). */- updateApiKey: boolean- /** Re-run the provider's OAuth sign-in (auth, oauth). */- signInAgain: boolean- /** Open the free-tier sign-in dialog (free_tier_* codes): signing in is free and lifts the refusal. */- signInFreeTier: boolean- /** Open the live session model menu (switches THIS session via- * model.switch); Settings → Models deep link fallback when no chat surface- * is on screen. */- switchProvider: boolean- /** Settings → Billing (usage_window: turn on Keep going, add credits). */- openBilling: boolean- /** usage_window: one-click "Switch to <recommended model>" (this session),- * then re-run the turn. Shown only when the backend named a model. */- switchToModel: boolean- /** usage_window: "Use credits" — turns on Keep going, then re-runs the turn. */- useCredits: boolean- /** Open logs / Send diagnostics / Copy details. Off for a plan limit: it is- * not a fault, and those buttons would bury the two that fix it. */- diagnostics: boolean-}--// Layers where the fix is provider/endpoint/auth config, not a retry.+// Layers where another provider can be the fix (the provider side failed, not the gateway or disk).const SWITCH_PROVIDER_LAYERS: readonly ErrorSurfaceLayer[] = ['auth', 'billing', 'endpoint', 'provider']-// Per-code overrides on top of the layer defaults. `retry: false` here means-// the classifier may call the failure retryable at the transport level, but-// an unchanged retry is known to reproduce it for the user (too long a-// conversation, a blocked prompt, a chat another surface owns).-const CODE_PLANS: Partial<Record<ErrorCodeKey, Partial<ErrorRecoveryPlan>>> = {- SESSION_NOT_OWNED: { retry: false, startNewSession: true },- SESSION_OWNER_BUSY: { retry: true, startNewSession: false },- SESSION_OWNER_UNCONFIRMED: { retry: false, startNewSession: false },- cron_session_read_only: { retry: false, startNewSession: true },- session_read_only: { retry: false, startNewSession: true },- // Retry is the next click once the folder is back or the chat was moved (Move to project).- workspace_unavailable: { retry: true, startNewSession: true },- launch_credentials_unavailable: { retry: false, startNewSession: true },- content_policy_blocked: { editMessage: true, retry: false },- context_overflow: { compress: true, retry: false, startNewSession: true },- disk_full: { openHermesFolder: true, retry: true },- loop_error: { startNewSession: true },- model_not_found: { chooseModel: true, retry: false },- payload_too_large: { compress: true, retry: false, startNewSession: true },- // A window plan's limit: the two ways on, one click each — switch to the- // plan's recommended model, or spend credits (Use credits when Keep going is- // off and there is a balance, else Add credits via Billing). Retry at the- // reset stays. Switch provider is not the fix (the provider is fine).- usage_window: { diagnostics: false, openBilling: true, retry: true, switchProvider: false }-}--export function errorRecoveryPlan(surface: ErrorSurface | null | undefined): ErrorRecoveryPlan {- const oauthReauth = isOAuthReauthSurface(surface)- const apiKeyRejected = isApiKeyRejectedSurface(surface)-- const base: ErrorRecoveryPlan = {- chooseModel: false,- compress: false,- editMessage: false,- openHermesFolder: false,- // Retry re-runs the failed prompt in place. Suppressed when the classifier- // says the failure is deterministic — except for a credential rejection,- // where fixing the credential changes the outcome and Retry is the- // natural second click.- retry: !surface || surface.retryable || oauthReauth || apiKeyRejected,- signInAgain: oauthReauth,- signInFreeTier: isFreeTierSurface(surface),- startNewSession: false,- switchProvider: surface != null && SWITCH_PROVIDER_LAYERS.includes(surface.layer),- openBilling: false,- switchToModel: false,- useCredits: false,- diagnostics: true,- updateApiKey: apiKeyRejected- }-- const key = errorCardKey(surface)- const plan = { ...base, ...('code' in key ? CODE_PLANS[key.code] : undefined) }-- if (surface?.code === 'usage_window') {- const limit = surface.usageLimit- plan.switchToModel = Boolean(limit?.suggestions.length)- plan.useCredits = limit?.credits === 'use_credits'- // Use credits replaces Open billing; Add credits is Open billing.- plan.openBilling = !plan.useCredits- // An older backend (no structured limit): keep the menu so there is still a way on.- plan.switchProvider = !limit- }-- return plan+/** Open logs / Send diagnostics / Copy details. Off for a plan limit: it is not a fault,+ * and those links would bury the actions that fix it. */+export function errorCardShowsDiagnostics(surface: ErrorSurface | null | undefined): boolean {+ return surface?.code !== 'usage_window'}/** Plain-text error-details blob for the error card's "Copy error details". */@@ -479,7 +381,6 @@ export function providerSettingsUrl(surface?: ErrorSurface | null): string | und// One main action + at most one second option per code (Error System Overhaul).const CODE_ACTIONS: Partial<Record<ErrorCodeKey, ErrorCardActions>> = {- // Shown only when the out-of-credits banner is not already on screen for this chat.billing: { primary: 'open_billing', secondary: 'switch_provider' },content_policy_blocked: { primary: 'edit_message' },context_overflow: { primary: 'compress', secondary: 'start_new_session' },@@ -508,21 +409,24 @@ const CODE_ACTIONS: Partial<Record<ErrorCodeKey, ErrorCardActions>> = {// A window plan's limit: switch to the plan's recommended model, else spend credits// (Use credits when Keep going is off with a balance, else Add credits via Billing).// An older backend sends no structured limit: Billing, or another model.+// Once the reset has passed the allowance is back, so a plain Retry replaces the scheduled one.function usageWindowActions(surface: ErrorSurface): ErrorCardActions {- const plan = errorRecoveryPlan(surface)- const credits: ErrorActionId = plan.useCredits ? 'use_credits' : 'open_billing'+ const limit = surface.usageLimit+ const credits: ErrorActionId = limit?.credits === 'use_credits' ? 'use_credits' : 'open_billing'- if (plan.switchToModel) {+ if (limit?.suggestions.length) {return { primary: 'switch_to_model', secondary: credits }}- if (!surface.usageLimit) {+ if (!limit) {return { primary: credits, secondary: 'choose_model' }}- return scheduledRetryDelayMs(surface.resetsAt) === null- ? { primary: credits }- : { primary: credits, secondary: 'retry_at_reset' }+ if (surface.resetsAt === undefined) {+ return { primary: credits }+ }++ return { primary: credits, secondary: scheduledRetryDelayMs(surface.resetsAt) === null ? 'retry' : 'retry_at_reset' }}export function errorCardActions(surface: ErrorSurface | null | undefined): ErrorCardActions {@@ -562,8 +466,9 @@ export function errorCardActions(surface: ErrorSurface | null | undefined): Erroreturn byCode}+ // Signing in is free and lifts the refusal; a transient one (rate limit) can also just be retried.if (isFreeTierSurface(surface)) {- return { primary: 'sign_in_free_tier' }+ return surface.retryable ? { primary: 'sign_in_free_tier', secondary: 'retry' } : { primary: 'sign_in_free_tier' }}if (@@ -578,7 +483,14 @@ export function errorCardActions(surface: ErrorSurface | null | undefined): Erro}// Another provider only helps when the provider side failed (not the gateway or the disk).- return { primary: errorRecoveryPlan(surface).switchProvider ? 'switch_provider' : null }+ return { primary: SWITCH_PROVIDER_LAYERS.includes(surface.layer) ? 'switch_provider' : null }+}++/** Whether the card for this failure offers `action` (as its main action or second option). */+export function errorCardOffers(surface: ErrorSurface | null | undefined, action: ErrorActionId): boolean {+ const { primary, secondary } = errorCardActions(surface)++ return primary === action || secondary === action}/**diff --git a/apps/desktop/src/store/session-states-interrupted-settle.test.ts b/apps/desktop/src/store/session-states-interrupted-settle.test.tsindex f3b6e016634..15397b9e596 100644--- a/apps/desktop/src/store/session-states-interrupted-settle.test.ts+++ b/apps/desktop/src/store/session-states-interrupted-settle.test.ts@@ -2,7 +2,7 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'import type { ClientSessionState } from '@/app/types'import { createClientSessionState } from '@/lib/chat-runtime'-import { errorRecoveryPlan } from '@/lib/error-surface'+import { errorCardOffers } from '@/lib/error-surface'import { requestGatewayForAgent } from '@/store/gateway'import { $activeSessionId, $selectedStoredSessionId, $unreadFinishedSessionIds } from './session'@@ -100,6 +100,6 @@ describe('settling a deliberately interrupted live turn', () => {const failed = card('rt-gone')expect($workingSessionIds.get()).not.toContain('s-gone')expect(failed?.errorSurface?.code).toBe('no_reply')- expect(errorRecoveryPlan(failed?.errorSurface).retry).toBe(true)+ expect(errorCardOffers(failed?.errorSurface, 'retry')).toBe(true)})})diff --git a/apps/desktop/src/store/session-watchdog.test.ts b/apps/desktop/src/store/session-watchdog.test.tsindex 4124ad91abe..cbd82737f97 100644--- a/apps/desktop/src/store/session-watchdog.test.ts+++ b/apps/desktop/src/store/session-watchdog.test.ts@@ -3,7 +3,7 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'import type { ClientSessionState } from '@/app/types'import { chatMessageText, textPart } from '@/lib/chat-messages'import { createClientSessionState } from '@/lib/chat-runtime'-import { errorRecoveryPlan } from '@/lib/error-surface'+import { errorCardOffers } from '@/lib/error-surface'import { requestGatewayForAgent } from '@/store/gateway'import { $activeSessionId, $selectedStoredSessionId, $unreadFinishedSessionIds } from './session'@@ -294,7 +294,7 @@ describe('live turn event silence', () => {const failed = card('rt-empty')expect($workingSessionIds.get()).not.toContain('s-empty')expect(failed?.errorSurface?.code).toBe('no_reply')- expect(errorRecoveryPlan(failed?.errorSurface).retry).toBe(true)+ expect(errorCardOffers(failed?.errorSurface, 'retry')).toBe(true)expect(failed?.error).not.toMatch(/connection/i)})diff --git a/apps/desktop/src/styles.css b/apps/desktop/src/styles.cssindex 1b903181e7e..433522bb927 100644--- a/apps/desktop/src/styles.css+++ b/apps/desktop/src/styles.css@@ -1843,7 +1843,9 @@ body.guest-pointer-lock :is(webview, iframe) {text-left. direction is never set, so chrome/layout/list-indent stay LTR (theissue asks not to flip the whole UI). Covers assistant prose, user lines, andboth composers (main + edit share composer-rich-input). */-[data-slot='aui_assistant-message-content'] .aui-md :where(p, [data-tool-media-paragraph], h1, h2, h3, h4, h5, h6, li, blockquote),+[data-slot='aui_assistant-message-content']+ .aui-md+ :where(p, [data-tool-media-paragraph], h1, h2, h3, h4, h5, h6, li, blockquote),[data-slot='aui_user-inline-text'],[data-slot='composer-rich-input'] {unicode-bidi: plaintext;@@ -1871,7 +1873,9 @@ body.guest-pointer-lock :is(webview, iframe) {every block takes the chosen direction (every line of a multi-line draftincluded). Auto stamps no dir, so nothing here matches. Code and KaTeX keeptheir isolated-LTR rules below. */-[data-slot='aui_assistant-message-content'] .aui-md[dir] :where(p, [data-tool-media-paragraph], h1, h2, h3, h4, h5, h6, li, blockquote),+[data-slot='aui_assistant-message-content']+ .aui-md[dir]+ :where(p, [data-tool-media-paragraph], h1, h2, h3, h4, h5, h6, li, blockquote),[data-slot='aui_user-inline-text'][dir],[data-slot='composer-rich-input'][dir] {unicode-bidi: normal;@@ -3974,9 +3978,12 @@ html[data-hermes-desktop-host='browser'] [data-slot='sidebar-container'] {* One layout for every severity; severity only changes the tint and the icon colour.* blocking: rust tint + rust icon. degraded: white card + muted icon + dismiss. */.aui-error-card {- --err-ink: #000d53;- --err-ink-muted: rgba(0, 13, 83, 0.6);- --err-action: #0000f2;+ /* Theme tokens, so light, dark and custom skins all follow. Blocking tints with the+ app's destructive colour. */+ --err-ink: var(--ui-text-primary);+ --err-ink-muted: var(--ui-text-tertiary);+ --err-action: var(--ui-accent-secondary);+ --err-alert: var(--dt-destructive);position: relative;margin-top: 0.375rem;display: flex;@@ -3984,9 +3991,9 @@ html[data-hermes-desktop-host='browser'] [data-slot='sidebar-container'] {gap: 12px;max-width: 640px;overflow: clip;- border: 1px solid rgba(0, 0, 0, 0.1);+ border: 1px solid var(--ui-stroke-tertiary);border-radius: 8px;- background: #fbfcfc;+ background: var(--ui-bg-card);padding: 16px;color: var(--err-ink);font-size: 13px;@@ -3994,8 +4001,8 @@ html[data-hermes-desktop-host='browser'] [data-slot='sidebar-container'] {}.aui-error-card[data-severity='blocking'] {- border-color: rgba(162, 42, 32, 0.1);- background: rgba(162, 42, 32, 0.03);+ border-color: color-mix(in srgb, var(--err-alert) 18%, transparent);+ background: color-mix(in srgb, var(--err-alert) 5%, transparent);}.aui-error-card-head {@@ -4008,11 +4015,11 @@ html[data-hermes-desktop-host='browser'] [data-slot='sidebar-container'] {width: 20px;height: 20px;flex-shrink: 0;- color: rgba(0, 0, 0, 0.4);+ color: var(--err-ink-muted);}.aui-error-card[data-severity='blocking'] .aui-error-card-icon {- color: #a22a20;+ color: var(--err-alert);}.aui-error-card-text {@@ -4037,12 +4044,14 @@ html[data-hermes-desktop-host='browser'] [data-slot='sidebar-container'] {font-weight: 400;}+/* Wraps so a narrow split pane drops the details toggle under the actions instead of clipping it. */.aui-error-card-row {display: flex;min-height: 30px;+ flex-wrap: wrap;align-items: center;justify-content: space-between;- gap: 12px;+ gap: 8px 12px;}.aui-error-card-actions {@@ -4108,7 +4117,10 @@ html[data-hermes-desktop-host='browser'] [data-slot='sidebar-container'] {line-height: 1.4;white-space: nowrap;cursor: pointer;- transition: background-color 150ms ease-out, box-shadow 150ms ease-out, transform 150ms ease-out;+ transition:+ background-color 150ms ease-out,+ box-shadow 150ms ease-out,+ transform 150ms ease-out;}.aui-error-btn:hover {@@ -4137,7 +4149,9 @@ html[data-hermes-desktop-host='browser'] [data-slot='sidebar-container'] {}.aui-error-btn-ghost:active {- box-shadow: inset 0 0 0 0.5px var(--err-action), inset 0 1px 4px 0 rgba(0, 0, 0, 0.08);+ box-shadow:+ inset 0 0 0 0.5px var(--err-action),+ inset 0 1px 4px 0 color-mix(in srgb, var(--err-ink) 8%, transparent);}.aui-error-btn:disabled {@@ -4163,9 +4177,11 @@ html[data-hermes-desktop-host='browser'] [data-slot='sidebar-container'] {align-items: flex-start;gap: 12px;border-radius: 3px;- background: #000629;+ /* Nous DS Copy (CommandBlock): a code slab that stays dark in every theme, like a terminal. */+ box-shadow: inset 0 0 0 1px var(--ui-stroke-tertiary);+ background: color-mix(in srgb, black 88%, var(--ui-accent-secondary));padding: 12px 12px 12px 14px;- color: #ffffff;+ color: white;}.aui-error-details-raw {@@ -4198,11 +4214,6 @@ html[data-hermes-desktop-host='browser'] [data-slot='sidebar-container'] {transition-duration: 0ms;}-.aui-error-copy-glyph[data-copied] {- color: #3ecf8e;- opacity: 1;-}-.aui-error-details-links {display: flex;flex-wrap: wrap;@@ -4228,36 +4239,3 @@ html[data-hermes-desktop-host='browser'] [data-slot='sidebar-container'] {background: none;color: var(--err-ink);}--/* Dark theme: same structure and rules; the code slab goes neutral-dark with a hairline. */-.dark .aui-error-card {- --err-ink: var(--ui-text-primary);- --err-ink-muted: var(--ui-text-tertiary);- --err-action: #9aa3ff;- border-color: rgba(255, 255, 255, 0.1);- background: rgba(255, 255, 255, 0.03);-}--.dark .aui-error-card[data-severity='blocking'] {- border-color: rgba(226, 92, 80, 0.28);- background: rgba(226, 92, 80, 0.08);-}--.dark .aui-error-card-icon {- color: rgba(255, 255, 255, 0.5);-}--.dark .aui-error-card[data-severity='blocking'] .aui-error-card-icon {- color: #ec6a5e;-}--.dark .aui-error-details-slab {- box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);- background: rgba(0, 0, 0, 0.45);-}---.dark .aui-error-card-close img {- filter: invert(1);- opacity: 0.85;-}