Repository navigation
Conversation
…nchronized output
🦋 Changeset detectedLatest commit: d5b9ae7 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
|
this is a pretty big rewrite of something we want to get rid of (see #479 ). sadly that PR is blocked because of Windows (the spinner in main has a bug on windows today which that PR fixes, but that reintroduces a different windows bug...) i think i'd rather see that land than touching this logic. let's see what @dreyfus92 thinks |
dreyfus92
left a comment
There was a problem hiding this comment.
hey @vazome, thanks for digging into this! i'm with james on not landing it as is though. i tested it and found a few things:
- when a wrapped row exactly fills the terminal, the
ESC[Kafter it can eat the row's last character (saw it in gnu screen) - it conflicts with #645, which landed today
- no windows testing yet
@43081j since #479 doesn't have a date, i tried a tiny version on main. same clear and draw as today, just written once and wrapped in synchronized output. it's about 20 lines in spinner.ts and gets us one write per frame. would you be ok landing something that small first, or still rather wait?
also the start() reset in here fixes a real bug on main, so that part is worth keeping either way.
|
really we should just get 479 finished as its been sat there for far too long. it is now blocked because of the accessible changes, though. we would need to add support for that stuff to i think we should close this and do the following:
|
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 witherase.down()(CSI J) and then wrote the new frame across 3–4 separateoutput.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 betweenerase.down()and the new frame, causing visible strobing. Batching the oldESC[1G+ESC[J+ text sequence alone still passes through a blank erased state.Fix
erase.lineEnd(CSI K) instead of callingerase.down()before drawing. Only appenderase.down()after drawing when a multi-line frame shrinks to fewer rows.output.write()per frame (both on ticks and on_stop()).\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 tospinner(), this fixes bothspinner()andprogress().Closes #613
Type of change
Checklist
pnpm testpasses (or targeted tests for my change) —spinner.test.ts,progress-bar.test.ts,spinner-accessible.test.ts(118/118),pnpm types, andpnpm run buildpasspnpm formathas been runAI-generated code disclosure