Add ANSI.replay to collapse captured repaints - #625
Open
GoodForOneFare wants to merge 3 commits into
Open
Conversation
Generate Unicode 17 wide-character ranges from pinned Unicode data and keep the width helper internal so existing layout APIs retain their current behavior. Assisted-By: devx/b840c1e6-d979-473d-9216-a53477380bf1
Apply viewport-independent terminal controls to a line grid so captured spinner and progress-bar repaints collapse to their final output. Parse streams with a VT-style state machine, discard presentation and alternate-screen content, and use the internal Unicode terminal-width helper for correct wide-glyph cursor placement without changing existing layout APIs. Co-authored-by: River <river@shopify.com> Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Assisted-By: devx/b840c1e6-d979-473d-9216-a53477380bf1
This was referenced Aug 13, 2026
GoodForOneFare
force-pushed
the
gordo-ansi-replay
branch
4 times, most recently
from
August 13, 2026 13:21
50531dc to
fe7fb3f
Compare
Assisted-By: devx/b840c1e6-d979-473d-9216-a53477380bf1
GoodForOneFare
force-pushed
the
gordo-ansi-replay
branch
from
August 13, 2026 14:00
fe7fb3f to
f230d66
Compare
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
Add
ANSI.replay, which turns a captured terminal stream into the text left after cursor-driven repaints settle.Spinners and progress bars repeatedly redraw the same screen area. A log capture stores every frame, and
ANSI.strip_codesonly removes escape sequences; it does not apply cursor movement or erasure. Replay applies the viewport-independent controls instead, so those frames collapse to the final output a developer saw.For example, Shopify's dev CLI attaches
dev upoutput to error reports. A representative 450 KB capture replays to 41 KB of useful text.What replay models
Presentation sequences and control-string payloads are consumed without producing text. Operations that require a viewport, such as absolute screen positioning and display erasure, are ignored because a capture does not record scrolling and therefore cannot map screen coordinates back to buffer rows.
The stream parser follows the VT500 state-machine shape, including malformed, aborted, embedded-control, and cut-off sequences. Resource limits apply only to rows and columns conjured by control sequences; ordinary captured output remains unbounded.
Scope boundary
This PR deliberately leaves the existing
ANSI.strip_codes,ANSI.printing_width, Truncater, and Wrap behavior unchanged. Replay needs terminal-accurate column widths, so it includes a private Unicode 17 width helper and generated data, but existing layout APIs do not adopt it here.Follow-up #624 aligns stripping, measurement, truncation, and wrapping on top of this PR. Replay and stripping still have different semantics: replay interprets cursor controls, while stripping only removes recognized sequences.
Limitations
The
[1234]pids that are inserted into stream sometimes break ordering, so they may pick up extra characters (e.g.,[12✅4]). This is acceptable, as the replayed logs are just for streamlined troubleshooting context.