Skip to content

terminal: reset style before VT replay of blank cells - #246

Merged
lawrencecchen merged 2 commits into
mainfrom
fix-formatter-blank-cell-style
Sep 30, 2026
Merged

lawrencecchen merged 2 commits into
mainfrom
fix-formatter-blank-cell-style

Conversation

@lawrencecchen

@lawrencecchen lawrencecchen commented Sep 30, 2026 •

Copy link
Copy Markdown

The VT formatter counted unstyled blank cells and wrote them as spaces just before the next non-blank cell, but it wrote them before it switched to that cell's style. The spaces took the previous cell's colors.

Claude Code draws its mascot with ESC[48;2;0;0;0m (black background) and then jumps over three untouched cells with ESC[12G before ESC[49m. A live terminal leaves those cells empty. A cmux Cloud replay (cmux-tui vt_replay through libghostty-vt) painted them as a black box next to the mascot.

The fix closes a non-default style before writing the pending blanks, the same way the row-break path already does. Plain output is unchanged.

Commits: 2439e8e7c adds the failing test Page VT unstyled blank cells do not inherit the previous background, 51c8da0ce adds the fix.

Verification on a Blacksmith Testbox (Linux, Zig 0.16.0): zig build test-lib-vt -Dtest-filter='Page VT' fails at the test commit (AB ESC[0mC) and passes at the fix commit. Full test-lib-vt has one failure, kitty temporary file medium preserves bool ABI, which also fails at base e1b8bf5f4. cmux-tui cargo test passes except one mouse-capture test that passes when run alone.

Upstream ghostty-org/ghostty has the same code; upstreaming is a maintainer decision.

🤖 Generated with Claude Code


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.


Summary by cubic

Fixes the VT formatter writing blank cells with the previous cell's colors, which could paint a black box in replays after Claude Code's mascot output.

The formatter now closes an open non-default style before emitting accumulated blank spaces, matching the row-break path. Plain output is unchanged, and a regression test covers a styled cell followed by skipped default cells.

Written for commit 51c8da0. Summary will update on new commits.

Review in cubic

Summary by CodeRabbit

  • Bug Fixes
    • Blank spaces between styled text and subsequent content now retain their default appearance instead of inheriting the preceding text’s styling.

lawrencecchen and others added 2 commits September 30, 2026 01:15
A styled cell followed by skipped default cells replays the blanks with
the previous cell's background.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
The formatter wrote accumulated blank cells as spaces before it switched
to the next cell's style, so the spaces took the previous cell's colors.
Claude Code's mascot sets a black background and skips three cells with
CHA, which a cmux Cloud replay painted as a black box.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Sep 30, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: e6b4b17f-791a-403b-bf4c-76b044858ad7

📥 Commits

Reviewing files that changed from the base of the PR and between e30b480 and 51c8da0.

📒 Files selected for processing (1)
  • src/terminal/formatter.zig

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

PageFormatter now resets active non-default styling before emitting accumulated blank cells. A regression test checks that three unstyled spaces follow an SGR reset after text with a black background.

Changes

Blank-cell formatting

Layer / File(s) Summary
Reset style before blank cells
src/terminal/formatter.zig
PageFormatter closes an active non-default style and resets tracked style state before writing accumulated blank cells. A regression test checks that an SGR reset precedes three unstyled spaces.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Suggested reviewers: mitchellh

Merge Risk: ⚪ Minimal · up to 51c8d

The formatter now emits pending blank cells without inheriting the prior style, and the regression test checks the reset ordering. No actionable merge-blocking risk is evident.

Architecture Summary

Architecture risk: 🔵 Low · up to 51c8d

The change affects 1 system.

Changed systems: src

Architecture concerns
No architecture-level concerns identified.

Review details

Systems and components

  • observed — src (service) was modified; 1 changed file maps to changed impact.

Before / after behavior

  • observed — Modified behavior in src/terminal/formatter.zig: Before emitting accumulated blank cells, styled output now closes a non-default style and resets the style state; previously the spaces were emitted without this reset.
  • observed — Modified behavior in src/terminal/formatter.zig: Adds a regression test that formats text with a black background, skips cells, resets the background, and writes another character. It expects an SGR reset before the three unstyled spaces so they do not inherit the previous background.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: resetting terminal style before replaying blank cells in VT formatting.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 0…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant