The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(desktop): Continue keeps the user's draft; credit card opens the right billing; reset and truncation edge cases
kshitijk4poor685bb3c8c4f5
diff --git a/apps/desktop/src/app/chat/composer/hooks/use-composer-submit.test.tsx b/apps/desktop/src/app/chat/composer/hooks/use-composer-submit.test.tsxindex f3411c27494..c43b4f8b98b 100644--- a/apps/desktop/src/app/chat/composer/hooks/use-composer-submit.test.tsx+++ b/apps/desktop/src/app/chat/composer/hooks/use-composer-submit.test.tsx@@ -170,16 +170,19 @@ describe('useComposerSubmit external request routing', () => {vi.restoreAllMocks()})- it.each(['interrupt', 'steer'] as const)('keeps a rejected %s draft in the local queue without submit admission', async mode => {- const h = renderSubmitHook({ busy: true, busyInputMode: mode, text: 'keep guidance' })- h.onSteer.mockRejectedValue(new Error('correction unsupported'))- act(() => h.hook.result.current.submitDraft())- await waitFor(() => expect(getQueuedPrompts('stored-session').map(({ text }) => text)).toEqual(['keep guidance']))- expect(h.onSteer).toHaveBeenCalledWith('keep guidance', mode)- expect(h.onSubmit).not.toHaveBeenCalled()- expect(h.queueCurrentDraft).not.toHaveBeenCalled()- clearQueuedPrompts('stored-session')- })+ it.each(['interrupt', 'steer'] as const)(+ 'keeps a rejected %s draft in the local queue without submit admission',+ async mode => {+ const h = renderSubmitHook({ busy: true, busyInputMode: mode, text: 'keep guidance' })+ h.onSteer.mockRejectedValue(new Error('correction unsupported'))+ act(() => h.hook.result.current.submitDraft())+ await waitFor(() => expect(getQueuedPrompts('stored-session').map(({ text }) => text)).toEqual(['keep guidance']))+ expect(h.onSteer).toHaveBeenCalledWith('keep guidance', mode)+ expect(h.onSubmit).not.toHaveBeenCalled()+ expect(h.queueCurrentDraft).not.toHaveBeenCalled()+ clearQueuedPrompts('stored-session')+ }+ )it('routes a refused native steer through canonical queue admission', async () => {$connection.set({ mode: 'local', wsUrl: 'ws://localhost/api/ws?native_dial=unminted' } as never)@@ -189,9 +192,17 @@ describe('useComposerSubmit external request routing', () => {try {act(() => h.hook.result.current.steerDraft())- await waitFor(() => expect(h.onSubmit).toHaveBeenCalledWith('keep guidance', expect.objectContaining({ fromQueue: true, sessionId: 'runtime-session', storedSessionId: 'stored-session' })))+ await waitFor(() =>+ expect(h.onSubmit).toHaveBeenCalledWith(+ 'keep guidance',+ expect.objectContaining({ fromQueue: true, sessionId: 'runtime-session', storedSessionId: 'stored-session' })+ )+ )expect(getQueuedPrompts('stored-session')).toEqual([])- } finally { $connection.set(null); $queuedPromptsBySession.set({}) }+ } finally {+ $connection.set(null)+ $queuedPromptsBySession.set({})+ }})it.each([true, false])('steers a busy external visible submit and queues only on rejection (%s)', async accepted => {@@ -248,6 +259,7 @@ describe('useComposerSubmit external request routing', () => {expect(onSubmit).toHaveBeenCalledExactlyOnceWith('[setup] links opened', {submission_id: expect.any(String),+ attachments: [],composerScope: 'stored-session',displayKind: 'hidden'})@@ -257,6 +269,33 @@ describe('useComposerSubmit external request routing', () => {expect(stashAt).not.toHaveBeenCalled()})+ it.each([true, false])(+ 'sends an idle external request without the draft files, and queues a rejected one instead of overwriting the draft (%s)',+ async accepted => {+ const draftFile = { id: 'draft-file', kind: 'file', label: 'notes.md' } as never++ const { onSubmit, loadIntoComposer, stashAt, clearDraft } = renderSubmitHook({+ attachments: [draftFile],+ busy: false,+ text: 'half-written draft'+ })++ onSubmit.mockResolvedValue(accepted)++ await act(async () => {+ expect(requestComposerSubmit('continue', { target: 'main' })).toBe(true)+ })++ expect(onSubmit).toHaveBeenCalledExactlyOnceWith('continue', expect.objectContaining({ attachments: [] }))+ expect(clearDraft).not.toHaveBeenCalled()+ expect(loadIntoComposer).not.toHaveBeenCalled()+ expect(stashAt).not.toHaveBeenCalled()+ expect(getQueuedPrompts('stored-session').map(({ text, attachments }) => ({ text, attachments }))).toEqual(+ accepted ? [] : [{ text: 'continue', attachments: [] }]+ )+ }+ )+it('does not fan out a main ship across keep-alives or other projects', async () => {const visibleMain = renderSubmitHook({ sessionKey: 'session-a' })const hiddenMain = renderSubmitHook({ sessionKey: 'session-b', visible: false })@@ -273,6 +312,7 @@ describe('useComposerSubmit external request routing', () => {await waitFor(() =>expect(visibleMain.onSubmit).toHaveBeenCalledWith('ship this branch', {submission_id: expect.any(String),+ attachments: [],composerScope: 'session-a'}))@@ -291,6 +331,7 @@ describe('useComposerSubmit external request routing', () => {await waitFor(() =>expect(tile.onSubmit).toHaveBeenCalledWith('ship project B', {submission_id: expect.any(String),+ attachments: [],composerScope: 'tile-session'}))@@ -306,6 +347,7 @@ describe('useComposerSubmit external request routing', () => {await waitFor(() =>expect(second.onSubmit).toHaveBeenCalledWith('ship exactly one session', {submission_id: expect.any(String),+ attachments: [],composerScope: 'session-second'}))@@ -325,6 +367,7 @@ describe('useComposerSubmit external request routing', () => {await waitFor(() =>expect(visibleB.onSubmit).toHaveBeenCalledWith('ship session B', {submission_id: expect.any(String),+ attachments: [],composerScope: 'session-b'}))@@ -470,7 +513,10 @@ describe('useComposerSubmit busy-turn routing', () => {})await waitFor(() =>- expect(onSubmit).toHaveBeenCalledWith('/compress preserve context', { submission_id: expect.any(String), composerScope: 'stored-session' })+ expect(onSubmit).toHaveBeenCalledWith('/compress preserve context', {+ submission_id: expect.any(String),+ composerScope: 'stored-session'+ }))expect(clearDraft).toHaveBeenCalledTimes(1)expect(onSteer).not.toHaveBeenCalled()@@ -575,7 +621,9 @@ describe('useComposerSubmit busy-turn routing', () => {hook.result.current.submitDraft()})- await waitFor(() => expect(onSteer).toHaveBeenCalledWith('```terminal\nselected terminal lines\n```\n\nlook at', 'interrupt'))+ await waitFor(() =>+ expect(onSteer).toHaveBeenCalledWith('```terminal\nselected terminal lines\n```\n\nlook at', 'interrupt')+ )expect(queueCurrentDraft).not.toHaveBeenCalled()})@@ -960,7 +1008,12 @@ describe('useComposerSubmit with a blocking prompt parked on the session', () =>hook.result.current.submitDraft()})- await waitFor(() => expect(onSubmit).toHaveBeenCalledWith('/status', { submission_id: expect.any(String), composerScope: 'stored-session' }))+ await waitFor(() =>+ expect(onSubmit).toHaveBeenCalledWith('/status', {+ submission_id: expect.any(String),+ composerScope: 'stored-session'+ })+ )expect(queueCurrentDraft).not.toHaveBeenCalled()expect(onSteer).not.toHaveBeenCalled()})@@ -1070,7 +1123,12 @@ describe('useComposerSubmit with a setup card waiting in the onboarding chat', (it('runs no slash command while setup is in progress: the words stay and a note says why', () => {$onboardingPhase.set('shown')- $onboardingSession.set({ connectionId: null, runId: 'run-1', runtimeId: 'runtime-session', storedId: 'stored-session' })+ $onboardingSession.set({+ connectionId: null,+ runId: 'run-1',+ runtimeId: 'runtime-session',+ storedId: 'stored-session'+ })$notifications.set([])const respond = parkCard('name')@@ -1092,7 +1150,12 @@ describe('useComposerSubmit with a setup card waiting in the onboarding chat', (it('queues no slash command while setup is in progress (Cmd/Ctrl+Enter)', () => {$onboardingPhase.set('shown')- $onboardingSession.set({ connectionId: null, runId: 'run-1', runtimeId: 'runtime-session', storedId: 'stored-session' })+ $onboardingSession.set({+ connectionId: null,+ runId: 'run-1',+ runtimeId: 'runtime-session',+ storedId: 'stored-session'+ })const { clearDraft, hook, onSubmit, queueCurrentDraft } = renderSubmitHook({ busy: true, text: '/help' })@@ -1105,7 +1168,12 @@ describe('useComposerSubmit with a setup card waiting in the onboarding chat', (it('runs slash commands as usual in the same chat once setup has ended', () => {$onboardingPhase.set('done')- $onboardingSession.set({ connectionId: null, runId: 'run-1', runtimeId: 'runtime-session', storedId: 'stored-session' })+ $onboardingSession.set({+ connectionId: null,+ runId: 'run-1',+ runtimeId: 'runtime-session',+ storedId: 'stored-session'+ })const { hook, onSubmit } = renderSubmitHook({ text: '/help' })diff --git a/apps/desktop/src/app/chat/composer/hooks/use-composer-submit.ts b/apps/desktop/src/app/chat/composer/hooks/use-composer-submit.tsindex 58ea5e56f58..351786d203a 100644--- a/apps/desktop/src/app/chat/composer/hooks/use-composer-submit.ts+++ b/apps/desktop/src/app/chat/composer/hooks/use-composer-submit.ts@@ -132,7 +132,8 @@ export function useComposerSubmit({text: string,attachments?: ComposerAttachment[],displayKind?: 'hidden',- target?: Parameters<ChatBarProps['onSubmit']>[1]+ target?: Parameters<ChatBarProps['onSubmit']>[1],+ onRejected?: () => void) => {// A fresh chat's composer is keyed by its per-lifecycle fresh-draft key// (`__new__:<uuid>`), but the submit contract spells "no session yet" as@@ -180,8 +181,10 @@ export function useComposerSubmit({}// A hidden submit is machine text (a setup note, never something the user- // typed), so a rejection drops it instead of loading it into the draft.- const rejected = displayKind ? () => {} : restore+ // typed), so a rejection drops it instead of loading it into the draft. An+ // external request brings its own (it never took the draft, so it must not+ // overwrite it).+ const rejected = onRejected ?? (displayKind ? () => {} : restore)// A synchronous throw takes the rejection path too: the caller has already cleared the// composer, so a send that fails while it is being prepared must not take the words with it.@@ -235,19 +238,20 @@ export function useComposerSubmit({!inputDisabled) {const current = externalSubmitRef.current-- if (!current.busy) {- current.dispatchSubmit(text, undefined, displayKind)-- return- }-const queueKey = activeQueueSessionKeyRef.current// External requests contain only text; the unsent draft and its attachments stay in the composer.const enqueue = () =>void enqueueQueuedPrompt(queueKey, { text, attachments: [], ...(displayKind ? { displayKind } : {}) })+ if (!current.busy) {+ // Explicitly no attachments: the send must not pick up the draft's files. A rejected+ // visible request goes to the queue (sendable, editable), never over the user's draft.+ current.dispatchSubmit(text, [], displayKind, undefined, displayKind ? () => {} : enqueue)++ return+ }+// A hidden note never becomes a user turn: it rides session.steer into// the model's next tool result, and keeps its kind if it has to queue.if (displayKind) {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 bb5cc3268b1..5cb36cb012e 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@@ -27,6 +27,12 @@ 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())+const openExternalLink = vi.hoisted(() => vi.fn())++vi.mock('@/lib/external-link', async importOriginal => ({+ ...(await importOriginal<Record<string, unknown>>()),+ openExternalLink: (href: string) => openExternalLink(href)+}))vi.mock('@/app/chat/composer/focus', async importOriginal => ({...(await importOriginal<Record<string, unknown>>()),@@ -510,6 +516,45 @@ describe('error card layout (Error System Overhaul)', () => {})it('names an out-of-credits turn on its card too: the banner may be off screen', async () => {+ render(+ <MemoryRouter>+ <Harness assistant={failedMessage({ code: 'billing', layer: 'billing', provider: 'nous', retryable: false })} />+ </MemoryRouter>+ )++ expect(await screen.findByRole('button', { name: en.assistant.thread.errorOpenBillingSettings })).toBeTruthy()+ })++ it("opens the failing provider's own billing page from this chat's billing wall", async () => {+ const { $activeSessionId } = await import('@/store/session')+ const { clearBillingBlock, setBillingBlock } = await import('@/store/billing-block')+ $activeSessionId.set('wall-session')+ setBillingBlock('wall-session', {+ billing_url: 'https://platform.openai.com/settings/organization/billing',+ is_nous: false,+ message: 'out of credits',+ provider: 'openai',+ provider_label: 'OpenAI'+ } as never)++ try {+ render(+ <MemoryRouter>+ <Harness+ assistant={failedMessage({ code: 'billing', layer: 'billing', provider: 'openai', retryable: false })}+ />+ </MemoryRouter>+ )++ fireEvent.click(await screen.findByRole('button', { name: en.assistant.thread.errorOpenBillingSettings }))+ expect(openExternalLink).toHaveBeenCalledWith('https://platform.openai.com/settings/organization/billing')+ } finally {+ clearBillingBlock()+ $activeSessionId.set(null)+ }+ })++ it("never sends a third-party provider's credit failure to Nous billing without its billing link", async () => {render(<MemoryRouter><Harness@@ -518,7 +563,8 @@ describe('error card layout (Error System Overhaul)', () => {</MemoryRouter>)- expect(await screen.findByRole('button', { name: en.assistant.thread.errorOpenBillingSettings })).toBeTruthy()+ expect(await screen.findByRole('button', { name: en.assistant.thread.errorSwitchProvider })).toBeTruthy()+ expect(screen.queryByRole('button', { name: en.assistant.thread.errorOpenBillingSettings })).toBeNull()})})diff --git a/apps/desktop/src/components/assistant-ui/thread/assistant-message.tsx b/apps/desktop/src/components/assistant-ui/thread/assistant-message.tsxindex bd538ab73b3..3e25d491c22 100644--- a/apps/desktop/src/components/assistant-ui/thread/assistant-message.tsx+++ b/apps/desktop/src/components/assistant-ui/thread/assistant-message.tsx@@ -83,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 { requestBillingSettings } from '@/store/billing-block'+import { $billingBlock, requestBillingSettings, runBillingRecovery } 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'@@ -1095,6 +1095,26 @@ const textButton = (className: string, onClick: () => void, label: ReactNode) =></button>)+// Out of credits runs the same recovery as the banner and toast: the failing provider's own+// billing page (Nous → Settings → Billing). A plan limit is Nous billing. Without this chat's+// billing descriptor Hermes doesn't know where a third-party provider bills, so no button.+const OpenBillingAction: FC<{ className: string; label: string; surface?: ErrorSurface }> = ({+ className,+ label,+ surface+}) => {+ const runtimeId = useStore(useSessionView().$runtimeId)+ const wall = useStore($billingBlock)+ const block = surface?.code !== 'usage_window' && wall?.sessionId === runtimeId ? wall.block : null+ const nousBilling = surface?.code === 'usage_window' || (surface?.provider || 'nous').toLowerCase() === 'nous'++ if (!block && !nousBilling) {+ return null+ }++ return textButton(className, () => (block ? runBillingRecovery(block) : requestBillingSettings()), label)+}+// One renderer per action (Error System Overhaul action table → the app's existing handlers).const ERROR_ACTION_RENDERERS: Record<ErrorActionId, (ctx: ErrorActionContext) => ReactNode> = {switch_to_model: ({ className, surface }) => {@@ -1103,7 +1123,9 @@ const ERROR_ACTION_RENDERERS: Record<ErrorActionId, (ctx: ErrorActionContext) =>return suggestion ? <SwitchToModelAction className={className} suggestion={suggestion} /> : null},use_credits: ({ className }) => <UseCreditsAction className={className} />,- open_billing: ({ className, copy }) => textButton(className, requestBillingSettings, copy.errorOpenBillingSettings),+ open_billing: ({ className, copy, surface }) => (+ <OpenBillingAction className={className} label={copy.errorOpenBillingSettings} surface={surface} />+ ),retry: ({ className, copy }) => (<ActionBarPrimitive.Reload asChild><buttondiff --git a/apps/desktop/src/i18n/ar_assistant.ts b/apps/desktop/src/i18n/ar_assistant.tsindex c6e8c9235fa..91282e92b61 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 f79a027ba56..a68b5029360 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 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.`+ `${model || 'Das Modell'} hat seine Antwort vor dem Ende abgebrochen. 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 55bb6496649..a6d323b7a0e 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'} stopped before finishing, so its last step didn't run. Continue to pick up where it stopped.`+ `${model || 'The model'} stopped before finishing its reply. 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 2efe8f1ae77..9325c7cbb02 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'} se detuvo antes de terminar, así que su último paso no se ejecutó. Continúa para retomarlo donde se detuvo.`+ `${model || 'El modelo'} se detuvo antes de terminar su respuesta. 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 52703b4ca9e..9bff916b69a 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'} 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é.`+ `${model || 'Le modèle'} s'est arrêté avant d'avoir fini sa réponse. 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 7e4d0e8e908..fd24c27d866 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 f9b2919eae3..ecf5a940b59 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 d697989c19d..b5ec4799cd0 100644--- a/apps/desktop/src/i18n/zh_error_codes.ts+++ b/apps/desktop/src/i18n/zh_error_codes.ts@@ -38,7 +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 998ef4d2e20..1803b559c1b 100644--- a/apps/desktop/src/lib/error-surface.test.ts+++ b/apps/desktop/src/lib/error-surface.test.ts@@ -345,6 +345,8 @@ describe('error card actions: one main action, at most one second option', () =>primary: 'open_billing',secondary: 'retry_at_reset'})+ // Too far ahead for a browser timer (a monthly window): no Retry until it passes.+ expect(at({ ...limit('add_credits', []), resets_at: later + 30 * 86_400 })).toEqual({ primary: 'open_billing' })// 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',diff --git a/apps/desktop/src/lib/error-surface.ts b/apps/desktop/src/lib/error-surface.tsindex be80f85478b..113c99f6955 100644--- a/apps/desktop/src/lib/error-surface.ts+++ b/apps/desktop/src/lib/error-surface.ts@@ -426,7 +426,14 @@ function usageWindowActions(surface: ErrorSurface): ErrorCardActions {return { primary: credits }}- return { primary: credits, secondary: scheduledRetryDelayMs(surface.resetsAt) === null ? 'retry' : 'retry_at_reset' }+ if (surface.resetsAt * 1000 <= Date.now()) {+ return { primary: credits, secondary: 'retry' }+ }++ // Still ahead: Retry at the reset, unless it is too far off for a browser timer (a monthly window).+ return scheduledRetryDelayMs(surface.resetsAt) === null+ ? { primary: credits }+ : { primary: credits, secondary: 'retry_at_reset' }}export function errorCardActions(surface: ErrorSurface | null | undefined): ErrorCardActions {