test(agent-session): let delivery park before the attention case's idle sweep

The single idle-sweep tick keeps a chat whose delivery loop is still
running, and the loop parks only after SQL reads that follow the second
send's completion event. When the tick ran first it touched the session
instead of retiring it, and the 1 s hasSession poll failed. Wait for the
loop to park (wake resolves when it does), as goal-steering does.

With an 8 ms SQL reply delay injected locally plus CPU load: old 2/5
failed (expected true to be false), new 5/5 passed.
This commit is contained in:
Brennan Benson
2026-11-13 02:02:28 -08:00
parent 98911ff1f6
commit a88b5a6dee
@@ -206,6 +206,8 @@ it('acknowledges a post-rewind completion after normal idle retirement without r
...origin,
scope: { ...origin.scope, workspaceId: 'another-workspace' }
})
// The idle sweep keeps a chat whose delivery loop has not parked after the second send.
await rig.host.collaboratorsForTests().conversationDelivery.loop.wake(SESSION)
rig.clock.now += IDLE_MS + 1
await sweepOnce(rig.host)
await vi.waitFor(() => expect(rig.host.hasSession(SESSION)).toBe(false))