fix(activity): prevent monitoring turns from emitting working events

Monitoring turns should surface only via the 'monitoring' snapshot in
the live state, not as separate working events that would contradict
the snapshot signal.
This commit is contained in:
Jinjing
2026-09-07 19:58:26 -07:00
parent 73321614dc
commit 4b2e3dded0
2 changed files with 7 additions and 1 deletions
@@ -171,6 +171,9 @@ describe('buildActivityEvents', () => {
expect(result.liveAgentByPaneKey[PANE_KEY].state).toBe('monitoring')
expect(threads[0].currentAgentState).toBe('monitoring')
// A monitoring turn must not emit a `working` event that contradicts the live snapshot.
expect(result.events).toHaveLength(0)
expect(threads[0].latestEvent).toBeNull()
expect(groups[0]).toMatchObject({
key: 'monitoring',
label: 'Monitoring background tasks',
@@ -97,8 +97,11 @@ export function buildPaneActivityEvents(args: PaneEventInputs): ActivityEvent[]
)
}
// Monitoring live turns surface only via the 'monitoring' snapshot, never as a working event.
const currentState =
args.liveState !== null || isHistoricalActivityState(args.entry.state) ? args.entry.state : null
args.liveState === 'working' || isHistoricalActivityState(args.entry.state)
? args.entry.state
: null
if (currentState === null || args.entry.sessionBoundary === true) {
return events
}