fix(native-chat): suppress cancellation toast during retry

This commit is contained in:
Merge Sim
2026-09-02 01:58:57 -07:00
parent b02e050024
commit d2546e599d
2 changed files with 32 additions and 0 deletions
@@ -196,6 +196,35 @@ describe('startStructuredCodexLaunch', () => {
expect(toast.error).not.toHaveBeenCalled()
})
it('does not toast when cancelled during retry reconciliation', async () => {
const worktreeId = 'wt-retry-close-race'
const intent = launchIntent(worktreeId, 'session-retry-close-race')
let resolveRetryRefresh!: (snapshots: RuntimeMobileSessionTabsResult[]) => void
mocks.createIntent.mockReturnValueOnce(intent)
mocks.launch
.mockRejectedValueOnce(new Error('first response lost'))
.mockRejectedValueOnce(new Error('retry response lost'))
vi.mocked(refreshLocalStructuredSessionTabs)
.mockResolvedValueOnce([])
.mockImplementationOnce(
() =>
new Promise<RuntimeMobileSessionTabsResult[]>((resolve) => {
resolveRetryRefresh = resolve
})
)
startStructuredCodexLaunch(worktreeId)
await vi.waitFor(() => expect(refreshLocalStructuredSessionTabs).toHaveBeenCalledTimes(2))
expect(cancelStructuredCodexLaunch(worktreeId, intent.sessionId)).toBe(true)
resolveRetryRefresh([])
await flushLaunchSettlement()
expect(mocks.launch).toHaveBeenCalledTimes(2)
expect(toast.error).not.toHaveBeenCalled()
expect(mocks.abandonIntent).toHaveBeenCalledWith(intent)
})
it('keeps an unresolved identity reserved until inventory reconciles it', async () => {
const worktreeId = 'wt-still-unknown'
const intent = launchIntent(worktreeId)
@@ -88,6 +88,9 @@ async function retrySameIntent(state: StructuredLaunchState, priorError: unknown
try {
return await verifyPublishedSession(state.intent)
} catch {
if (state.cancelled) {
throw new StructuredAgentSessionLaunchCancelledError()
}
state.visibilityUnknown = true
throw error ?? priorError
}