Skip to content

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.

debug(glyphgrid): name the author of a cell that holds a character and draws nothing

enes8788b7020e49
diff --git a/src/renderer/canvas/SharedGlyphLayer.tsx b/src/renderer/canvas/SharedGlyphLayer.tsx
index 3b7da4094..aa7949589 100644
--- a/src/renderer/canvas/SharedGlyphLayer.tsx
+++ b/src/renderer/canvas/SharedGlyphLayer.tsx
@@ -42,6 +42,7 @@ import {
} from '../glyphgrid/atlas'
import type { Camera } from '../glyphgrid/camera'
import { GlyphGridEngine } from '../glyphgrid/engine'
+import { setBlankCellProbe } from '../glyphgrid/feed'
import { createFrameLoop, type FrameLoop } from '../glyphgrid/frame-driver'
import type { GlyphGL } from '../glyphgrid/gl'
import { createWebgl2GL } from '../glyphgrid/gl-webgl2'
@@ -734,6 +735,33 @@ function glyphDebugTap(): ((info: GlyphSlotAllocation) => void) | undefined {
}
}
+/** Names the author of a cell that HOLDS a character and still packs to "draw nothing".
+ *
+ * The three answers are not a list of suspects, they are the three code paths that can produce a
+ * blank lane, so the first report ends the guessing:
+ * - `width 0` → the buffer says this column is a wide glyph's FOLLOWER. Then the bug is upstream
+ * of us (or in the lead's width handling), not in the atlas.
+ * - `width -1` → the buffer had no cell for the column at all, i.e. we packed past the end of a
+ * line we thought was longer.
+ * - `width >=1` → the cell exists and holds text, and the crash guard still refused the derived
+ * code: read the reported `code` against `isRenderableCode`.
+ *
+ * Throttled per (row, col) so a stuck cell on a repainting row cannot flood the console — the
+ * interesting fact is WHICH cell and WHY, and it does not get truer the hundredth time. */
+function installBlankCellProbe(): void {
+ if (!glyphDebugOn()) return
+ const seen = new Set<string>()
+ setBlankCellProbe(({ col, row, width, code, chars }) => {
+ const key = `${row}:${col}`
+ if (seen.has(key)) return
+ seen.add(key)
+ console.warn(
+ `[glyphgrid] BLANK CELL row ${row} col ${col} holds ${JSON.stringify(chars)} ` +
+ `(code 0x${code.toString(16)}, width ${width}) but drew nothing`
+ )
+ })
+}
+
/** Exposes `window.__glyphgridDump()` → `{ page, ...geometry }`, where `page` is a PNG data URL of
* the whole atlas. Installed only under the debug flag; the tester opens the data URL in a tab and
* looks for the reported letter.
@@ -859,6 +887,7 @@ function createContext(cell: DeviceCell): LiveContext | null {
if (!gl) return null
const atlas = new GlyphAtlas(raster, ATLAS_PAGE_PX, glyphDebugTap())
installGlyphDump(atlas, raster)
+ installBlankCellProbe()
const engine = new GlyphGridEngine(gl, atlas)
engine.setCamera(lastCamera)
return {
diff --git a/src/renderer/glyphgrid/feed.test.ts b/src/renderer/glyphgrid/feed.test.ts
index 8f765feb3..4f0264b20 100644
--- a/src/renderer/glyphgrid/feed.test.ts
+++ b/src/renderer/glyphgrid/feed.test.ts
@@ -2,7 +2,7 @@ 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 type { GlyphAtlas } from './atlas'
import type { DecorationReader } from './decorations'
-import { packViewportRow, type CellView, type RowFeedOpts, type ThemeLanes } from './feed'
+import { packViewportRow, setBlankCellProbe, type BlankCellReport, type CellView, type RowFeedOpts, type ThemeLanes } from './feed'
const THEME: ThemeLanes = {
fg: packColor(0xd0, 0xd1, 0xd2, 0xff),
@@ -687,3 +687,33 @@ describe('packViewportRow — missing cells and buffer reuse', () => {
expect(readCell(out, 0).glyph).toBe(901)
})
})
+
+describe('the blank-cell probe', () => {
+ it('names the cell, what it holds and the width that produced the blank', () => {
+ const reports: BlankCellReport[] = []
+ setBlankCellProbe((r) => reports.push(r))
+ try {
+ // A cell that HOLDS a letter and still reports width 0 — the shape of the 2026-08-05 report,
+ // where a letter went missing mid-word. The probe must name the width, because that is the
+ // one fact that says whether the loss is ours or the buffer's.
+ const orphan = makeCell({ chars: 'L', code: 0x4c, width: 0 })
+ pack([orphan], { bufferRow: 7 })
+ expect(reports).toEqual([{ col: 0, row: 7, width: 0, code: 0, chars: 'L' }])
+ } finally {
+ setBlankCellProbe(null)
+ }
+ })
+
+ it('stays silent for a space and for a cell that did get a glyph', () => {
+ const reports: BlankCellReport[] = []
+ setBlankCellProbe((r) => reports.push(r))
+ try {
+ // A space packs to no glyph and that is CORRECT, not a loss — reporting it would bury the
+ // real finding under one line per blank column on the canvas.
+ pack([makeCell({ chars: ' ', code: 0x20 }), makeCell({ chars: 'A', code: 0x41 })])
+ expect(reports).toEqual([])
+ } finally {
+ setBlankCellProbe(null)
+ }
+ })
+})
diff --git a/src/renderer/glyphgrid/feed.ts b/src/renderer/glyphgrid/feed.ts
index 1045ba89c..fcf022a53 100644
--- a/src/renderer/glyphgrid/feed.ts
+++ b/src/renderer/glyphgrid/feed.ts
@@ -84,6 +84,34 @@ export interface RowFeedOpts {
const MAX_CODE_POINT = 0x10ffff
+/** What a cell reported at the moment it packed to "draw nothing". */
+export interface BlankCellReport {
+ col: number
+ row: number
+ /** `cell.getWidth()`, or -1 when the buffer had no cell for this column at all. */
+ width: number
+ /** The code the feed derived — 0 when nothing was derived. */
+ code: number
+ /** `cell.getChars()`, i.e. what the buffer says is actually IN the cell. */
+ chars: string
+}
+
+/** Debug-only tap, off unless something installs it.
+ *
+ * This exists because a blank cell has THREE possible authors — a wide glyph's follower, a column
+ * past the end of the line, and a code the crash guard refuses — and a screenshot cannot tell them
+ * apart. It fires only when the cell HAS content and we still drew nothing, which is the exact
+ * shape of the 2026-08-05 "a letter goes missing mid-word" report.
+ *
+ * Its SILENCE is a result too: if a cell renders blank on screen and this never fires, the feed
+ * asked for the right glyph and the loss happened downstream (lane upload or draw), which is a
+ * different hunt entirely. */
+let blankProbe: ((report: BlankCellReport) => void) | null = null
+
+export function setBlankCellProbe(fn: ((report: BlankCellReport) => void) | null): void {
+ blankProbe = fn
+}
+
/** Whether a code point may reach the atlas — i.e. whether `String.fromCodePoint(code)` in the
* rasterizer is safe AND worth a slot.
*
@@ -278,6 +306,11 @@ export function packViewportRow(
let code = 0
let bold = false
let italic = false
+ // Debug-only witnesses, read at the bottom of the loop. -1 distinguishes "no cell" from a cell
+ // that reported width 0; `getChars()` is only called when the probe is installed, because it
+ // allocates a string per cell and this loop runs for every cell of every packed row.
+ let probeWidth = -1
+ let probeChars = ''
if (cell) {
fg = resolveFg(cell, theme)
@@ -290,6 +323,10 @@ export function packViewportRow(
if (cell.isDim()) fg = dimLane(fg)
const width = cell.getWidth()
+ if (blankProbe) {
+ probeWidth = width
+ probeChars = cell.getChars()
+ }
if (width === 0) {
// Second half of the preceding wide glyph: no glyph of its own, and the lead's colors
// when we have them (a stray width-0 cell with no lead keeps its own — still never
@@ -354,6 +391,11 @@ export function packViewportRow(
// fg/bg are FINAL here — this is the only place the atlas may be asked, see the doc comment.
const glyph = isRenderableCode(code) ? atlas.glyphFor(code, bold, italic, fg, bg) : 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 !== ' ') {
+ blankProbe({ col, row: bufferRow, width: probeWidth, code, chars: probeChars })
+ }
writeCell(out, col, glyph, fg, bg, flags)
}
}