Node-based terminal manager for AI coding agents — tmux-backed terminals and parallel agent sessions as draggable nodes on an infinite pan/zoom canvas. macOS, Linux, and a browser Server Edition.
TypeScript adhdagent-orchestrationai-agentscanvasclaude-codecodexcoding-agentsdeveloper-toolselectrongeminilinuxmacosmultiplexeropencodeparallel-agentsterminalterminal-emulatorterminal-multiplexertmuxworkspace-manager
fix(glyphgrid): render the BASE character of a combining sequence, not the bare mark
enes82205112e977
diff --git a/src/renderer/glyphgrid/feed.test.ts b/src/renderer/glyphgrid/feed.test.tsindex c8ce55d03..55f5fea4c 100644--- a/src/renderer/glyphgrid/feed.test.ts+++ b/src/renderer/glyphgrid/feed.test.ts@@ -31,6 +31,8 @@ type Attr = 'default' | ['palette', number] | ['rgb', number]function makeCell(o: {+ /** Defaults to '' so the existing tests keep exercising the getCode() fallback path. */+ chars?: stringcode?: numberwidth?: numberbold?: boolean@@ -47,6 +49,7 @@ function makeCell(const is = (a: Attr, mode: string): boolean => (a === 'default' ? mode === 'default' : a[0] === mode)const val = (a: Attr): number => (a === 'default' ? 0 : a[1])return {+ getChars: () => o.chars ?? '',getCode: () => o.code ?? 0x41,getWidth: () => o.width ?? 1,isBold: () => (o.bold ? 1 : 0),@@ -224,6 +227,48 @@ describe('packViewportRow — code point validation', () => {})})+describe('packViewportRow — glyph code derivation from getChars()', () => {+ it('a precomposed char renders its own code point', () => {+ const { out, atlas } = pack([makeCell({ chars: 'é', code: 0x00e9 })]) // 'é', precomposed+ expect(atlas.calls).toEqual([[0x00e9, false, false]])+ expect(readCell(out, 0).glyph).toBe(901)+ })++ it('a DECOMPOSED combining sequence renders its BASE character, not the bare mark', () => {+ // xterm keeps the whole sequence in the cell string and getCode() reports its LAST code+ // point — here U+0301, the naked accent. Rendering that would drop the 'e' off the screen.+ const { out, atlas } = pack([makeCell({ chars: 'é', code: 0x0301 })])+ expect(atlas.calls).toEqual([[0x65, false, false]]) // 'e', asked for exactly once+ expect(readCell(out, 0).glyph).toBe(901)+ })++ it('an astral char (surrogate pair) resolves to its full code point, not the lead surrogate', () => {+ const { out, atlas } = pack([makeCell({ chars: '\u{1f44d}' })]) // 👍+ expect(atlas.calls).toEqual([[0x1f44d, false, false]])+ expect(readCell(out, 0).glyph).toBe(901)+ })++ it('an empty chars string falls back to getCode()', () => {+ const { out, atlas } = pack([makeCell({ chars: '', code: 0x5a })])+ expect(atlas.calls).toEqual([[0x5a, false, false]])+ expect(readCell(out, 0).glyph).toBe(901)+ })++ it('a chars string starting with a LONE SURROGATE is blank and never reaches the atlas', () => {+ // A string can carry a broken surrogate just as easily as getCode() can return one; the+ // rasterizer's String.fromCodePoint must see neither.+ const { out, atlas } = pack([makeCell({ chars: '\ud800', code: 0x41 })])+ expect(readCell(out, 0).glyph).toBe(0)+ expect(atlas.calls).toEqual([])+ })++ it('a chars string of a control char is blank and never reaches the atlas', () => {+ const { out, atlas } = pack([makeCell({ chars: '\u0007', code: 0x41 })])+ expect(readCell(out, 0).glyph).toBe(0)+ expect(atlas.calls).toEqual([])+ })+})+describe('packViewportRow — cursor and selection', () => {it('the cursor cell paints cursorBg/cursorFg and sets FLAG_CURSOR', () => {const { out } = pack([makeCell(), makeCell({ fg: ['palette', 3] })], { cursorCol: 1 })diff --git a/src/renderer/glyphgrid/feed.ts b/src/renderer/glyphgrid/feed.tsindex 28a664606..5bb639b36 100644--- a/src/renderer/glyphgrid/feed.ts+++ b/src/renderer/glyphgrid/feed.ts@@ -20,6 +20,10 @@ import {/** Narrow view of one buffer cell — the subset of xterm's IBufferCell the feed reads. The shell* passes real cells; tests pass literals. */export interface CellView {+ /** The cell's full string. A combining sequence lives HERE as one string ("e" + U+0301) —+ * which is exactly what `getCode()` cannot express, since it reports only the LAST code point+ * of a combined string. See `glyphCode`. */+ getChars(): stringgetCode(): numbergetWidth(): numberisBold(): number@@ -80,6 +84,25 @@ function isRenderableCode(code: number): boolean {)}+/** Which code point this cell should draw.+ *+ * `getCode()` alone is WRONG for a combining sequence: xterm stores the whole sequence in the+ * cell's string and `getCode()` returns its LAST code point, so "e" + U+0301 would rasterize as+ * the bare accent — the base letter would vanish off the screen. Taking the string's FIRST code+ * point instead draws the base character.+ *+ * TRADEOFF, stated plainly: this renders "é" (decomposed) as "e", dropping the mark. That is the+ * correct v1 degradation — readable, and never a phantom glyph — but it is a degradation.+ * Rendering the full grapheme needs the atlas keyed by STRING rather than by code point (so the+ * rasterizer can draw the whole cluster into one slot), which is Phase 2 atlas work.+ *+ * `getCode()` remains the fallback for an empty string: a cell can report no chars (a fresh or+ * reset cell), and its code is then the only thing there is to go on. */+function glyphCode(cell: CellView): number {+ const chars = cell.getChars()+ return chars.length > 0 ? (chars.codePointAt(0) as number) : cell.getCode()+}+/** 0xRRGGBB (xterm's RGB encoding) → an opaque packed lane. */function rgbLane(v: number): number {return packColor((v >>> 16) & 0xff, (v >>> 8) & 0xff, v & 0xff, 0xff)@@ -188,7 +211,9 @@ export function packViewportRow(} else {const bold = cell.isBold() !== 0const italic = cell.isItalic() !== 0- const code = cell.getCode()+ // The guard runs on the DERIVED code: a string can start with a lone surrogate just as+ // easily as getCode() can return one, and the rasterizer must never see either.+ const code = glyphCode(cell)if (isRenderableCode(code)) glyph = atlas.glyphFor(code, bold, italic)if (bold) flags |= FLAG_BOLDif (italic) flags |= FLAG_ITALIC