Repository navigation
fix(native-chat): after a crash, show an unconfirmed message as sent with one chat notice instead of guessing from the transcript #23604
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from 7 commits
Commits
Show all changes
56 commits
Select commit
Hold shift + click to select a range
4f20e4b
fix(native-chat): decide Claude restart delivery by the message's own…
brennanb2025 07368bb
perf(native-chat): read Claude history on restart only for sends that…
brennanb2025 f1ba667
fix(native-chat): find a Claude send folded or merged into a running …
brennanb2025 2f34ca0
test(native-chat): pin a running turn keeping a Claude send unconfirmed
brennanb2025 f3c6bf1
docs(native-chat): say where Claude keeps a folded frame's id
brennanb2025 4e261d0
fix(native-chat): keep a merged Claude send unconfirmed once the row'…
brennanb2025 2aeb8b0
test(native-chat): pin the Claude adapter sending a frame under its r…
brennanb2025 50b9bf2
fix(native-chat): decide a restarted Claude send only by finding its …
brennanb2025 9a773b5
Merge remote-tracking branch 'origin/main' into brennanb2025/sta-7416…
brennanb2025 bfd12f7
revert(native-chat): drop the transcript id lookup for restarted sends
brennanb2025 460cd0f
fix(native-chat): end a restarted session with one row instead of rea…
brennanb2025 f00a880
fix(native-chat): word the restart row and retire the unconfirmed-id …
brennanb2025 632e5eb
fix(native-chat): draw a send left in doubt as sent, with no barrier …
brennanb2025 8083343
test(native-chat): read the new cases' calls without casts
brennanb2025 ddd9c15
test(native-chat): name the drawn-as-sent projection cases plainly
brennanb2025 96134dc
test(native-chat): read the sent requests by shape, not through the n…
brennanb2025 0140e10
fix(native-chat): keep a live unknown send until it settles, so a lat…
brennanb2025 ef56226
docs(native-chat): say an older host's not-delivered send carries no …
brennanb2025 9d62068
chore: restore pnpm-lock.yaml
brennanb2025 84c3bed
Merge origin/main into brennanb2025/sta-7416-delivery-by-message-id
brennanb2025 d25b69b
fix(native-chat): draw an older host's restart-doubted send as sent too
brennanb2025 a72f755
refactor(native-chat): decide a send's settlement in one classifier
brennanb2025 328fbed
fix(native-chat): settle a dispatch state this build cannot place as …
brennanb2025 0862016
fix(native-chat): keep a failure row outside a settled turn's fold
brennanb2025 2ce2803
docs(agent-status): list a crash-doubted send as a request
brennanb2025 fb06b52
docs(native-chat): name failure rows where the fold skips them; a dou…
brennanb2025 b75ef65
Merge remote-tracking branch 'origin/main' into brennanb2025/sta-7416…
brennanb2025 7a97fdb
test(native-chat): name the settlement classifier's input for the sub…
brennanb2025 4002f3c
fix(native-chat): explain a send retired in doubt with no exit or res…
brennanb2025 d6d00bf
test(native-chat): pin that the unanswered-send row stays outside a f…
brennanb2025 0a9a356
fix(native-chat): say Claude stopped when its exit is settled after t…
brennanb2025 b7c37f7
revert(native-chat): drop the "didn't respond to your last message" row
brennanb2025 1c50e6e
fix(native-chat): keep an agent running while a send it took is unans…
brennanb2025 03e44d2
fix(native-chat): keep a failure row in view only when the turn ended…
brennanb2025 c309dfc
feat(native-chat): draw a crash-doubted send as sent on released clie…
brennanb2025 71dd198
test(native-chat): assert the projected stream without a type assertion
brennanb2025 a8949ab
fix(native-chat): name the crash-doubted send capability without a ra…
brennanb2025 a0ca713
fix(native-chat): publish an older host's "not delivered" as sent to …
brennanb2025 6e7ebc5
fix(native-chat): keep only the failure a turn ended in outside its fold
brennanb2025 cd2da8e
refactor(native-chat): read the in-flight send at teardown through th…
brennanb2025 7cb874a
Merge origin/main into brennanb2025/sta-7416-delivery-by-message-id
brennanb2025 c2004eb
test(native-chat): read the Claude crash-restart journal as a current…
brennanb2025 f395e98
Merge remote-tracking branch 'origin/main' into brennanb2025/sta-7416…
brennanb2025 f71d13b
fix(i18n): drop the wait-for-setup help keys main removed, which the …
brennanb2025 e69eee9
Merge remote-tracking branch 'origin/main' into brennanb2025/sta-7416…
brennanb2025 0e4263f
fix(native-chat): give a doubted send a way to die at its turn end, a…
brennanb2025 c709f01
fix(native-chat): word a crash row by the boundary it crossed, not by…
brennanb2025 58f406f
test(native-chat): type the turn-end and crash-boundary fixtures agai…
brennanb2025 8e25362
fix(native-chat): settle a doubted send at the provider's turn-over, …
brennanb2025 3361da8
fix(native-chat): keep a failed turn-over settle from stalling the ev…
brennanb2025 76c2d5b
test(codex): leave the cast journal fake untouched; the turn-over set…
brennanb2025 814cf11
test(codex): pin that a subagent thread's turn end leaves the user's …
brennanb2025 6ea9c3d
Merge origin/main into brennanb2025/sta-7416-delivery-by-message-id
brennanb2025 726cf30
fix(native-chat): read main's two new send-state checks through the s…
brennanb2025 2586cf9
test(codex): give main's turn-grouping fold rows the failure field th…
brennanb2025 c9ecc80
test(native-chat): pin that a Stop naming no turn settles the send it…
brennanb2025 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
153 changes: 153 additions & 0 deletions
153
src/main/claude/claude-structured-dispatch-identity.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,153 @@ | ||
| // The id a restart decides delivery by: chosen before the hand-over, durable with it, and the | ||
| // exact id the frame Claude records carries. | ||
|
|
||
| import { mkdtemp, rm } from 'node:fs/promises' | ||
| import { tmpdir } from 'node:os' | ||
| import { join } from 'node:path' | ||
| import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' | ||
| import { | ||
| agentJournalItemKey, | ||
| parseAgentJournalItemKey | ||
| } from '../../shared/agent-session-journal-item-key' | ||
| import type { AgentSessionJournalIdentity } from '../../shared/agent-session-journal-types' | ||
| import { createTrackedJournalOpener } from '../native-chat/agent-session-journal/journal-store-test-open' | ||
| import type { StructuredAgentSessionAdapter } from '../native-chat/agent-session-wire/structured-agent-session-adapter' | ||
| import { handOverSubmission } from '../native-chat/agent-session-wire/structured-agent-session-turns' | ||
| import { dispatchClaudeTurn } from './claude-structured-dispatch' | ||
| import { | ||
| claudeRecordedFrameUuid, | ||
| mintClaudeDispatchIdentity | ||
| } from './claude-structured-dispatch-content' | ||
| import { sessionFor, userMessage } from './claude-structured-dispatch-test-support' | ||
| import { | ||
| acquired, | ||
| fakeClaude, | ||
| PROVIDER_SESSION_ID, | ||
| USER_MESSAGE | ||
| } from './claude-structured-session-test-support' | ||
|
|
||
| const IDENTITY: AgentSessionJournalIdentity = { | ||
| sessionId: 'session-1', | ||
| workspaceId: 'workspace-1', | ||
| hostId: 'local', | ||
| agent: 'claude', | ||
| providerHandle: { kind: 'claude', sessionId: 'provider-session', leafUuid: null } | ||
| } | ||
|
|
||
| const journals = createTrackedJournalOpener() | ||
| let root: string | ||
|
|
||
| beforeEach(async () => { | ||
| root = await mkdtemp(join(tmpdir(), 'orca-dispatch-identity-')) | ||
| }) | ||
|
|
||
| afterEach(async () => { | ||
| await journals.closeAll() | ||
| await rm(root, { recursive: true, force: true }) | ||
| }) | ||
|
|
||
| describe('the Claude dispatch identity', () => { | ||
| it('names a plain prompt by a fresh uuid in the live session', () => { | ||
| const identity = mintClaudeDispatchIdentity( | ||
| 'provider-session', | ||
| userMessage([{ type: 'text', text: 'ship it' }]) | ||
| ) | ||
| expect(identity).toMatchObject({ provider: 'claude', sessionId: 'provider-session' }) | ||
| }) | ||
|
|
||
| it('leaves a slash command to content, since Claude records no prompt for it', () => { | ||
| expect( | ||
| mintClaudeDispatchIdentity( | ||
| 'provider-session', | ||
| userMessage([{ type: 'text', text: '/compact' }]) | ||
| ) | ||
| ).toBeNull() | ||
| }) | ||
|
|
||
| it('stamps the recorded uuid on the frame, and only for the session it names', async () => { | ||
| const send = vi.fn().mockResolvedValue(undefined) | ||
| const session = sessionFor(send) | ||
| const recorded = { provider: 'claude', sessionId: 'provider-session', uuid: 'frame-1' } as const | ||
| const sentUuid = claudeRecordedFrameUuid(session.providerSessionId, recorded) | ||
|
|
||
| await dispatchClaudeTurn(session, { | ||
| body: userMessage([{ type: 'text', text: 'ship it' }]), | ||
| sentUuid | ||
| }) | ||
|
|
||
| expect(send.mock.calls[0]?.[0]).toMatchObject({ uuid: 'frame-1' }) | ||
| expect(claudeRecordedFrameUuid('another-session', recorded)).toBeUndefined() | ||
| }) | ||
| }) | ||
|
|
||
| describe('handing a send over under its identity', () => { | ||
| it('records the id before dispatch and keeps it through a crash', async () => { | ||
| const journal = await journals.open({ identity: IDENTITY, journalDir: root }) | ||
| await journal.appendSubmission({ | ||
| clientMessageId: 'cm-1', | ||
| payloadFingerprint: 'fingerprint', | ||
| body: userMessage([{ type: 'text', text: 'ship it' }]), | ||
| fence: 1, | ||
| handoverRecorded: true | ||
| }) | ||
| const identity = { provider: 'claude', sessionId: 'provider-session', uuid: 'frame-1' } as const | ||
| let recordedAtDispatch: string | undefined | ||
| const dispatch = vi.fn(async () => { | ||
| recordedAtDispatch = journal.submissions()[0]?.handedOverItemId | ||
| return { state: 'admitted' as const } | ||
| }) | ||
| const adapter: Pick<StructuredAgentSessionAdapter, 'dispatch' | 'mintDispatchIdentity'> = { | ||
| dispatch, | ||
| mintDispatchIdentity: () => identity | ||
| } | ||
|
|
||
| await handOverSubmission( | ||
| { | ||
| sessionId: 'session-1', | ||
| journal, | ||
| fence: 1, | ||
| // oxlint-disable-next-line typescript/consistent-type-assertions -- SAFETY: A hand-over calls only these two members. | ||
| adapter: adapter as StructuredAgentSessionAdapter | ||
| }, | ||
| journal.submissions()[0]! | ||
| ) | ||
|
|
||
| expect(dispatch).toHaveBeenCalledWith(expect.objectContaining({ providerIdentity: identity })) | ||
| expect(recordedAtDispatch).toBe(agentJournalItemKey(identity)) | ||
| await journal.close() | ||
| const reopened = await journals.open({ identity: IDENTITY, journalDir: root }) | ||
| await reopened.markPendingSubmissionsUnknown(2) | ||
| expect(reopened.submissions()[0]).toMatchObject({ | ||
| dispatchState: 'unknown', | ||
| handedOverItemId: agentJournalItemKey(identity) | ||
| }) | ||
| }) | ||
| }) | ||
|
|
||
| describe('the Claude adapter handing a send over', () => { | ||
| it('writes the frame under the id the journal recorded for it', async () => { | ||
| const claude = fakeClaude({ replayUuid: null }) | ||
| const adapter = await acquired(claude) | ||
| const journal = await journals.open({ identity: IDENTITY, journalDir: root }) | ||
| await journal.appendSubmission({ | ||
| clientMessageId: 'cm-1', | ||
| payloadFingerprint: 'fingerprint', | ||
| body: USER_MESSAGE, | ||
| fence: 7, | ||
| handoverRecorded: true | ||
| }) | ||
|
|
||
| await handOverSubmission( | ||
| { sessionId: 'session-1', journal, fence: 7, adapter }, | ||
| journal.submissions()[0]! | ||
| ) | ||
|
|
||
| const recorded = parseAgentJournalItemKey(journal.submissions()[0]?.handedOverItemId ?? '') | ||
| const uuid = | ||
| recorded?.provider === 'claude' && recorded.sessionId === PROVIDER_SESSION_ID | ||
| ? recorded.uuid | ||
| : null | ||
| expect(uuid).toEqual(expect.any(String)) | ||
| expect(claude.connections[0]?.sent[0]).toMatchObject({ uuid }) | ||
| }) | ||
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.