Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions mobile/src/session/MobileNativeChatMessage.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -352,17 +352,15 @@ describe('MobileNativeChatMessage', () => {
}),
{ surface: 'row', agentName: 'OpenCode' }
)
expect(host.text).toBe(
'OpenCode hit its usage limit. Send a message once it resets to continue.'
)
expect(host.text).toBe('OpenCode hit its usage limit.')
const tree = render(statusRow({ kind: 'status', tone: 'warning', ...host }))
const text = tree.root.find(
(node) => String(node.type) === 'Text' && node.props.selectable === true
)
expect(text.props.children).toEqual(
hasReset
? expect.stringMatching(
/^OpenCode hit its usage limit\. Send a message once it resets to continue\. It resets at (3:42\sPM|15:42)\.$/
/^OpenCode hit its usage limit\. It resets at (3:42\sPM|15:42)\.$/
Comment thread
brennanb2025 marked this conversation as resolved.
Resolved
)
: host.text
)
Expand Down
2 changes: 1 addition & 1 deletion src/main/acp/acp-timeline-turn-failures.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ describe('a failed ACP turn says why', () => {
{
kind: 'status',
tone: 'warning',
text: 'The agent hit its usage limit. Send a message once it resets to continue.',
text: 'The agent hit its usage limit.',
failure: { kind: 'usageLimitReached', detail: { text: REASON, audience: 'person' } }
}
])
Expand Down
2 changes: 1 addition & 1 deletion src/main/claude/claude-usage-limits.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ describe('a Claude usage limit', () => {
const limitRow = {
kind: 'status',
tone: 'warning',
text: 'Claude hit its session limit. Send a message once it resets to continue.',
text: 'Claude hit its session limit.',
failure: {
kind: 'usageLimitReached',
usageLimit: { window: 'session', resetsAt: RESETS_AT_S * 1000 },
Expand Down
2 changes: 1 addition & 1 deletion src/main/codex/codex-usage-limits.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ describe('a Codex usage limit', () => {
expect(bodies.filter((body) => body.kind === 'status')).toEqual([
expect.objectContaining({
tone: 'warning',
text: 'Codex hit its weekly limit. Send a message once it resets to continue.',
text: 'Codex hit its weekly limit.',
failure: {
kind: 'usageLimitReached',
usageLimit: { window: 'weekly', resetsAt: RESETS_AT_S * 1000 },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import '@testing-library/jest-dom/vitest'

import { cleanup, fireEvent, render, screen } from '@testing-library/react'
import { cleanup, render, screen } from '@testing-library/react'
import { afterAll, afterEach, beforeAll, describe, expect, it, vi } from 'vitest'

// Why: these fixtures have neither inline visual owners nor sender navigation.
Expand Down Expand Up @@ -259,7 +259,7 @@ const usageLimitView = {
}

it.each(['claude', 'codex', 'grok'] as const)(
'keeps a collapsed %s quota failure and Continue visible',
'keeps a collapsed %s quota warning visible without a continuation action',
(agent) => {
continueUsageLimit.mockClear()
const items: AgentJournalRenderItem[] = [
Expand Down Expand Up @@ -326,10 +326,8 @@ const usageLimitView = {
expect(screen.queryByText('Earlier work')).toBeNull()
expect(screen.getByText(/hit its session limit/)).toBeVisible()
expect(screen.getByText('Details')).toBeVisible()
const button = screen.getByRole('button', { name: 'Continue' })
expect(button).toBeVisible()
fireEvent.click(button)
expect(continueUsageLimit).toHaveBeenCalledOnce()
expect(screen.queryByRole('button', { name: 'Continue' })).toBeNull()
expect(screen.queryByText(/Send a message once it resets/)).toBeNull()
}
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,28 +236,52 @@ describe('the row a usage limit leaves', () => {
)
}

it('says when the limit resets in this clock, and continues the turn it ended', () => {
it.each([
['future', resetsAt],
['past', new Date(2026, 9, 18, 10, 0).getTime()],
['unknown', undefined]
] as const)('shows a %s reset without a continuation action or instruction', (_state, reset) => {
vi.useFakeTimers({ now: new Date(2026, 9, 18, 12, 30), toFake: ['Date'] })
const continueUsageLimit = vi.fn()
renderStatus(row, null, false, false, 'Claude', {
...NO_OFFER,
usageLimitTurnItemId: 'cut-turn',
continueUsageLimit
})
vi.useRealTimers()
const clock = new Intl.DateTimeFormat(undefined, { hour: 'numeric', minute: '2-digit' }).format(
resetsAt
)
expect(
screen.getByText(`Claude hit its session limit. It resets at ${clock}.`)
).toBeInTheDocument()
fireEvent.click(screen.getByRole('button', { name: 'Continue' }))
expect(continueUsageLimit).toHaveBeenCalledTimes(1)
try {
renderStatus(
{
kind: 'status',
tone: 'warning',
...agentSessionFailureWords(
agentSessionFailureFact('usageLimitReached', {
usageLimit: { window: 'session', ...(reset === undefined ? {} : { resetsAt: reset }) }
}),
{ agentName: 'Claude', surface: 'row' }
)
},
null,
false,
false,
'Claude',
{ ...NO_OFFER, usageLimitTurnItemId: 'cut-turn', continueUsageLimit: vi.fn() }
)
const clock =
reset === undefined
? null
: new Intl.DateTimeFormat(undefined, { hour: 'numeric', minute: '2-digit' }).format(reset)
expect(
screen.getByText(
clock === null
? 'Claude hit its session limit.'
: `Claude hit its session limit. It resets at ${clock}.`
)
).toBeInTheDocument()
expect(screen.queryByRole('button', { name: 'Continue' })).toBeNull()
expect(screen.queryByText(/Send a message once it resets/)).toBeNull()
} finally {
vi.useRealTimers()
}
})

it('tells a chat that has no Continue to send a message', () => {
it('keeps historical usage-limit notices free of continuation guidance', () => {
renderStatus(row, null, false, false, 'Claude')
expect(screen.getByText(/Send a message once it resets to continue\.$/)).toBeInTheDocument()
expect(screen.getByText(/Claude hit its session limit\. It resets at/)).toBeInTheDocument()
expect(screen.queryByText(/Send a message once it resets/)).toBeNull()
expect(screen.queryByRole('button', { name: 'Continue' })).toBeNull()
})
})
Expand Down
13 changes: 0 additions & 13 deletions src/renderer/src/components/native-chat/NativeChatNoticeRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,6 @@ export function NativeChatNoticeRow({
orcaStop?.turnItemId !== undefined && orcaStop.turnItemId === orcaStopView.offeredTurnItemId
const failure = readWholeAgentSessionFailureFact(block.failure)
const antigravitySignInContent = nativeChatAntigravitySignInContent(failure?.kind, agentName)
const usageLimitContinue =
block.usageLimitTurnItemId !== undefined &&
block.usageLimitTurnItemId === orcaStopView.usageLimitTurnItemId
// Only reword auth text fully described by its fact; host text may also carry command advice.
const authSurface =
failure?.kind === 'notSignedIn'
Expand All @@ -164,7 +161,6 @@ export function NativeChatNoticeRow({
'row',
{
agentName,
retryControl: usageLimitContinue,
usageLimitReset: formatUsageLimitResetClock
},
sayAgentSessionFailureTranslated
Expand Down Expand Up @@ -207,15 +203,6 @@ export function NativeChatNoticeRow({
</p>
{continueOffered ? (
<NativeChatInterruptedContinueButton onContinue={orcaStopView.continueNow} />
) : usageLimitContinue ? (
<NativeChatInterruptedContinueButton
onContinue={orcaStopView.continueUsageLimit}
disabled={orcaStopView.usageLimitContinueDisabled}
explanation={translate(
'components.native-chat.interruptedContinue.usageLimitExplanation',
'Asks the agent to continue where it left off. Use it once the limit resets.'
)}
/>
) : null}
</div>
{claudeSignIn && isClaudeSignInFailureKind(block.failure?.kind) ? (
Expand Down
3 changes: 1 addition & 2 deletions src/shared/agent-session-failure-words.ts
Original file line number Diff line number Diff line change
Expand Up @@ -285,8 +285,7 @@ const FAILURE_SENTENCES = {
: providerRetryWords(say, agent(say, context), retry),
usageLimitReached: (context, { usageLimit }, _surface, say) =>
usageLimitWords(say, agent(say, context), usageLimit, {
resetWords: context.usageLimitReset,
continueControl: context.retryControl
resetWords: context.usageLimitReset
}),
previousExitUnverifiable: namingAgent('previousExitUnverifiable'),
sessionNotRestored: namingAgent('sessionNotRestored')
Expand Down
10 changes: 2 additions & 8 deletions src/shared/agent-session-usage-limit-words.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// The words for a usage limit an agent hit: which limit, when it resets, and how to continue.
// The words for a usage limit an agent hit: which limit and when it resets.

import {
sayAgentSessionFailureEnglish,
Expand Down Expand Up @@ -30,19 +30,13 @@ export function usageLimitWords(
limit: AgentSessionUsageLimit | undefined,
context: {
resetWords?: AgentSessionUsageLimitResetWords
/** The surface offers its own Continue, so the words leave out sending a message. */
continueControl?: boolean
}
): string {
const lead = limit?.window
? say('usageLimitReachedNamed', { ...agent, window: say(WINDOW_COPY[limit.window]) })
: say('usageLimitReached', agent)
const reset = limit?.resetsAt !== undefined ? context.resetWords?.(limit.resetsAt) : null
return joinSentences([
lead,
...(reset ? [say('usageLimitResetsAt', { when: reset })] : []),
...(context.continueControl ? [] : [say('usageLimitSendAfterReset')])
])
return joinSentences([lead, ...(reset ? [say('usageLimitResetsAt', { when: reset })] : [])])
}

/** A usage-limit line for a reader that has no agent name to reword it with (the phone): the host's
Expand Down
Loading