Keep redrawn progress rows in place instead of repeating them - #137
Merged
Conversation
Homebrew's parallel download queue draws N rows, deliberately leaves the last without a trailing newline, then rewinds with ESC[<n>F (cursor previous line) to draw the next frame over the top. TerminalLineAssembler handled SGR, ESC[K and the column moves but dropped everything else, so the rewind was lost. That one gap caused both reported symptoms: the block repeated every tick, and the newline-less last row spliced into the next frame's first row. The assembler now keeps a window of committed rows addressable, sized to the pty's row count because that is the screen and a terminal cannot address above it, and handles ESC[F, ESC[A and ESC[B. Inside a block a newline steps the cursor down a row rather than opening one, which is the rule the fix turns on. Movement above the window is ignored, degrading to the previous append behaviour rather than writing to a wrong row. TerminalLineEvent.revised carries a row offset that BrewCommandOutputLine and CommandJob.appendOutput route by, counted from the end so offsets stay valid after maxOutputLines trims the front. BrewCommandService builds the returned transcript from settled rows rather than every frame; trailing-newline-ness is tracked separately from completeness so output that ended without a newline does not gain one. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
MikeMcQuaid
approved these changes
Aug 30, 2026
Its only coverage was incidental: the pty tests that assert `printf 'tty'` returns exactly `tty` are what caught trailing-newline-ness being conflated with completeness, and a test about TTY detection is the wrong place for that to surface. Twelve cases over the value type itself: newline termination, settling a row the stream ended without a newline, offset-zero replacement, positive-offset rewrites leaving the target's newline alone, out-of-range offsets, and a redrawn block recording settled rows rather than every frame. Reintroducing the original defect fails five of them, including the `printf 'tty'` case. 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.
PR: Fix console progress repeating on multi-package operations
Summary
The console redrew Homebrew's parallel download block on every tick instead of updating it in place, so a multi-package operation filled the pane with duplicated rows. Reported with a screenshot showing the cask list repeated at different byte counts.
Changes
Homebrew's download queue draws N rows, leaves the last without a trailing newline, then rewinds with
ESC[<n>F(cursor previous line) to draw the next frame over the top.TerminalLineAssemblerhandled SGR,ESC[Kand the column moves but dropped everything else, so the rewind was lost. That gap caused both symptoms: the block repeated, and the last row spliced into the next frame's first row.TerminalLineAssemblerkeeps a window of committed rows addressable, sized to the pty's row count, and handlesESC[F,ESC[AandESC[B. Inside a block, a newline steps the cursor down a row rather than opening one. Movement above the window is ignored rather than writing to a wrong row.TerminalLineEvent.revisedcarries a row offset.BrewCommandOutputLineandCommandJob.appendOutputroute by it, counting back from the end so offsets stay valid aftermaxOutputLinestrims the front.BrewCommandServicebuilds the returned transcript from settled rows rather than every frame.Testing
scripts/test: 780 package tests plus 19 BrewUILint testsbrew install nodeat concurrency 8, on main and on this branchPR checklist
download_queue.rband wrote the implementation, tests and this description. Verified manually by reproducing the block on main and confirming one row per download here.Follow-ups