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
feat(glyphgrid): render strikethrough (SGR 9) in the Shared GPU renderer
Paul Robertson828913a896c2
diff --git a/src/renderer/glyphgrid/addon-fakes.ts b/src/renderer/glyphgrid/addon-fakes.tsindex 92dfc6be9..6ab84d9ef 100644--- a/src/renderer/glyphgrid/addon-fakes.ts+++ b/src/renderer/glyphgrid/addon-fakes.ts@@ -41,6 +41,7 @@ export function rowCodedCell(absRow: number, col: number): CellView {isBold: () => 0,isItalic: () => 0,isUnderline: () => 0,+ isStrikethrough: () => 0,isInverse: () => 0,isDim: () => 0,isFgDefault: () => true,diff --git a/src/renderer/glyphgrid/atlas.test.ts b/src/renderer/glyphgrid/atlas.test.tsindex 3265698fe..227636885 100644--- a/src/renderer/glyphgrid/atlas.test.ts+++ b/src/renderer/glyphgrid/atlas.test.ts@@ -53,6 +53,20 @@ describe('GlyphAtlas', () => {expect(r.calls).toHaveLength(1)})+ it('a struck glyph is its own slot, and a struck space is drawn rather than left blank', () => {+ const r = fakeRasterizer()+ const atlas = new GlyphAtlas(r, 100)++ const plain = atlas.glyphFor(0x41, false, false, FG, BG)+ const struck = atlas.glyphFor(0x41, false, false, FG, BG, 'whole', false, true)+ const underlined = atlas.glyphFor(0x41, false, false, FG, BG, 'whole', true, false)+ const struckSpace = atlas.glyphFor(0x20, false, false, FG, BG, 'whole', false, true)++ expect(new Set([plain, struck, underlined]).size).toBe(3)+ expect(struckSpace).not.toBe(0)+ expect(r.calls).toHaveLength(4)+ })+it('same key is cached (one rasterization, stable slot); styles are distinct keys', () => {const r = fakeRasterizer()const atlas = new GlyphAtlas(r, 100)@@ -545,13 +559,22 @@ describe('GlyphAtlas', () => {atlas.glyphFor(0x20, false, false, FG, BG) // the blank slot is never an allocationatlas.glyphFor(0x78, false, false, FG, BG, 'wide-right') // …and so is the other halfexpect(seen).toEqual([- { slot: 1, code: 0x78, bold: false, italic: false, x: 16, y: 2, fg: FG, bg: BG, part: 'whole' as const, underline: false },- { slot: 2, code: 0x78, bold: true, italic: false, x: 30, y: 2, fg: FG, bg: BG, part: 'whole' as const, underline: false },- { slot: 3, code: 0x78, bold: false, italic: false, x: 44, y: 2, fg: FG + 1, bg: BG, part: 'whole' as const, underline: false },- { slot: 4, code: 0x78, bold: false, italic: false, x: 58, y: 2, fg: FG, bg: BG, part: 'wide-right' as const, underline: false }+ { slot: 1, code: 0x78, bold: false, italic: false, x: 16, y: 2, fg: FG, bg: BG, part: 'whole' as const, underline: false, strikethrough: false },+ { slot: 2, code: 0x78, bold: true, italic: false, x: 30, y: 2, fg: FG, bg: BG, part: 'whole' as const, underline: false, strikethrough: false },+ { slot: 3, code: 0x78, bold: false, italic: false, x: 44, y: 2, fg: FG + 1, bg: BG, part: 'whole' as const, underline: false, strikethrough: false },+ { slot: 4, code: 0x78, bold: false, italic: false, x: 58, y: 2, fg: FG, bg: BG, part: 'wide-right' as const, underline: false, strikethrough: false }])})+ it('reports a struck slot as struck', () => {+ const seen: GlyphSlotAllocation[] = []+ const atlas = new GlyphAtlas(fakeRasterizer(10, 20), 100, (i) => seen.push(i))++ atlas.glyphFor(0x78, false, false, FG, BG, 'whole', false, true)++ expect(seen.map((a) => a.strikethrough)).toEqual([true])+ })+it('a throwing tap costs the log line, not the glyph', () => {const r = fakeRasterizer(10, 20)const atlas = new GlyphAtlas(r, 100, () => {diff --git a/src/renderer/glyphgrid/atlas.ts b/src/renderer/glyphgrid/atlas.tsindex 0175575fc..9578856e7 100644--- a/src/renderer/glyphgrid/atlas.ts+++ b/src/renderer/glyphgrid/atlas.ts@@ -31,7 +31,8 @@ export interface GlyphRasterizer {fg: number,bg: number,part?: GlyphPart,- underline?: boolean+ underline?: boolean,+ strikethrough?: boolean): void/** Blank the whole page. Called by `GlyphAtlas.reset()` and by nothing else: the bookkeeping and* the pixels have to be emptied in the same breath or a stale slot keeps its old ink. */@@ -148,6 +149,8 @@ export interface GlyphSlotAllocation {part: GlyphPart/** Whether this slot carries an underline — a cell attribute, or a hovered link. */underline: boolean+ /** Whether this slot carries a strikethrough (SGR 9). */+ strikethrough: boolean}/** What `onReset` hands back. A plain disposable rather than an unsubscribe function so the call@@ -364,12 +367,13 @@ export class GlyphAtlas {fg: number,bg: number,part: GlyphPart = 'whole',- underline = false+ underline = false,+ strikethrough = false): number {- // A blank cell has nothing to rasterize — UNLESS it is underlined. An underlined run is text- // and spaces together (`\e[4munder line\e[0m`), and returning the blank slot for the spaces- // would break the rule into dashes at every word gap.- if ((code === 0x20 || code === 0) && !underline) return 0+ // A blank cell has nothing to rasterize — UNLESS it is underlined or struck through. A+ // decorated run is text and spaces together (`\e[4munder line\e[0m`), and returning the+ // blank slot for the spaces would break the rule into dashes at every word gap.+ if ((code === 0x20 || code === 0) && !underline && !strikethrough) return 0// `>>> 0` on both lanes: `0xff << 24` is NEGATIVE in JS (packColor carries the same note), so// one colour can arrive as -16777216 from an arithmetic path and as 4278190080 off a cell// lane. Keying the two spellings separately would put identical pixels in two slots — wasted@@ -378,7 +382,7 @@ export class GlyphAtlas {// `part` is IN the key: the two halves of one character are different pixels, and keying them// together would hand the follower the lead's slot and paint the left half twice. 'whole' and// 'wide-left' differ too — same drawing, different entitlement, so a different shrink.- const key = `${code}|${bold ? 1 : 0}${italic ? 1 : 0}${underline ? 1 : 0}|${fg >>> 0}|${bg >>> 0}|${part}`+ const key = `${code}|${bold ? 1 : 0}${italic ? 1 : 0}${underline ? 1 : 0}${strikethrough ? 1 : 0}|${fg >>> 0}|${bg >>> 0}|${part}`const hit = this.slots.get(key)if (hit !== undefined) return hitif (this.nextSlot >= this.capacity) {@@ -399,14 +403,14 @@ export class GlyphAtlas {}const slot = this.nextSlot++const { x, y } = this.cellXY(slot)- this.rasterizer.draw(code, bold, italic, x, y, fg, bg, part, underline)+ this.rasterizer.draw(code, bold, italic, x, y, fg, bg, part, underline, strikethrough)this.slots.set(key, slot)this.dirtyFlag = true// LAST, and guarded: the tap is a debug aid, so a throwing callback must cost a log line, not// the glyph — everything above is already committed by the time it runs.if (this.onAllocate) {try {- this.onAllocate({ slot, code, bold, italic, x, y, fg, bg, part, underline })+ this.onAllocate({ slot, code, bold, italic, x, y, fg, bg, part, underline, strikethrough })} catch {/* a debug tap never breaks a frame */}diff --git a/src/renderer/glyphgrid/cells.ts b/src/renderer/glyphgrid/cells.tsindex 93633afcd..028de83bc 100644--- a/src/renderer/glyphgrid/cells.ts+++ b/src/renderer/glyphgrid/cells.ts@@ -8,6 +8,7 @@ export const FLAG_UNDERLINE = 4export const FLAG_CURSOR = 8export const FLAG_WIDE = 16export const FLAG_SELECTED = 32+export const FLAG_STRIKETHROUGH = 64/** RGBA8 packed little-endian style: r in the low byte (matches UNSIGNED_BYTE attr upload).* The trailing `>>> 0` is load-bearing, not cosmetic: `0xff << 24` is NEGATIVE in JS, sodiff --git a/src/renderer/glyphgrid/feed.test.ts b/src/renderer/glyphgrid/feed.test.tsindex fa6fa6105..d8e3250af 100644--- a/src/renderer/glyphgrid/feed.test.ts+++ b/src/renderer/glyphgrid/feed.test.ts@@ -1,5 +1,16 @@import { describe, expect, it } from 'vitest'-import { CELL_STRIDE, FLAG_BOLD, FLAG_CURSOR, FLAG_ITALIC, FLAG_SELECTED, FLAG_UNDERLINE, FLAG_WIDE, packColor, readCell } from './cells'+import {+ CELL_STRIDE,+ FLAG_BOLD,+ FLAG_CURSOR,+ FLAG_ITALIC,+ FLAG_SELECTED,+ FLAG_STRIKETHROUGH,+ FLAG_UNDERLINE,+ FLAG_WIDE,+ packColor,+ readCell+} from './cells'import type { GlyphAtlas, GlyphPart } from './atlas'import type { DecorationReader } from './decorations'import { packViewportRow, setBlankCellProbe, type BlankCellReport, type CellView, type RowFeedOpts, type ThemeLanes } from './feed'@@ -28,6 +39,7 @@ function fakeAtlas(): Pick<GlyphAtlas, 'glyphFor'> & {colors: Array<[number, number]>parts: GlyphPart[]underlines: boolean[]+ strikethroughs: boolean[]} {const calls: Array<[number, boolean, boolean]> = []const colors: Array<[number, number]> = []@@ -37,11 +49,13 @@ function fakeAtlas(): Pick<GlyphAtlas, 'glyphFor'> & {// assertions that pin `calls` verbatim stay about what they were written for.const parts: GlyphPart[] = []const underlines: boolean[] = []+ const strikethroughs: boolean[] = []return {calls,colors,parts,underlines,+ strikethroughs,glyphFor(code: number,bold: boolean,@@ -49,12 +63,14 @@ function fakeAtlas(): Pick<GlyphAtlas, 'glyphFor'> & {fg: number,bg: number,part: GlyphPart = 'whole',- underline = false+ underline = false,+ strikethrough = false): number {calls.push([code, bold, italic])colors.push([fg, bg])parts.push(part)underlines.push(underline)+ strikethroughs.push(strikethrough)return 900 + calls.length}}@@ -71,6 +87,7 @@ function makeCell(bold?: booleanitalic?: booleanunderline?: boolean+ strikethrough?: booleaninverse?: booleandim?: booleanfg?: Attr@@ -88,6 +105,7 @@ function makeCell(isBold: () => (o.bold ? 1 : 0),isItalic: () => (o.italic ? 1 : 0),isUnderline: () => (o.underline ? 1 : 0),+ isStrikethrough: () => (o.strikethrough ? 1 : 0),isInverse: () => (o.inverse ? 1 : 0),isDim: () => (o.dim ? 1 : 0),isFgDefault: () => is(fg, 'default'),@@ -222,6 +240,32 @@ describe('packViewportRow — attributes', () => {expect(atlas.calls).toEqual([[0x43, false, true]])expect(readCell(out, 0).flags).toBe(FLAG_ITALIC | FLAG_UNDERLINE)})++ /**+ * Reported 2026-10-06: a diff viewer's removed lines (`\e[9m`) showed no strikethrough in shared+ * mode while GPU mode drew one. The feed never read the attribute at all.+ */+ it('strikethrough sets FLAG_STRIKETHROUGH and asks the atlas for the STRUCK variant', () => {+ const { out, atlas } = pack([makeCell({ code: 0x44, strikethrough: true })])++ expect(readCell(out, 0).flags).toBe(FLAG_STRIKETHROUGH)+ expect(atlas.strikethroughs).toEqual([true])+ expect(atlas.underlines).toEqual([false])+ })++ it('strikes a SPACE inside a struck run — the line must not dash at word gaps', () => {+ const { out, atlas } = pack([makeCell({ code: 0x20, strikethrough: true })])++ expect(readCell(out, 0).glyph).not.toBe(0)+ expect(atlas.strikethroughs).toEqual([true])+ })++ it('an undecorated space still takes the blank slot', () => {+ const { out, atlas } = pack([makeCell({ code: 0x20 })])++ expect(readCell(out, 0).glyph).toBe(0)+ expect(atlas.calls).toEqual([])+ })})describe('packViewportRow — wide and zero-width cells', () => {@@ -259,6 +303,16 @@ describe('packViewportRow — wide and zero-width cells', () => {])})+ it('the follower carries the lead’s strikethrough, so both halves are crossed out', () => {+ const lead = makeCell({ code: 0x4e2d, width: 2, strikethrough: true })+ const cont = makeCell({ code: 0, width: 0 })++ const { out, atlas } = pack([lead, cont])++ expect(atlas.strikethroughs).toEqual([true, true])+ expect(readCell(out, 1).flags & FLAG_STRIKETHROUGH).toBe(FLAG_STRIKETHROUGH)+ })+it('a zero-width cell with no wide lead before it still writes a blank cell (never stale)', () => {// The row buffer is reused across frames, so "write nothing" would leave the PREVIOUS// frame's lanes at that column. Every column is always written.diff --git a/src/renderer/glyphgrid/feed.ts b/src/renderer/glyphgrid/feed.tsindex 9d48e2c85..c8be4189d 100644--- a/src/renderer/glyphgrid/feed.ts+++ b/src/renderer/glyphgrid/feed.ts@@ -13,6 +13,7 @@ import {FLAG_CURSOR,FLAG_ITALIC,FLAG_SELECTED,+ FLAG_STRIKETHROUGH,FLAG_UNDERLINE,FLAG_WIDE,packColor,@@ -31,6 +32,7 @@ export interface CellView {isBold(): numberisItalic(): numberisUnderline(): number+ isStrikethrough(): numberisInverse(): numberisDim(): numberisFgDefault(): boolean@@ -150,10 +152,10 @@ function isRenderableCode(code: number): boolean {* Is this a BLANK the atlas can still be asked to paint — i.e. a space, or the 0 an empty cell* reports?*- * Only reached for an UNDERLINED cell (see the request site). A blank normally short-circuits to- * the blank slot, and must keep doing so: it is the most common cell on the canvas, and a slot per- * space-with-these-colours would burn the page for pixels that are pure background. An underline is- * the one thing that makes a blank cell carry ink.+ * Only reached for an UNDERLINED or STRUCK cell (see the request site). A blank normally+ * short-circuits to the blank slot, and must keep doing so: it is the most common cell on the+ * canvas, and a slot per space-with-these-colours would burn the page for pixels that are pure+ * background. A line decoration is the one thing that makes a blank cell carry ink.*/function drawableBlank(code: number): boolean {return code === 0x20 || code === 0@@ -333,6 +335,7 @@ export function packViewportRow(let carryCode = 0let carryBold = falselet carryItalic = false+ let carryStrikethrough = false/** Was the wide lead we are carrying from the one the BLOCK cursor covers? Separate from the* colour carry because the colours are captured PRE-override and the cursor is applied post — the* follower has to re-apply it, not inherit an already-overridden pair. */@@ -392,6 +395,9 @@ export function packViewportRow(code = carryCodebold = carryBolditalic = carryItalic+ // Unlike underline (still Phase 2), a strikethrough IS carried: a struck double-width+ // character with only its left half crossed out reads as two different characters.+ if (carryStrikethrough) flags |= FLAG_STRIKETHROUGHpart = 'wide-right'}carryPending = false@@ -405,6 +411,7 @@ export function packViewportRow(if (bold) flags |= FLAG_BOLDif (italic) flags |= FLAG_ITALICif (cell.isUnderline() !== 0) flags |= FLAG_UNDERLINE+ if (cell.isStrikethrough() !== 0) flags |= FLAG_STRIKETHROUGHif (width === 2) {flags |= FLAG_WIDE// The LEFT half of a two-cell character, which is a different request from 'whole' even@@ -422,6 +429,7 @@ export function packViewportRow(carryCode = codecarryBold = boldcarryItalic = italic+ carryStrikethrough = (flags & FLAG_STRIKETHROUGH) !== 0} else {carryPending = falsecarryCursor = false@@ -463,9 +471,12 @@ export function packViewportRow(// word gap. `isRenderableCode` still guards the CRASH cases — a lone surrogate or a control// code is refused whatever its underline says — so this only widens it to the blanks the atlas// knows how to answer.+ //+ // A strikethrough follows the same rule for the same reason: a struck run crosses its spaces.const underlined = (flags & FLAG_UNDERLINE) !== 0- const wantsSlot = isRenderableCode(code) || (underlined && drawableBlank(code))- const glyph = wantsSlot ? atlas.glyphFor(code, bold, italic, fg, bg, part, underlined) : 0+ const struck = (flags & FLAG_STRIKETHROUGH) !== 0+ const wantsSlot = isRenderableCode(code) || ((underlined || struck) && drawableBlank(code))+ const glyph = wantsSlot ? atlas.glyphFor(code, bold, italic, fg, bg, part, underlined, struck) : 0// A cell that HOLDS something and still draws nothing is the defect under investigation. A// space is excluded because that is the correct answer for it, not a loss.if (blankProbe && glyph === 0 && probeChars !== '' && probeChars !== ' ') {diff --git a/src/renderer/glyphgrid/raster.test.ts b/src/renderer/glyphgrid/raster.test.tsindex b98b11456..a69306d64 100644--- a/src/renderer/glyphgrid/raster.test.ts+++ b/src/renderer/glyphgrid/raster.test.ts@@ -8,6 +8,7 @@ import {sentinelIntact,shrinkEligible,shrinkToFit,+ strikethroughThickness,underlineThickness} from './raster'@@ -1081,6 +1082,65 @@ describe('underline', () => {})})+describe('strikethrough', () => {+ it('draws a rule across the MIDDLE of the cell, spanning the WHOLE-TEXEL box', () => {+ const stub = stubCanvas()+ active = stub+ const r = createCanvasRasterizer(FONT, 256)!+ stub.ops.length = 0++ r.draw(0x41, false, false, INK_X, INK_Y, FG, BG, 'whole', false, true)++ const rule = stub.ops.filter((o) => o.kind === 'fillRect').at(-1)!+ expect(rule.args[0]).toBe(INK_X)+ expect(rule.args[2]).toBe(COLS_W)+ // Row 9 of a 20-row cell, 1px thick: the row xterm's WebGL stroke paints (centred on 10 - 0.5).+ expect(rule.args[1]).toBe(INK_Y + 9)+ expect(rule.args[3]).toBe(1)+ expect(rule.fill).toBe(FG_CSS)+ })++ it('draws NOTHING extra when the cell is not struck', () => {+ const plain = stubCanvas()+ active = plain+ createCanvasRasterizer(FONT, 256)!.draw(0x41, false, false, INK_X, INK_Y, FG, BG)+ const struck = stubCanvas()+ active = struck++ createCanvasRasterizer(FONT, 256)!.draw(0x41, false, false, INK_X, INK_Y, FG, BG, 'whole', false, true)++ expect(struck.ops.length).toBeGreaterThan(plain.ops.length)+ })++ it('draws BOTH rules when a cell is underlined and struck', () => {+ const stub = stubCanvas()+ active = stub+ const r = createCanvasRasterizer(FONT, 256)!+ stub.ops.length = 0++ r.draw(0x41, false, false, INK_X, INK_Y, FG, BG, 'whole', true, true)++ const rules = stub.ops.filter((o) => o.kind === 'fillRect' && o.args[2] === COLS_W && o.fill === FG_CSS)+ const ys = rules.map((o) => o.args[1])+ expect(ys).toContain(INK_Y + COLS_H - 1)+ expect(ys).toContain(INK_Y + 9)+ })+})++describe('strikethroughThickness', () => {+ it("follows xterm's WebGL rule, so the weight matches the renderer beside it", () => {+ expect(strikethroughThickness(10)).toBe(1)+ expect(strikethroughThickness(20)).toBe(2)+ expect(strikethroughThickness(35)).toBe(3)+ })++ it('never rounds away to nothing', () => {+ expect(strikethroughThickness(8)).toBe(1)+ expect(strikethroughThickness(0)).toBe(1)+ expect(strikethroughThickness(NaN)).toBe(1)+ })+})+describe('underlineThickness', () => {it("follows xterm's own rule, so the weight matches the renderer beside it", () => {expect(underlineThickness(15)).toBe(1)diff --git a/src/renderer/glyphgrid/raster.ts b/src/renderer/glyphgrid/raster.tsindex e7cf7866e..bf5fc15c8 100644--- a/src/renderer/glyphgrid/raster.ts+++ b/src/renderer/glyphgrid/raster.ts@@ -206,6 +206,18 @@ export function underlineThickness(fontSizePx: number): number {return Math.max(1, Math.floor(fontSizePx / 15))}+/**+ * How thick a strikethrough is, in device pixels, for a font of this size.+ *+ * xterm's WebGL rule (`Math.max(1, floor(fontSize * dpr / 10))` — `sizePx` is already device px),+ * for the same reason `underlineThickness` adopts xterm's: a struck run in shared mode should weigh+ * the same as it does in GPU mode beside it. Floored at 1 so it never rounds away at small sizes.+ */+export function strikethroughThickness(fontSizePx: number): number {+ if (!Number.isFinite(fontSizePx) || fontSizePx <= 0) return 1+ return Math.max(1, Math.floor(fontSizePx / 10))+}+/*** How close a geometric op's far edge has to come to the cell's far edge to count as REACHING it —* see step 2 of `draw` for what reaching one earns.@@ -510,7 +522,7 @@ export function createCanvasRasterizer(/** `x, y` is the INK origin the atlas hands us — already one gutter inside the pitch cell on* each axis (`GlyphAtlas.cellXY`) — and `fg`/`bg` are the FINAL packed colour lanes for this* slot. Two DIFFERENT rects are involved; see the header's invariants 3 and 4. */- draw(code, bold, italic, x, y, fg, bg, part = 'whole', underline = false) {+ draw(code, bold, italic, x, y, fg, bg, part = 'whole', underline = false, strikethrough = false) {// The glyph's own origin inside this slot. 'wide-right' is the RIGHT half of a double-width// character (see `GlyphAtlas.glyphFor`): the character is drawn one cell FURTHER LEFT, so the// window this slot's clip keeps is its second cell instead of its first. Everything else@@ -698,6 +710,24 @@ export function createCanvasRasterizer(ctx.fillRect(x, y + colsH - thickness, colsW, thickness)ctx.restore()}+ // 2c. THE STRIKETHROUGH, if this cell carries one (SGR 9).+ //+ // Everything 2b says applies: our own geometry, the whole-texel box so a struck run joins+ // into one continuous line, baked into the slot as one more key lane. Only the position+ // differs — xterm's WebGL renderer strokes it across the MIDDLE of the cell, centred on+ // `floor(cellH / 2) - 0.5` for an odd width (the half-pixel nudge that keeps a 1px stroke+ // crisp). As a whole-pixel fill that is a top edge `ceil(thickness / 2)` above the middle+ // row — `floor` would sit one device pixel lower than GPU mode at every odd thickness.+ if (strikethrough) {+ ctx.save()+ ctx.beginPath()+ ctx.rect(x, y, colsW, colsH)+ ctx.clip()+ ctx.fillStyle = cssColor(fg)+ const thickness = strikethroughThickness(font.sizePx)+ ctx.fillRect(x, y + Math.floor(font.cellH / 2) - Math.ceil(thickness / 2), colsW, thickness)+ ctx.restore()+ }// 3. THE EDGE EXTENSION — clamp-to-edge padding, the standard atlas technique. Replicate the// cell's outermost texel row/column outward into the gutter, so the gutter continues the// cell instead of falling back to flat background.