Skip to content

Commit 5b6ce1b

Browse files
committed
test(desktop): a call declined in a background chat is never claimed or run
The fixture Sim can now decline a held call the way Sim settles it, and the executor suite checks the device never claims it and its command never runs after the approval notification.
1 parent bdd2936 commit 5b6ce1b

2 files changed

Lines changed: 35 additions & 0 deletions

File tree

‎apps/desktop/e2e/background-executor.spec.ts‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,34 @@ test.describe('background executor', () => {
377377
})
378378
})
379379

380+
test('F: a call the user declines in a background chat never runs', async () => {
381+
const userData = mkdtempSync(join(tmpdir(), 'sim-executor-f-declined-'))
382+
const marker = join(userData, 'declined-marker.txt')
383+
app = (await launch(sim, userData)).app
384+
const deviceId = await registeredDevice(sim)
385+
const pulls = () =>
386+
sim.requests.filter((request) => request.startsWith('GET /api/desktop/inbox')).length
387+
const pullsBefore = pulls()
388+
389+
const gated = sim.issue(
390+
deviceId,
391+
CHAT_B,
392+
'terminal',
393+
{ operation: 'run', args: { command: `echo ran >> '${marker}'`, waitSeconds: 30 } },
394+
'awaiting_approval'
395+
)
396+
// The device has pulled its inbox and seen the call waiting for approval.
397+
await expect.poll(pulls).toBeGreaterThan(pullsBefore)
398+
sim.decline(gated)
399+
400+
await check('F: the declined call is never claimed, and its command never runs', async () => {
401+
await sleep(RECONCILE_MS * 2)
402+
expect(sim.requireCall(gated).claims).toBe(0)
403+
expect(sim.requireCall(gated).completions).toEqual([])
404+
expect(readFileSafe(marker)).toBe('')
405+
})
406+
})
407+
380408
test('G: only the device a turn is bound to claims its calls', async () => {
381409
const first = await launch(sim, mkdtempSync(join(tmpdir(), 'sim-executor-g1-')))
382410
const firstDevice = await registeredDevice(sim)

‎apps/desktop/e2e/executor-sim.ts‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,13 @@ export class FixtureSim {
167167
this.ring(call.deviceId, 'approval')
168168
}
169169

170+
/** The user declines a held call: Sim settles it without the device and rings again. */
171+
decline(toolCallId: string): void {
172+
const call = this.requireCall(toolCallId)
173+
call.status = 'cancelled'
174+
this.ring(call.deviceId, 'approval')
175+
}
176+
170177
requireCall(toolCallId: string): FixtureCall {
171178
const call = this.calls.get(toolCallId)
172179
if (!call) throw new Error(`No fixture call ${toolCallId}`)

0 commit comments

Comments
 (0)