mirror of
https://github.com/stablyai/orca.git
synced 2026-10-12 16:03:03 +00:00
* fix(native-chat): a Stop the agent took settles the message whose turn never opened When Codex takes a person's Stop on a turn it never opened, no turn-ended event follows, so the message stayed pending: the chat read Working with Stop shown, and the next turn's clock counted from that message. The Stop's settle now handles that case from its own answer: when the provider names the turn it took and that turn has no record, the sends it was for are withdrawn by the same rule a Codex child's end after a Stop already uses. The send's own row then says it was stopped before the agent started, and Working, the clock and the opening-send hold follow from it being settled. Deletes the opening-send hold's special case for a taken Stop's note, which this makes dead, and moves the Stop note key back next to its only users. * test(native-chat): a Claude Stop before the echo settles the send through the CLI's end, and the next message goes out * fix(native-chat): an interrupted Codex turn that never started records nothing, and the withdrawal reads from the handover Codex can abort a turn before it starts: it answers the interrupt, then sends turn/completed for a turn that never sent turn/started. The translator wrote an empty interrupted turn for it, so the person saw that turn beside the message's own "Stopped before the agent started" row, and when the end was read before the interrupt's answer the Stop's settle found a record and withdrew nothing. Codex records a turn's prompt only once the turn starts, so an interrupted turn this child never started, with no item or prompt read, now gets no record. Failed ends keep theirs. The withdrawal now asks whether a turn opened since the send's handover row, the same point the opening-send hold reads, rather than since its acceptance: a turn record written in between is not the send's turn. * test(native-chat): say why the item-read case pins only that the send is not taken back
44 lines
1.5 KiB
TypeScript
44 lines
1.5 KiB
TypeScript
import { describe, expect, it } from 'vitest'
|
|
import { agentJournalSubmissionKey } from './agent-session-journal-item-key'
|
|
import {
|
|
structuredAgentSessionSendOpeningTurn,
|
|
type StructuredAgentSessionOpeningSendItem
|
|
} from './structured-agent-session-opening-send'
|
|
|
|
const send = {
|
|
clientMessageId: 'send-1',
|
|
dispatchState: 'pending',
|
|
handedOverAt: 10,
|
|
fence: 1
|
|
} as const
|
|
const handover: StructuredAgentSessionOpeningSendItem = {
|
|
itemId: agentJournalSubmissionKey('send-1'),
|
|
sequence: 5,
|
|
body: { kind: 'message', role: 'user', blocks: [{ type: 'text', text: 'first' }] },
|
|
turnScope: { kind: 'thread' }
|
|
}
|
|
const turnRecord = (sequence: number): StructuredAgentSessionOpeningSendItem => ({
|
|
itemId: `turn-${sequence}`,
|
|
sequence,
|
|
body: { kind: 'turn', turnId: 'turn-1', state: 'running' }
|
|
})
|
|
|
|
function opening(items: StructuredAgentSessionOpeningSendItem[]): boolean {
|
|
return structuredAgentSessionSendOpeningTurn([send], (visit) => items.forEach(visit), 1)
|
|
}
|
|
|
|
describe('a send still opening its turn', () => {
|
|
it('holds the next message until a turn record follows its handover', () => {
|
|
expect(opening([handover])).toBe(true)
|
|
expect(opening([handover, turnRecord(6)])).toBe(false)
|
|
})
|
|
|
|
// A Stop the provider took before the turn opened withdraws the send: nothing is opening.
|
|
it('ends once the send is settled, with no turn record', () => {
|
|
const withdrawn = { ...send, dispatchState: 'rejected' } as const
|
|
expect(structuredAgentSessionSendOpeningTurn([withdrawn], (visit) => visit(handover), 1)).toBe(
|
|
false
|
|
)
|
|
})
|
|
})
|