Files
orca/src/main/runtime/structured-chat-worker-start-unknown.test.ts
T
Brennan Benson 6059a5f7fa Native chat: a message is never marked not delivered after a crash, and reopening a chat stops reading the transcript (#30580)
* Native chat: never mark a message not delivered after a crash; reopening a chat stops reading the transcript

After a crash or restart, attach read a window of the agent's saved log and marked any
unconfirmed message missing from it as rejected "not delivered". Absence from a log Orca
does not own is not proof: the window's anchor moves every turn (STA-7416) and its text
filters drop tagged prompts (STA-7453), so messages the agent received were marked
undelivered and retyping them duplicated the question. The read also ran on every attach
(STA-7434).

Delete the inference: the provider history window and its adapter hooks (Claude window and
branch proof, OpenCode stored-messages reader), the submission matcher, and the attach step.
A send the crash boundary leaves unconfirmed stays an ordinary sent message; the interrupted
turn still ends through the existing settlement. Explicit live refusals are unchanged.

A queued card whose hand-off a restart left unconfirmed no longer counts as able to return
to the queue, so it stops keeping an idle chat loaded.

* test(native-chat): update restart fixture calls after history removal

* Hide rewind targets without a saved native boundary

* Run rewind boundary regression across host and renderer

* Keep incoming main package-manager lock unchanged

* Test recovered chat consumer outcomes without delivery inference

* Assign the complete cursor in recovered phone regression fixture

* Supply presentation capture in rewind boundary fixture
2026-10-24 00:27:01 -07:00

77 lines
2.9 KiB
TypeScript

import './rpc/unused-default-rpc-methods.test-fixture'
import { expect, it, vi } from 'vitest'
import * as sessionCreate from './rpc/methods/structured-agent-session-create'
import { attachParams, providerFaults } from './structured-chat-coordinator-fake-codex-fixture'
import {
COORDINATOR,
call,
codex,
coordinatorRunAndTask,
db,
host,
openChat,
runtime
} from './structured-chat-coordinator-mail-rig.test-fixture'
it('keeps a minted worker start unknown after one preamble handover without an echo', async () => {
await openChat(COORDINATOR)
const { taskId } = await coordinatorRunAndTask()
vi.spyOn(runtime, 'validateOrchestrationAgentLauncher').mockImplementation(() => {})
vi.spyOn(runtime, 'getStructuredAgentSessionCreateSupport').mockResolvedValue({ supported: true })
// oxlint-disable-next-line typescript/consistent-type-assertions -- SAFETY: placement reads only the workspace identity in this rig.
vi.spyOn(runtime, 'showManagedTerminalWorkspace').mockResolvedValue({
id: 'workspace-1',
repoId: 'repo'
} as never)
// oxlint-disable-next-line typescript/consistent-type-assertions -- SAFETY: launch-mode selection reads only getSettings on this store double.
vi.spyOn(runtime, 'requireStore').mockReturnValue({
getSettings: () => ({
experimentalNativeChat: true,
agentCmdOverrides: {},
agentDefaultArgs: {},
agentDefaultEnv: {}
})
} as never)
vi.spyOn(sessionCreate, 'createStructuredAgentSessionForWorktree').mockImplementation(
async (args) => {
const attached = await host.attach(args.caller, attachParams(args.envelope.sessionId))
if (!attached.ok) {
throw new Error('scripted worker attach refused')
}
return {
...attached,
value: { ...attached.value, sessionId: args.envelope.sessionId, fence: attached.fence }
}
}
)
providerFaults.dieBeforeEveryEcho = true
const receipt = await call(
'orchestration.workerStart',
{
task: taskId,
agent: 'codex',
worktree: 'current'
},
{ sessionId: COORDINATOR }
)
expect(receipt).toMatchObject({
state: 'outcome_unknown',
lastError: expect.stringMatching(/not acknowledged/)
})
expect(JSON.stringify(receipt.nextCommands)).toContain('worker-show')
expect(JSON.stringify(receipt.nextCommands)).toContain('worker-abandon')
const dispatchId = String(receipt.dispatchId)
expect(db.getWorkerDispatch(dispatchId)?.state).toBe('start_unknown')
const worker = codex.connections.at(-1)!
const sessionId = db.getDispatchContextById(dispatchId)?.assignee_orca_session_id
if (!sessionId) {
throw new Error('minted worker session missing')
}
const snapshot = await host.journalSnapshot(sessionId)
expect(snapshot.submissions).toHaveLength(1)
expect(snapshot.submissions[0]).toMatchObject({ dispatchState: 'unknown' })
expect(worker.turns).toHaveLength(1)
expect(providerFaults.turnStarts).toBe(1)
})