Skip to content

Spinner vanishes briefly during premature idle recovery cycles #395

@PureWeen

Description

@PureWeen

Problem

During long-running multi-agent worker sessions, the SDK sends premature session.idle events mid-turn (before the worker is actually done). The premature idle recovery correctly detects this via events.jsonl freshness and re-arms, but there's a visible UI gap:

  1. session.idleCompleteResponse fires → IsProcessing = falsespinner vanishes
  2. Recovery code checks events.jsonl → logs "still processing after round N" → waits
  3. ~30-60s later, SDK sends TurnStartEventEVT-REARM fires → IsProcessing = truespinner reappears

The gap between steps 1 and 3 makes it look like nothing is happening, confusing users.

Proposed Fix

When DISPATCH-RECOVER detects the worker is still active (events.jsonl fresh), immediately re-arm IsProcessing = true on the UI thread instead of waiting for the next TurnStartEvent. This keeps the spinner on during the gap.

Key location: CopilotService.Organization.cs — the premature idle recovery loop in WaitForSessionIdleAsync / ExecuteWorkerAsync.

Diagnostics Example

19:48:01 [COMPLETE] 'worker-4' CompleteResponse executing (flushedLen=38921)
19:48:01 [DISPATCH-RECOVER] Worker 'worker-4' premature idle detected — waiting...
19:48:37 [DISPATCH-RECOVER] Worker 'worker-4' still processing after round 18 (re-armed again)
19:49:41 [EVT-REARM] 'worker-4' TurnStartEvent arrived after premature session.idle — re-arming

The ~100s gap between COMPLETE and EVT-REARM is when the spinner is invisible.

Safety Notes

Must follow INV-1 (complete state cleanup checklist) when re-arming. The re-arm should set IsProcessing = true and restart the watchdog, matching the existing EVT-REARM pattern in CopilotService.Events.cs.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions