fix(vterm): track SGR per cell so re-attach replays colors#24
Merged
Conversation
The emulator stored bare runes and discarded SGR by design, so the
replay a re-attaching client receives (Redraw) repainted the screen
black and white; the follow-up resize nudge only rescues full-screen
TUIs that fully repaint on SIGWINCH - inline agents (claude, omp) never
repaint their history, so everything stayed monochrome until new output
arrived.
Track attributes per cell and replay them:
- cell = rune + attr (16/256/truecolor fg+bg, bold/dim/italic/
underline/blink/reverse/strike), stamped from the terminal's current
SGR state
- a real SGR parser, including colon sub-parameter forms (38:5:196,
38:2::r:g:b, 4:0) and a 58 underline-color skip
- back-color-erase: erases, scroll-revealed rows, and inserted blanks
fill with the current background so colored bars replay intact;
resize keeps bg-colored blank rows the same way Redraw paints them
- Redraw repaints each cell with its original attributes (reset
prefix, per-run transitions, reset before the cursor park)
Capture/peek stays plain text by contract, and history stays plain
rowText - scrollback replays uncolored; only the visible screen carries
attributes.
|
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.



Problem
Re-attaching to a session rendered it black and white: vterm stored bare runes and discarded SGR by design, so
Redraw(the replay a new attach client receives) repainted the screen colorless. The SIGWINCH nudge only rescues full-screen TUIs; inline agents (claude, omp) never repaint their history.Fix
Per-cell SGR tracking + attribute-aware replay:
cell = rune + attr(16/256/truecolor fg+bg, bold/dim/italic/underline/blink/reverse/strike).38:5:196,38:2::r:g:b,4:0) and58underline-color skip.Redrawrepaints each cell with its original attributes; reset-prefixed transitions; reset before the cursor park.Capture/peek stays plain text by contract; history stays plain (scrollback replays uncolored — only the visible screen carries attributes).Test plan
-racegreen; adversarially reviewed (one finding — resize/Redraw blank-row inconsistency — fixed in-branch).