fix(agent-status): suppress stamped turn replays

This commit is contained in:
Brennan Benson
2026-08-14 13:26:42 -07:00
parent 7f8994fc37
commit f3f1b9ccd1
2 changed files with 15 additions and 2 deletions
@@ -1277,7 +1277,7 @@ describe('agent completion coordinator', () => {
)
})
it('pairs a background all-clear with the turn it announced even after a working title blip', () => {
it('does not replay a stamped turn or its all-clear after a working title blip', () => {
const dispatchCompletion = vi.fn()
const dispatchHookLifecycle = vi.fn()
const coordinator = createAgentCompletionCoordinator({
@@ -1308,6 +1308,15 @@ describe('agent completion coordinator', () => {
vi.advanceTimersByTime(2_000)
coordinator.observeTitleWorking()
coordinator.observeHookStatus({
state: 'working',
prompt: 'review the PR',
agentType: 'claude',
stateStartedAt: 1_700_000_000_000,
turnCompletedAt: 1_700_000_005_000
})
expect(dispatchCompletion).toHaveBeenCalledTimes(1)
coordinator.observeHookStatus({
state: 'done',
prompt: 'review the PR',
@@ -832,7 +832,11 @@ export function createAgentCompletionCoordinator(
: undefined
if (turnCompletedAt !== undefined) {
// Why: Claude's lead Stop already ended the turn; the pane stays `working` only for background inventory. Announce now, keep lifecycle on the reported working row.
if (workingStatusObserved) {
if (
workingStatusObserved &&
!turnCompletedAtAlreadyNotified(turnCompletedAt) &&
lastCompletionIdentity?.lastTurnCompletedAtNotified !== turnCompletedAt
) {
const completionSnapshot: AgentCompletionStatusSnapshot = {
...payload,
state: 'done',