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): the feed asks for colored glyphs; the addon survives atlas resets
enes98ece7040cc6
diff --git a/src/renderer/glyphgrid/addon.test.ts b/src/renderer/glyphgrid/addon.test.tsindex 3f8ea33da..39267e142 100644--- a/src/renderer/glyphgrid/addon.test.ts+++ b/src/renderer/glyphgrid/addon.test.ts@@ -83,10 +83,37 @@ function recordingHandle(): GridHandle & {}}-function recordingAtlas(): Pick<GlyphAtlas, 'glyphFor'> {- // Identity-ish: the slot IS derived from the code point, so a packed glyph lane names the cell- // it came from without a second bookkeeping structure.- return { glyphFor: (code) => code }+/** The atlas surface the addon holds: a slot source AND a reset broadcaster.+ *+ * `fireReset()` is the test's hand on the real atlas's most awkward behaviour — a reset fires+ * SYNCHRONOUSLY inside a `glyphFor` call, i.e. in the middle of someone's row pack — so+ * `onGlyphFor` exists to fire it from exactly there. */+function recordingAtlas(o: { onGlyphFor?: (fire: () => void) => void } = {}): Pick<+ GlyphAtlas,+ 'glyphFor' | 'onReset'+> & { fireReset(): void; subCount(): number } {+ const subs = new Set<() => void>()+ const fireReset = (): void => {+ for (const cb of [...subs]) cb()+ }+ return {+ // Identity-ish: the slot IS derived from the code point, so a packed glyph lane names the cell+ // it came from without a second bookkeeping structure.+ glyphFor: (code) => {+ o.onGlyphFor?.(fireReset)+ return code+ },+ onReset: (cb) => {+ subs.add(cb)+ return {+ dispose: (): void => {+ subs.delete(cb)+ }+ }+ },+ fireReset,+ subCount: () => subs.size+ }}interface FakeTermOpts {@@ -130,15 +157,19 @@ function fakeTerm(o: FakeTermOpts = {}): TermInternals & { state: Required<FakeT}}-function make(o: FakeTermOpts = {}): {+function make(+ o: FakeTermOpts & { atlas?: ReturnType<typeof recordingAtlas> } = {}+): {core: GlyphGridRendererAddonCoreterm: ReturnType<typeof fakeTerm>handle: ReturnType<typeof recordingHandle>+ atlas: ReturnType<typeof recordingAtlas>} {const term = fakeTerm(o)const handle = recordingHandle()- const core = new GlyphGridRendererAddonCore(term, handle, recordingAtlas())- return { core, term, handle }+ const atlas = o.atlas ?? recordingAtlas()+ const core = new GlyphGridRendererAddonCore(term, handle, atlas)+ return { core, term, handle, atlas }}/** The glyph lane of a packed row decodes back to (absRow, col) — see rowCodedCell. */@@ -404,6 +435,55 @@ describe('GlyphGridRendererAddonCore redraw requests', () => {})})+/** ATLAS RESETS. The atlas clears its whole page when the colour key space fills, which leaves+ * every already-packed lane pointing at a slot that now holds someone else's glyph. The addon's+ * job is to get all its rows repacked — and to do it WITHOUT repacking from inside the reset,+ * which fires synchronously in the middle of a `glyphFor` call during someone's row pack. */+describe('GlyphGridRendererAddonCore atlas resets', () => {+ it('asks for a DEFERRED full redraw instead of repacking on the spot', () => {+ const { core, handle, atlas } = make({ rows: 5 })+ const seen: Array<{ start: number; end: number }> = []+ core.onRequestRedraw((e) => seen.push(e))+ handle.rows.length = 0+ atlas.fireReset()+ // The repack itself is xterm's to schedule: packing here would run inside whatever pack loop+ // the reset interrupted.+ expect(handle.rows).toEqual([])+ expect(seen).toEqual([{ start: 0, end: 4 }])+ })++ it('a reset fired from INSIDE a row pack does not recurse into the pack loop', () => {+ // The real shape of the event: the page fills on some cell's glyphFor, mid-row. Every+ // requested row must still be packed exactly once, and the repack must arrive as a redraw+ // request rather than as a nested pack.+ let fired = false+ const atlas = recordingAtlas({+ onGlyphFor: (fire) => {+ if (fired) return+ fired = true+ fire()+ }+ })+ const { core, handle } = make({ rows: 4, atlas })+ const seen: Array<{ start: number; end: number }> = []+ core.onRequestRedraw((e) => seen.push(e))+ core.renderRows(0, 2)+ expect(handle.rows.map((r) => r.row)).toEqual([0, 1, 2])+ expect(seen).toEqual([{ start: 0, end: 3 }])+ })++ it('unsubscribes from the atlas on dispose — a torn-down terminal owes it no repack', () => {+ const { core, atlas } = make()+ const seen: number[] = []+ core.onRequestRedraw(() => seen.push(1))+ expect(atlas.subCount()).toBe(1)+ core.dispose()+ expect(atlas.subCount()).toBe(0)+ atlas.fireReset()+ expect(seen).toEqual([])+ })+})+describe('GlyphGridRendererAddonCore.dispose', () => {it('makes every further call inert — a torn-down terminal must never touch the grid', () => {const { core, handle } = make({ rows: 6 })diff --git a/src/renderer/glyphgrid/addon.ts b/src/renderer/glyphgrid/addon.tsindex 339ab9835..0ead41a52 100644--- a/src/renderer/glyphgrid/addon.ts+++ b/src/renderer/glyphgrid/addon.ts@@ -8,7 +8,7 @@* one injected interface means a bump breaks ONE thin shell instead of the renderer, and lets the* whole render path be unit-tested without a DOM, a canvas or a terminal. */-import type { GlyphAtlas } from './atlas'+import type { GlyphAtlas, GlyphAtlasSubscription } from './atlas'import { CELL_STRIDE } from './cells'import type { GridHandle } from './engine'import { packViewportRow, type CellView, type ThemeLanes } from './feed'@@ -120,10 +120,15 @@ export class GlyphGridRendererAddonCore {private readonly readCellBound = (col: number, into: CellView): CellView | undefined =>this.internals.readCell(this.absRow, col, into)+ /** Live for the addon's whole life; disposed in `dispose()`. The atlas is SHARED by every+ * terminal on the canvas, so a subscription left behind holds a torn-down addon alive and asks+ * it to repack rows into a grid its node has already dropped. */+ private readonly atlasResetSub: GlyphAtlasSubscription+constructor(private readonly internals: TermInternals,private readonly handle: GridHandle,- private readonly atlas: Pick<GlyphAtlas, 'glyphFor'>+ private readonly atlas: Pick<GlyphAtlas, 'glyphFor' | 'onReset'>) {this.cols = internals.cols()this.rows = internals.rows()@@ -132,6 +137,10 @@ export class GlyphGridRendererAddonCore {this.focused = internals.hasFocus()this.lastCursorRow = this.cursorViewportRow()this.updateDims()+ // LAST, so nothing above can throw after the subscription exists: the shell catches a failing+ // construction and restores the DOM renderer, and a subscription made before that throw would+ // never be disposed by anyone.+ this.atlasResetSub = this.atlas.onReset(() => this.handleAtlasReset())}// ---------------------------------------------------------------- xterm renderer surface@@ -249,10 +258,43 @@ export class GlyphGridRendererAddonCore {dispose(): void {this.disposed = truethis.redrawListeners.clear()+ this.atlasResetSub.dispose()}// ---------------------------------------------------------------- internals+ /**+ * The shared atlas cleared its page (its colour key space filled), so EVERY lane this addon has+ * ever packed now names a slot holding some other cell's glyph. All rows have to be repacked.+ *+ * DEFERRED, NOT IMMEDIATE, and that is the whole design of this method. A reset fires+ * synchronously from inside a `glyphFor` call — i.e. from the middle of a `packRows` loop, ours+ * or another terminal's. Repacking here would re-enter that loop, and the atlas's own guard would+ * then hand the re-entrant requests the BLANK slot to stop it recursing, so the repack would+ * produce exactly the empty cells it exists to prevent. Instead we ask xterm for a full redraw+ * through the same `onRequestRedraw` mechanism `clear()` and a theme change use: RenderService+ * marks the rows dirty and packs them from its own debounced render pass, outside anybody's loop.+ *+ * WHY THE ENGINE'S UPLOAD ORDERING SURVIVES THIS. The engine uploads the atlas before it uploads+ * rows and both before it draws, and a reset preserves that: it marks the atlas dirty, so the+ * next frame re-uploads the cleared-and-refilled page BEFORE any row of it is drawn. Within that+ * frame, the row whose pack triggered the reset carries fresh slots (its remaining cells+ * allocated into the new page); OTHER rows may still name slots that meant something else in the+ * old page, and they are repainted one frame late — the frame this redraw request schedules. A+ * single frame of possibly-stale glyphs on rows nobody has touched, self-healing, is the accepted+ * cost of resets being rare; the alternative is a synchronous repack inside a pack loop, which is+ * a correctness problem rather than a cosmetic one.+ *+ * Bounded by nothing here on purpose: a page too small for the canvas would reset again on the+ * repack, request another redraw, and settle into a repaint per frame. That is the LRU escalation+ * Phase 2 names, and it needs to be VISIBLE (the atlas logs `resetCount`) rather than smoothed+ * over by a rate limit in the one place that knows the rows are wrong.+ */+ private handleAtlasReset(): void {+ if (this.disposed || this.rows <= 0) return+ this.emitRedraw(0, this.rows - 1)+ }+private repackAll(): void {if (this.disposed) returnthis.packRows(0, this.rows - 1)diff --git a/src/renderer/glyphgrid/atlas.ts b/src/renderer/glyphgrid/atlas.tsindex e2933ecc8..561b2af88 100644--- a/src/renderer/glyphgrid/atlas.ts+++ b/src/renderer/glyphgrid/atlas.ts@@ -218,8 +218,10 @@ export class GlyphAtlas {* and a page genuinely too small for the canvas is the LRU escalation's problem, not a* recursion's.*- * A full repack inside someone else's pack loop is still the wrong SHAPE for the addon — which- * is why T4 defers it to the redraw path rather than running it here.+ * That guard is a floor, not the intended path. A full repack inside someone else's pack loop is+ * the wrong SHAPE for a subscriber, which is why the renderer addon answers a reset by requesting+ * a full REDRAW (see `handleAtlasReset`) and lets xterm's render pass do the packing outside this+ * notification — where the guard above never has to degrade anything to blank.*/onReset(cb: () => void): GlyphAtlasSubscription {this.resetSubs.add(cb)@@ -247,9 +249,10 @@ export class GlyphAtlas {// atlas started over", and a clearPage() that threw must not leave a count claiming it did.this.resets++this.dirtyFlag = true- // NOTE: nothing subscribes yet — T3+T4 wire the addon repack; until then a reset leaves stale- // lanes rendering WRONG glyphs (worse than the old blank degrade). Do not run a device round- // before T4.+ // The subscriber that matters is the renderer addon (one per attached terminal), which answers+ // by asking xterm for a full redraw — deferred, never a repack from inside this notification.+ // A page with NO subscriber (the dev harness feeds the engine directly) keeps rendering its+ // already-uploaded lanes against the fresh page, i.e. wrong glyphs until something repacks it.this.inReset = truetry {// Iterate a COPY: a subscriber is allowed to dispose itself (or another) from inside its owndiff --git a/src/renderer/glyphgrid/engine.ts b/src/renderer/glyphgrid/engine.tsindex e84a4a120..1db6155d9 100644--- a/src/renderer/glyphgrid/engine.ts+++ b/src/renderer/glyphgrid/engine.ts@@ -112,6 +112,13 @@ interface Grid extends GridSpec {* sampling slot 0 everywhere and the uniforms permanently one upload stale. A draw that* samples a texture the glyphs have not been uploaded into paints solid blocks; the engine* is the only place that sees both, so it is the enforcer.+ *+ * An atlas RESET needs no special handling here, which is worth stating because it looks like it+ * should: it happens during a row PACK, never inside `frame()` (nothing this class calls allocates+ * a glyph), and it marks the atlas dirty — so the very next frame re-uploads the cleared and+ * refilled page before it uploads or draws a single row of it. Rows still naming old slots are the+ * addon's problem, and it repacks them from the redraw it requests (see+ * `GlyphGridRendererAddonCore.handleAtlasReset`).*/export class GlyphGridEngine {private grids = new Map<string, Grid>()diff --git a/src/renderer/glyphgrid/feed.test.ts b/src/renderer/glyphgrid/feed.test.tsindex cc58d70e5..05d4e8274 100644--- a/src/renderer/glyphgrid/feed.test.ts+++ b/src/renderer/glyphgrid/feed.test.ts@@ -15,16 +15,25 @@ const THEME: ThemeLanes = {}/** Records every glyphFor call so "the atlas was NOT called" is assertable, and hands back a- * distinct non-zero slot per call so a glyph lane can be traced to the call that produced it. */-function fakeAtlas(): Pick<GlyphAtlas, 'glyphFor'> & { calls: Array<[number, boolean, boolean]> } {+ * distinct non-zero slot per call so a glyph lane can be traced to the call that produced it.+ *+ * Two parallel records rather than one 5-tuple: `calls` is the shape/style key every existing+ * assertion reads, and `colors` is the COLOUR key at the same index. The atlas is keyed by both+ * from Phase 1c on, so what the feed asks for is as load-bearing as what it writes into the lanes+ * — a cell that renders selected but requests a slot painted in its unselected colours is+ * invisible in the lanes and wrong on screen. */+function fakeAtlas(): Pick<GlyphAtlas, 'glyphFor'> & {+ calls: Array<[number, boolean, boolean]>+ colors: Array<[number, number]>+} {const calls: Array<[number, boolean, boolean]> = []+ const colors: Array<[number, number]> = []return {calls,- // fg/bg are accepted (the atlas keys on them from Phase 1c on) but not recorded yet: the- // colours the feed passes are Task 4's subject, and recording them here would pin the- // pre-override values this task deliberately leaves alone.- glyphFor(code: number, bold: boolean, italic: boolean): number {+ colors,+ glyphFor(code: number, bold: boolean, italic: boolean, fg: number, bg: number): number {calls.push([code, bold, italic])+ colors.push([fg, bg])return 900 + calls.length}}@@ -311,6 +320,77 @@ describe('packViewportRow — cursor and selection', () => {})})+/** THE COLOURS THE ATLAS IS ASKED FOR — the whole point of a colour-keyed atlas.+ *+ * The rasterizer bakes the requested fg/bg into the slot's pixels and the shader blits them+ * unmodified, so the request must carry the cell's FINAL colours: everything the resolution+ * pipeline produces (default/palette/RGB → inverse → dim) AND the selection/cursor overrides that+ * are applied last. Asking with the pre-override pair paints a selected cell in its unselected+ * colours — a defect the packed lanes cannot show, since those are correct either way. */+describe('packViewportRow — the colours the atlas is asked for', () => {+ it('a plain cell asks for the colours it resolved to', () => {+ const { atlas } = pack([makeCell({ code: 0x41 })])+ expect(atlas.colors).toEqual([[THEME.fg, THEME.bg]])+ })++ it('palette and RGB colours reach the atlas resolved, never as indices', () => {+ const { atlas } = pack([+ makeCell({ code: 0x41, fg: ['palette', 2], bg: ['palette', 250] }),+ makeCell({ code: 0x42, fg: ['rgb', 0xaabbcc], bg: ['rgb', 0x123456] })+ ])+ expect(atlas.colors).toEqual([+ [THEME.ansi[2], THEME.ansi[250]],+ [packColor(0xaa, 0xbb, 0xcc, 0xff), packColor(0x12, 0x34, 0x56, 0xff)]+ ])+ })++ it('inverse and dim are baked into the request, in that order', () => {+ const { atlas } = pack([makeCell({ code: 0x41, fg: ['palette', 2], inverse: true, dim: true })])+ // inverse swapped the resolved pair, dim halved the foreground that swap left in place.+ expect(atlas.colors).toEqual([[halve(THEME.bg), THEME.ansi[2]]])+ })++ it('a SELECTED cell asks for a slot painted on the selection background', () => {+ const { out, atlas } = pack([makeCell({ code: 0x41, fg: ['palette', 4] })], { selection: [0, 1] })+ expect(atlas.colors).toEqual([[THEME.ansi[4], THEME.selectionBg]])+ // …and the lanes still say the same thing, so the slot and the cell can never disagree.+ const c = readCell(out, 0)+ expect([c.fg, c.bg]).toEqual([THEME.ansi[4], THEME.selectionBg])+ })++ it('a CURSOR cell asks for a slot painted in the cursor pair', () => {+ const { atlas } = pack([makeCell({ code: 0x41, fg: ['palette', 4] })], { cursorCol: 0 })+ expect(atlas.colors).toEqual([[THEME.cursorFg, THEME.cursorBg]])+ })++ it('cursor over selection asks for the CURSOR pair — the same winner the lanes record', () => {+ const { out, atlas } = pack([makeCell({ code: 0x41 })], { selection: [0, 1], cursorCol: 0 })+ expect(atlas.colors).toEqual([[THEME.cursorFg, THEME.cursorBg]])+ const c = readCell(out, 0)+ expect([c.fg, c.bg]).toEqual([THEME.cursorFg, THEME.cursorBg])+ })++ it('only the covered columns of a selection ask for selection-coloured slots', () => {+ const cells = [0, 1, 2].map((i) => makeCell({ code: 0x41 + i }))+ const { atlas } = pack(cells, { selection: [1, 2] })+ expect(atlas.colors).toEqual([+ [THEME.fg, THEME.bg],+ [THEME.fg, THEME.selectionBg],+ [THEME.fg, THEME.bg]+ ])+ })++ it('a wide lead under the cursor asks for the cursor pair, and its follower asks for nothing', () => {+ const wide = makeCell({ code: 0x4e2d, width: 2, bg: ['rgb', 0x223344] })+ const cont = makeCell({ code: 0, width: 0, bg: ['rgb', 0x223344] })+ const { out, atlas } = pack([wide, cont], { cursorCol: 0 })+ expect(atlas.colors).toEqual([[THEME.cursorFg, THEME.cursorBg]])+ // The follower carries the lead's RESOLVED colours (not the cursor override, which is a+ // per-column paint) and asks for no slot of its own.+ expect(readCell(out, 1).bg).toBe(packColor(0x22, 0x33, 0x44, 0xff))+ })+})+describe('packViewportRow — missing cells and buffer reuse', () => {it('a column past the end of the line becomes a blank cell on the theme background', () => {const { out } = pack([makeCell(), undefined], { cols: 2 })diff --git a/src/renderer/glyphgrid/feed.ts b/src/renderer/glyphgrid/feed.tsindex d0ee7b983..999a6250a 100644--- a/src/renderer/glyphgrid/feed.ts+++ b/src/renderer/glyphgrid/feed.ts@@ -164,7 +164,16 @@ function resolveBg(cell: CellView, theme: ThemeLanes): number {* CURSOR and SELECTION are applied last, over whatever the cell resolved to. Selection repaints* only the background (the foreground must stay readable as itself); the cursor repaints both.* On overlap the CURSOR WINS the colors, and BOTH flags stay set — the flags describe the cell's- * state (this cell is selected AND under the cursor), only the paint has to pick a winner. */+ * state (this cell is selected AND under the cursor), only the paint has to pick a winner.+ *+ * THE ATLAS REQUEST IS THE LAST THING THAT HAPPENS, and it has to be. The atlas is keyed by+ * COLOUR: the rasterizer bakes the requested fg/bg into the slot's pixels and the shader blits+ * them unmodified, so a slot requested before the overrides is painted in the cell's UNSELECTED,+ * UNCURSORED colours and renders that way however correct the lanes are. Which code point / bold /+ * italic to draw is decided in the loop below (it depends on the cell, not on the overrides); the+ * request itself waits until fg/bg are final. Everything that is NOT a request — the flags, the+ * wide-cell carry, the blank branches — is unchanged, so the lanes this writes are what they have+ * always been. */export function packViewportRow(out: Uint32Array,readCell: (col: number, into: CellView) => CellView | undefined,@@ -182,10 +191,15 @@ export function packViewportRow(for (let col = 0; col < cols; col++) {const cell = readCell(col, workCell)- let glyph = 0let fg = theme.fglet bg = theme.bglet flags = 0+ // What this cell will ask the atlas for, decided here and REQUESTED after the overrides below.+ // 0 is "nothing to draw" — it fails `isRenderableCode`, which is the same answer a blank cell,+ // a control code and a wide glyph's follower all give.+ let code = 0+ let bold = false+ let italic = falseif (cell) {fg = resolveFg(cell, theme)@@ -209,23 +223,20 @@ export function packViewportRow(}carryPending = false} else {- const bold = cell.isBold() !== 0- const italic = cell.isItalic() !== 0+ bold = cell.isBold() !== 0+ italic = cell.isItalic() !== 0// 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)- // The atlas is keyed by COLOUR from Phase 1c on, so the request carries the lanes this- // cell resolved to. NOTE, and this is Task 4's to finish: SELECTION and CURSOR are applied- // BELOW this line, so a selected/cursor cell currently asks for a slot in its pre-override- // colours. Threading the values is all this task does; moving the request after the- // overrides (and the ordering audit that goes with it) is the feed rewire.- if (isRenderableCode(code)) glyph = atlas.glyphFor(code, bold, italic, fg, bg)+ code = glyphCode(cell)if (bold) flags |= FLAG_BOLDif (italic) flags |= FLAG_ITALICif (cell.isUnderline() !== 0) flags |= FLAG_UNDERLINEif (width === 2) {flags |= FLAG_WIDEcarryPending = true+ // The lead's RESOLVED colors, captured before the selection/cursor overrides on purpose:+ // those are decided per COLUMN, so the follower applies whichever ones cover IT. A lead+ // under the cursor therefore paints one cursor cell, not two.carryFg = fgcarryBg = bg} else {@@ -247,6 +258,8 @@ export function packViewportRow(flags |= FLAG_CURSOR}+ // 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) : 0writeCell(out, col, glyph, fg, bg, flags)}}diff --git a/src/renderer/glyphgrid/harness/GlyphGridHarness.tsx b/src/renderer/glyphgrid/harness/GlyphGridHarness.tsxindex 8553ba7c9..247def547 100644--- a/src/renderer/glyphgrid/harness/GlyphGridHarness.tsx+++ b/src/renderer/glyphgrid/harness/GlyphGridHarness.tsx@@ -86,9 +86,11 @@ const BASE_BG = packColor(20, 20, 24, 255)* The atlas is keyed by colour (Phase 1c), so the key space this harness generates is* `codes x bold x fg x bg` = 90 x 2 x 4 x 4 = 2880, against a capacity of 3588 slots* (1024px page, 13x22 pitch). A random fg per cell — what this used to do — puts the key space at- * ~54k and the page then RESETS several times a second: 30+ full-page clears per second, and,- * until T4 wires the repack, every already-uploaded lane pointing at a recycled slot, i.e. a- * screen of permanently wrong glyphs. That is a broken harness, not a stress test.+ * ~54k and the page then RESETS several times a second: 30+ full-page clears per second, and every+ * already-uploaded lane pointing at a recycled slot, i.e. a screen of permanently wrong glyphs.+ * This harness feeds the engine DIRECTLY — it is not an xterm terminal, so it has no renderer addon+ * and therefore no reset subscriber to repack it (see GlyphAtlas.onReset). That is a broken+ * harness, not a stress test.*/const FG_PALETTE = [packColor(200, 200, 160, 255),@@ -98,8 +100,8 @@ const FG_PALETTE = []/** ATLAS RESET STRESS. Flip to true to give every cell a random foreground, which blows the key* space past the page's capacity and exercises reset-on-full continuously. Deliberately a manual- * switch: with it on the glyphs on screen are expected to be WRONG (no repack subscriber yet), so- * it is a test of the reset MACHINERY, never of rendering quality. */+ * switch: with it on the glyphs on screen are expected to be WRONG (this harness subscribes to no+ * reset, see above), so it is a test of the reset MACHINERY, never of rendering quality. */const ATLAS_RESET_STRESS = false/** A little air around the fitted layout, so the outermost grids are visibly INSIDE the frame* rather than clipping its edge — the tester has to be able to count them. */