fix(tui): keep busy spinner active throughout agent turn#116
fix(tui): keep busy spinner active throughout agent turn#116tjb-tech merged 1 commit intoHKUDS:mainfrom
Conversation
- Remove premature setBusy(false) from assistant_complete handler; busy state should only clear at true end-of-turn (line_complete). - Add setBusy(true) to tool_started handler so the spinner activates even when tool calls come immediately after an assistant message. - Show 'Processing...' label on tool_completed instead of clearing label. - Improve inline comments to clarify the intended event flow. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR fixes the React terminal UI “busy” spinner so it stays active for the full duration of a multi-step agent turn (including tool calls that occur after an assistant_complete event), aligning the UI with the backend event flow where line_complete signals the true end of a turn.
Changes:
- Stop clearing
busyonassistant_complete; only clear it online_complete. - Ensure
tool_startedexplicitly setsbusy=true, and keep a “Processing...” label aftertool_completed. - Document the intended event-flow contract and record the fix in the changelog.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| frontend/terminal/src/hooks/useBackendSession.ts | Updates event handling so the spinner/label stays active across assistant + tool phases until line_complete. |
| CHANGELOG.md | Adds an Unreleased “Fixed” entry describing the spinner behavior correction. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| clearAssistantDelta(); | ||
| setBusy(false); | ||
| // Do NOT reset busy here: tool calls may follow this event. | ||
| // busy is reset by line_complete (the true end-of-turn signal). |
There was a problem hiding this comment.
The new inline comment says busy is reset by line_complete (the “true end-of-turn signal”), but error events also call setBusy(false) earlier in this handler. Consider tweaking the wording to reflect that line_complete is the normal end-of-turn signal, with error/shutdown as exceptional early-termination paths, to avoid misleading future readers.
| // busy is reset by line_complete (the true end-of-turn signal). | |
| // line_complete is the normal end-of-turn signal; error/shutdown paths may clear busy earlier. |
Fixes #115
Problem
The React TUI spinner disappears prematurely during multi-tool agent turns because:
assistant_completeincorrectly calledsetBusy(false), but tool calls may follow this event in the same turn.tool_startednever calledsetBusy(true), so the spinner would stay hidden ifbusywas alreadyfalse.Change
setBusy(false)fromassistant_completehandler —line_completeis the only true end-of-turn signal.setBusy(true)totool_startedhandler so the spinner re-activates for each tool call.'Processing...'label ontool_completedinstead of clearing the label immediately.Verification
cd frontend/terminal && npx tsc --noEmit— passes with no errors.ohand ask a question that triggers multiple tool calls; the spinner stays visible continuously until the full response is rendered.