Skip to content

fix(tui): paint the OSC-10 default foreground on quantizing terminals - #72523

Merged
OutThisLife merged 1 commit into
mainfrom
bb/tui-resize-color
Jul 27, 2026
Merged

fix(tui): paint the OSC-10 default foreground on quantizing terminals#72523
OutThisLife merged 1 commit into
mainfrom
bb/tui-resize-color

Conversation

@OutThisLife

Copy link
Copy Markdown
Collaborator

A skin that authors a background paints both terminal defaults: OSC-11 for the backdrop, OSC-10 to re-base every default-fg token — markdown body, borders, anything rendered without an explicit color — onto the theme's text tone.

The OSC-10 half never fired on a limited-palette terminal. normalizeThemeForAnsiLightTerminal rewrites the foreground tones to ansi256(N), and setTerminalForeground only accepts #rrggbb, so the argument failed the hex test and the write was silently skipped. The background moved to the skin while default-fg text stayed on the host profile's foreground.

That split is the reported symptom. Prose renders in the terminal's own near-black while every themed token beside it renders the skin's gray, so the base text color appears to change between adjacent words — and because a resize repaints affected cells from the screen buffer, the text "goes black" on resize and the mix reads as scattered rather than uniform.

This resolves the tone through a new themeToneHex before handing it to OSC-10: ansi256(N) maps through the xterm grayscale ramp and 6×6×6 cube, an authored hex passes through, and a tone with no paintable color yields '', which correctly clears back to the terminal's own default. That keeps the existing opt-in intact — a skin without a background still releases both defaults.

Verification

On Terminal.app with the brooklyn skin, theme.color.text resolves to ansi256(238). Driving the real paint path through a fake TTY and capturing the bytes:

before:  ESC]11;#f6f9fd BEL                        <- background only
after:   ESC]11;#f6f9fd BEL  ESC]10;#444444 BEL    <- both defaults

Regression tests are invariant-shaped rather than snapshots: the palette-wide case asserts that every tone in a quantized theme resolves to a literal #rrggbb, so a newly added tone can't silently regress the paint. Reverting the source fix while keeping the tests turns them red (4 failed), which confirms they actually guard the behavior.

tsc --noEmit is clean. The full ui-tui suite has 24 pre-existing failures on origin/main (subscription overlay, syntax highlighter, backpressure, paired-palette); the failure set is byte-identical before and after this change, so it introduces none.

A skin that authors a background paints both terminal defaults: OSC-11
for the backdrop, OSC-10 to re-base every default-fg token (markdown
body, borders, anything rendered without an explicit color) onto the
theme's text tone.

The OSC-10 half never fired on a limited-palette terminal.
`normalizeThemeForAnsiLightTerminal` rewrites the foreground tones to
`ansi256(N)`, and `setTerminalForeground` only accepts `#rrggbb` — so
the argument failed the hex test and the write was silently skipped.
The background moved to the skin while default-fg text stayed on the
host profile's foreground.

That split is the reported symptom: prose renders in the terminal's own
near-black while every themed token beside it renders the skin's gray,
so the base text color appears to change between adjacent words. A
resize repaints the affected cells from the screen buffer, which is why
the text "goes black" on resize and why the mix looks scattered rather
than uniform.

Resolve the tone through a new `themeToneHex` before handing it to
OSC-10: `ansi256(N)` maps through the xterm grayscale ramp and 6x6x6
cube, an authored hex passes through, and anything with no paintable
color yields '' (which correctly clears back to the terminal default).

Verified on Terminal.app + the `brooklyn` skin: `theme.color.text` is
`ansi256(238)`, previously dropped, now emitted as
`ESC]10;#444444 BEL` alongside the existing `ESC]11;#f6f9fd BEL`.
@OutThisLife
OutThisLife force-pushed the bb/tui-resize-color branch from c71df12 to 0b1ee22 Compare July 27, 2026 06:59
@OutThisLife
OutThisLife enabled auto-merge July 27, 2026 07:00
@github-actions

github-actions Bot commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

૮ >ﻌ< ა ci review

ran on 0b1ee22

all good!

@OutThisLife
OutThisLife merged commit d7311b5 into main Jul 27, 2026
31 checks passed
@OutThisLife
OutThisLife deleted the bb/tui-resize-color branch July 27, 2026 07:07
@alt-glitch alt-glitch added type/bug Something isn't working comp/tui Terminal UI (ui-tui/ + tui_gateway/) P3 Low — cosmetic, nice to have labels Jul 27, 2026
randlee pushed a commit to randlee/hermes-agent that referenced this pull request Aug 11, 2026
…-color

fix(tui): paint the OSC-10 default foreground on quantizing terminals
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/tui Terminal UI (ui-tui/ + tui_gateway/) P3 Low — cosmetic, nice to have type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants