Skip to content

fix(tui): keep busy spinner active throughout agent turn#116

Merged
tjb-tech merged 1 commit intoHKUDS:mainfrom
yl-jiang:fix/tui-busy-indicator
Apr 11, 2026
Merged

fix(tui): keep busy spinner active throughout agent turn#116
tjb-tech merged 1 commit intoHKUDS:mainfrom
yl-jiang:fix/tui-busy-indicator

Conversation

@yl-jiang
Copy link
Copy Markdown
Contributor

Fixes #115

Problem

The React TUI spinner disappears prematurely during multi-tool agent turns because:

  • assistant_complete incorrectly called setBusy(false), but tool calls may follow this event in the same turn.
  • tool_started never called setBusy(true), so the spinner would stay hidden if busy was already false.

Change

  • Remove setBusy(false) from assistant_complete handler — line_complete is the only true end-of-turn signal.
  • Add setBusy(true) to tool_started handler so the spinner re-activates for each tool call.
  • Show 'Processing...' label on tool_completed instead of clearing the label immediately.
  • Clarify inline comments to document the intended event-flow contract.

Verification

  1. cd frontend/terminal && npx tsc --noEmit — passes with no errors.
  2. Run oh and ask a question that triggers multiple tool calls; the spinner stays visible continuously until the full response is rendered.

- 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>
Copilot AI review requested due to automatic review settings April 11, 2026 10:58
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 busy on assistant_complete; only clear it on line_complete.
  • Ensure tool_started explicitly sets busy=true, and keep a “Processing...” label after tool_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).
Copy link

Copilot AI Apr 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
// 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.

Copilot uses AI. Check for mistakes.
@tjb-tech tjb-tech merged commit 78b1d64 into HKUDS:main Apr 11, 2026
7 of 8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(tui): busy spinner disappears prematurely during multi-tool agent turns

3 participants