Skip to content

fix(prompts): eliminate spinner flicker via in-place overwrite and synchronized output - #646

Open
vazome wants to merge 1 commit into
bombshell-dev:mainfrom
vazome:fix/spinner-flicker
Open

vazome wants to merge 1 commit into
bombshell-dev:mainfrom
vazome:fix/spinner-flicker

Conversation

@vazome

@vazome vazome commented Nov 22, 2026

Copy link
Copy Markdown

What does this PR do?

Eliminates visible spinner and progress bar flickering on low-latency GPU terminals (reproduced on macOS Ghostty as well as Linux Ptyxis/VTE in #613).

Root cause

On every 80ms tick, spinner() previously cleared the entire region with erase.down() (CSI J) and then wrote the new frame across 3–4 separate output.write() calls (cursor.up, cursor.to(0), erase.down(), then the frame). Terminals that paint promptly on PTY reads (like Ghostty and Ptyxis) render the intermediate blank state between erase.down() and the new frame, causing visible strobing. Batching the old ESC[1G + ESC[J + text sequence alone still passes through a blank erased state.

Fix

  • Overwrite in place before clearing: Write each rendered line followed by erase.lineEnd (CSI K) instead of calling erase.down() before drawing. Only append erase.down() after drawing when a multi-line frame shrinks to fewer rows.
  • Single output.write() per frame (both on ticks and on _stop()).
  • DEC Mode 2026 synchronized output (\x1b[?2026h … \x1b[?2026l) around interactive frame writes (skipped in CI mode). Supported natively by Ghostty, VTE/Ptyxis, Kitty, WezTerm, iTerm2, Alacritty, and xterm.js 6+; ignored by terminals that do not implement private mode 2026.

Because progress() delegates to spinner(), this fixes both spinner() and progress().

Closes #613

Type of change

  • Bug fix
  • Feature
  • Refactor (no behavior change)
  • Documentation
  • Performance improvement
  • Tests
  • Chore (dependencies, CI, tooling)

Checklist

  • pnpm test passes (or targeted tests for my change) — spinner.test.ts, progress-bar.test.ts, spinner-accessible.test.ts (118/118), pnpm types, and pnpm run build pass
  • pnpm format has been run
  • I have added/updated tests for my changes (if applicable)
  • I have added a changeset

AI-generated code disclosure

  • This PR includes AI-generated code

@changeset-bot

changeset-bot Bot commented Nov 22, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: d5b9ae7

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@clack/prompts Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vazome
vazome marked this pull request as ready for review November 22, 2026 16:20
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.

[Bug] Progress bar visibly flickers in Ptyxis 50.1 but not in Zed terminal

1 participant