fix(cli): render the progress spinner ourselves so a terminal resize cannot leave rows behind - #11
Merged
Merged
Conversation
…cannot leave rows behind clack's spinner reads the terminal width once at creation and sizes its erase from the bare message, so shrinking the window mid-run made every frame wrap and leave a stale row; the truncation added in f4f7ea8 only helped until the next resize. rowSpinner re-fits the message to the live width on every frame and erases with \r + clear-line, so the row can never wrap in the first place. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Contributor
🐛 Gribble (apps/website): gate passedThe gribbles went hungry. Ship it.
Gribble 0.3.0 · mode gate · http://localhost:4173 ✅ Step passed: No new findings at or above error. (fail-on: error) |
picocolors enables color when CI is set, so on GitHub the glyph is wrapped in escape codes and the literal match failed. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Follow-up to #7. Resizing the terminal during a review made every spinner tick print a new row, not just the intermittent ones #7 fixed.
Cause: clack's spinner captures the terminal width once when it is created and computes how many rows to erase from the bare message. After a shrink, the row it already printed wraps, and its
\r+ erase only clears the last of those rows; thefitSpinnerMessagetruncation from #7 only re-applied on the nextmessage()call (the next budget/tool event), so between events every frame left a row behind. Upstream has no fix planned short of the stalled rework (bombshell-dev/clack#479), so this stops depending on their spinner for the live row.rowSpinnerinprompts.tsreplacesclack.spinnerinsideclackPrompter:◇ done/▲ failedend lines, hidden cursor while spinning);stdout.columnson every frame, so the row never exceedscolumns - 1and erasing it is\r+ clear-line — no cursor-up arithmetic to get wrong;stop/error/clearand onprocess.exit(second Ctrl+C).The
TODO(clack)workaround note from #7 is gone with it;fitSpinnerMessagestays as the sizing helper.Verification
test/spinner.test.tsdrives it with fake timers, including a 120 → 55 column resize mid-run: every frame after the shrink is ≤ 54 columns and none contains a newline.TIOCSWINSZ+SIGWINCH(120 → 55) 1.3 s in: 32 frames, widest after the shrink 54 columns, no newlines inside frames, ends with◇ done.pnpm lint,pnpm --filter gribble typecheck, CLI test suite (52 tests) pass.Checklist
pnpm lint && pnpm typecheck && pnpm testpasspnpm changeset) if a published package changeddocs/) if behavior changed — n/a🤖 Generated with Claude Code