Skip to content

fix(cli): reduce spinner flickering under patch_stdout#91

Merged
teknium1 merged 1 commit intoNousResearch:mainfrom
0xbyt4:fix/cli-spinner-flickering
Feb 27, 2026
Merged

fix(cli): reduce spinner flickering under patch_stdout#91
teknium1 merged 1 commit intoNousResearch:mainfrom
0xbyt4:fix/cli-spinner-flickering

Conversation

@0xbyt4
Copy link
Copy Markdown
Contributor

@0xbyt4 0xbyt4 commented Feb 26, 2026

Summary

  • KawaiiSpinner._animate() used a two-phase approach to update spinner frames: first \r + spaces to blank the line, then \r + new content (agent/display.py:185)
  • Under prompt_toolkit's patch_stdout proxy, each write can trigger a separate UI repaint, so the blank-then-redraw cycle causes visible flickering every 120ms
  • Spinners run during every API call and every tool execution, so the flickering is constant while the agent is working
  • Replace with \r\033[K (carriage return + ANSI erase-to-end-of-line) in a single write so the clear and redraw happen atomically

Reproduction

  1. Start the CLI and send any message that triggers tool calls
  2. Before fix: Spinner line visibly flickers/blinks during tool execution and API calls
  3. After fix: Spinner animates smoothly without blank-frame flashes
KawaiiSpinner used a two-phase clear+redraw approach: first write
\r + spaces to blank the line, then \r + new frame. When running
inside prompt_toolkit's patch_stdout proxy, each phase could trigger
a separate repaint, causing visible flickering every 120ms.

Replace with a single \r\033[K (carriage return + ANSI erase-to-EOL)
write so the line is cleared and redrawn atomically.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants