TUI busy state can become stale when dispatch/turn lifecycle state diverges
Description
The TUI busy state can become stale if the frontend enters is_loading = true but the expected turn lifecycle does not progress or later becomes inconsistent.
This is related to the stale working... class of issues from #738, but it is broader than the original dispatch-failure path. It can leave the composer treating later input as pending input even when no active task is shown.
Steps to reproduce
- Start an interactive TUI session.
- Submit a prompt so the UI enters a busy/loading state.
- If dispatch or turn lifecycle state becomes inconsistent, the footer can remain
working...while later prompts are queued as pending input.
Expected behavior
The TUI should self-heal stale busy states when no active turn, agent, or compaction is running.
Actual behavior
The UI can remain in a stale busy state, causing later composer input to be queued instead of submitted normally.
Environment
- OS: Windows 11
- DeepSeek CLI version: v0.8.20
- Model: deepseek-v4-pro
- Shell: Windows Terminal / cmd / PowerShell
Proposed fix
Add a small UI-side watchdog/reconciliation layer.
Suggested narrow implementation:
- Track dispatches that have not yet observed
TurnStarted. - Clear that marker on turn start, turn completion, cancellation, engine error, or send failure.
- Reconcile stale/impossible states in the TUI event loop when no turn, agent, or compaction is active.
- Show a short recovery toast/status note.
This avoids a larger AgentHook/generator-style lifecycle refactor.
Fixed by #1170, merged as 219e15a85. Verification from the PR: Version drift, lint, Ubuntu, macOS, Windows, npm wrapper smoke, and GitGuardian all passed. The patch tracks dispatches before TurnStarted, clears the marker on normal lifecycle/cancel/error/send failure, and reconciles terminal runtime states so stale loading no longer leaves later input queued as pending.