fix(tui): fold rare prompt glyphs in the preview so they stop rendering as boxes

A beta tester photographed claude's `❯` prompt and its `⏵⏵` bypass-permissions
marker rendering as empty boxes in the preview pane. Their font has no coverage
for those codepoints while drawing `·`, `─`, `│` and `▶` perfectly.

The glyph TIER cannot help here. It answers "can this terminal do Unicode at
all", which is a locale question, and it correctly says yes for exactly the
terminals this affects. Coverage is per-glyph and undetectable from inside the
process, so the handful of rare glyphs CLIs use as chrome are folded to the
ASCII arrows they already look like, and everything a plain font does render is
left alone.

Scoped tightly: the preview only, never the TUI's own chrome, and skipped
entirely at the `nerd` tier where the user has declared a font that can draw
anything. The table is short and every entry was seen as tofu in a real
terminal rather than guessed at. The fold is length-preserving, so the preview
pane's column arithmetic is unaffected.
This commit is contained in:
Codeman maintainer
2026-08-22 14:13:58 +02:00
parent 84f8a8a2fe
commit e7b7e90a1b
3 changed files with 74 additions and 2 deletions
+29
View File
@@ -16,6 +16,7 @@ import {
toDisplayLines,
visibleWidth,
charWidth,
foldPreviewGlyphs,
} from '../../src/tui/tui-ansi.js';
const RED = '\x1b[31m';
@@ -204,3 +205,31 @@ describe('stripStyles', () => {
expect(stripStyles('a\u{1f600}中')).toBe('a\u{1f600}中');
});
});
describe('foldPreviewGlyphs', () => {
it("turns claude's prompt and mode markers into the arrows they look like", () => {
// Exactly what a beta tester photographed as empty boxes.
expect(foldPreviewGlyphs('\u276F Try "how does report_agent.py work?"')).toBe(
'> Try "how does report_agent.py work?"'
);
expect(foldPreviewGlyphs(' \u23F5\u23F5 bypass permissions on')).toBe(' >> bypass permissions on');
});
it('leaves the glyphs that plain fonts DO render', () => {
// The same terminal drew all of these correctly, so folding them would be a
// downgrade for everyone to fix a problem nobody has.
const kept = '\u00B7 \u2500 \u2502 \u25B6 \u25CB \u2714 \u2192';
expect(foldPreviewGlyphs(kept)).toBe(kept);
});
it('leaves ordinary text and box drawing exactly alone', () => {
const line = ' 1 tui-demo-shell shell \u25CB 4m\u2502';
expect(foldPreviewGlyphs(line)).toBe(line);
expect(foldPreviewGlyphs('')).toBe('');
});
it('preserves length, so preview column arithmetic is unaffected', () => {
const line = '\u276F hello \u23F5\u23F5 world';
expect(foldPreviewGlyphs(line)).toHaveLength([...line].length);
});
});