test(orchestration): cover deferred pointer recovery after prolonged unknown status

This commit is contained in:
Jinwoo-H
2026-09-07 04:05:19 -04:00
parent 933796fd0c
commit 505c51f3e4
@@ -6,6 +6,7 @@ import {
type AgentStatusIpcPayload
} from '../../shared/agent-status-types'
import { settledWriteStub } from '../providers/settled-pty-write-stub'
import { MAILBOX_POINTER_WRITE_ATTEMPTED } from './orchestration/db/messages/mailbox-pointer-enter-state'
import {
createBoundRun,
createDatabase,
@@ -151,6 +152,34 @@ describe('Codex completion title mailbox delivery', () => {
db.close()
})
it('keeps an unverified staged pointer pending and submits it once readiness returns', async () => {
vi.useFakeTimers()
const { db, runtime, write, run, getForegroundProcess, completeWithNativeTitles } =
completionFixture()
getForegroundProcess.mockResolvedValue(null)
await runtime.listTerminals()
const message = insertDirectRunMessage(db, run.id, 'Worker progress')
completeWithNativeTitles()
await vi.advanceTimersByTimeAsync(10 * 60_000)
expect(write.mock.calls.map(([, data]) => data)).toEqual([
expect.stringContaining('You have 1 orchestration message')
])
expect(db.getMessageById(message.id)).toMatchObject({
read: 0,
delivered_at: null,
pointer_enter_pending: MAILBOX_POINTER_WRITE_ATTEMPTED
})
runtime.ingestSyntheticTitleFrame(PTY_ID, '\x1b]0;Codex ready\x07')
await vi.advanceTimersByTimeAsync(1000)
expect(write.mock.calls.map(([, data]) => data)).toEqual([
expect.stringContaining('You have 1 orchestration message'),
'\r'
])
expect(db.getMessageById(message.id)).toMatchObject({ pointer_enter_pending: 0 })
db.close()
})
it('rechecks a repeated neutral title before resuming the staged Enter', async () => {
vi.useFakeTimers()
const { db, runtime, write, run, completeWithNativeTitles } = completionFixture(750)