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): edge-extend slot gutters — full-bleed glyphs no longer grow grout seams
enesd9ab09579703
diff --git a/docs/superpowers/plans/2026-08-03-phase1b-device-checklist.md b/docs/superpowers/plans/2026-08-03-phase1b-device-checklist.mdindex f2d597ed4..fe7277ab9 100644--- a/docs/superpowers/plans/2026-08-03-phase1b-device-checklist.md+++ b/docs/superpowers/plans/2026-08-03-phase1b-device-checklist.md@@ -141,9 +141,24 @@ Auto after you switched builds, that is why: re-select Shared and carry on.motion is where undersampling shows.**What should now be true.** Minified text degrades SMOOTHLY, in the same class as GPU mode:softer as it shrinks, but not speckling, crawling or shimmering under a pan. The atlas carries- a real mip chain and every slot carries a 2-texel gutter filled with its own background, so a- minified sample averages texels that belong to this cell instead of undersampling level 0 —- which is exactly what made a zoomed-out canvas sparkle before this phase.+ a real mip chain and every slot carries a 2-texel gutter holding its own edge-extended content,+ so a minified sample averages texels that belong to this cell instead of undersampling level 0+ — which is exactly what made a zoomed-out canvas sparkle before this phase.+ **Also check FULL-BLEED art, not just text (fixed after the 2026-08-04 device round).** Put+ something made of solid blocks on screen — the **Claude mascot** (the `claude` splash art,+ U+2580–U+259F) is the reference case — and keep a **tmux pane split** in view so its `│` `─`+ separators are there too. At ~50% and ~25%: the mascot must read as SOLID, with **no dark+ "grout" lines along the cell boundaries**, and the separators must stay continuous rather than+ going dashed. Before the gutters were edge-extended, every cell boundary grew a dark seam — the+ mip texel was averaging the cell's edge INK with the slot's flat background gutter — so a solid+ block of mascot came out as a dark lattice. Seams coming back is a **blocking** report: say at+ which zoom, and whether the dips track the cell pitch.+ **Expected residual 0 — two adjacent full-bleed slots.** At the worst subpixel phase and mip+ level 2, a bilinear tap can reach a gutter texel blending THIS slot's edge colour with the+ NEIGHBOUR's; where two differently-coloured full-bleed cells sit side by side, each can+ slightly tint the other's outermost sample. Same bounded, accepted class as the old+ background-vs-background softness — a faint tint at extreme zoom-out, never a seam and never a+ ghost glyph. Report it only if it reads as more than that.**Expected residual 1 — the LOD clamp.** The sampler is forbidden to go deeper than mip level 2,because that is the deepest level the gutter can keep free of a neighbouring glyph's ink. Pastroughly 25% the filter therefore cannot get any softer, and slight aliasing comes back. That isdiff --git a/src/renderer/glyphgrid/atlas.ts b/src/renderer/glyphgrid/atlas.tsindex dad34d760..831d76230 100644--- a/src/renderer/glyphgrid/atlas.ts+++ b/src/renderer/glyphgrid/atlas.ts@@ -35,24 +35,37 @@ export interface GlyphRasterizer {}/**- * The ink-free margin, in page texels, on EVERY side of a slot's cell rect. Exported because three- * modules have to agree on it: this file lays the page out with it, raster.ts fills it with the- * slot's own background colour, and gl-webgl2.ts offsets its uv derivation by it.+ * The margin, in page texels, on EVERY side of a slot's cell rect that belongs to this slot alone.+ * Exported because three modules have to agree on it: this file lays the page out with it,+ * raster.ts fills it with the slot's own content, and gl-webgl2.ts offsets its uv derivation by it.+ *+ * WHAT THE GUTTER CARRIES. Not simply background — the slot's own EDGE-EXTENDED content: raster.ts+ * fills it with the slot's background and then replicates the cell's outermost texel row/column+ * outward into it (clamp-to-edge padding). For ordinary text the border texels ARE background, so+ * that is bit-identical to a flat bg fill; for a glyph whose ink reaches the cell edge (blocks, box+ * lines, progress bars) the gutter continues the INK, which is what stops a minified sample at the+ * cell edge from averaging ink with background and drawing a dark seam. See step 3 of `draw` in+ * raster.ts for the device report that forced this.** WHY 2 — the derivation, since this number is what bounds the usable mip chain. A mip level-n- * texel is the average of an aligned 2^n × 2^n block of level-0 texels. Two slots' inks are+ * texel is the average of an aligned 2^n × 2^n block of level-0 texels. Two slots' CELLS are* separated by 2*GUTTER_PX = 4 texels of gutter (this slot's plus the neighbour's), so a level-n- * block can only contain ink from BOTH slots once it is wider than that separation, i.e. once+ * block can only contain content from BOTH slots once it is wider than that separation, i.e. once* 2^n > 4 → n >= 3. Levels 0, 1 and 2 therefore never mix a foreign glyph into this slot, which is- * why gl-webgl2 clamps TEXTURE_MAX_LOD to MAX_SAFE_LOD = 2.+ * why gl-webgl2 clamps TEXTURE_MAX_LOD to MAX_SAFE_LOD = 2. Note what the derivation does and does+ * not require: it requires the gutter to hold colours OWNED BY THIS SLOT, which the pitch layout+ * guarantees whatever raster.ts writes there — it never required them to be background.** What the gutter does NOT promise, stated so nobody reads more into it: bilinear filtering WITHIN- * a level still reaches the adjacent texel, which at level 2 can be a pure-gutter texel holding a- * blend of this slot's background and the neighbour's. That is a soft edge between two BACKGROUND- * colours at heavy zoom-out — never a ghost glyph — and it is the residual the LOD clamp accepts.- * The promise is about INK, and it holds only while raster.ts keeps ink inside the cell rect: ink- * allowed to overhang into the gutter shortens the ink-to-ink separation and invalidates the- * derivation above.+ * a level still reaches the adjacent texel, which at level 2 can be a pure-gutter texel blending+ * this slot's edge colour with the neighbour's. Usually that is background against background; two+ * adjacent full-bleed slots make it ink against ink, possibly tinting each other's outermost+ * sample. Either way it is a soft edge between two slots' EDGE colours at heavy zoom-out — never a+ * ghost glyph — and it is the residual the LOD clamp accepts. The promise is that no glyph GEOMETRY+ * is ever drawn outside its cell rect, and it holds only while raster.ts keeps clipping the ink:+ * ink allowed to overhang into the gutter shortens the cell-to-cell separation and invalidates the+ * derivation above. (Copying this slot's own edge texels outward does not — a copy of our own+ * content is not a second slot's ink.)*/export const GUTTER_PX = 2diff --git a/src/renderer/glyphgrid/gl-webgl2.ts b/src/renderer/glyphgrid/gl-webgl2.tsindex c3a27a1cf..77f0aec93 100644--- a/src/renderer/glyphgrid/gl-webgl2.ts+++ b/src/renderer/glyphgrid/gl-webgl2.ts@@ -8,11 +8,12 @@ import { plateRectDevice } from './plate'* The deepest mip level the atlas may ever be sampled at (`TEXTURE_MAX_LOD`).** DERIVED FROM `GUTTER_PX`, which is why it is computed rather than typed: a level-n texel is the- * average of an aligned 2^n x 2^n block of level-0 texels, and two slots' inks are separated by- * `2 * GUTTER_PX` ink-free texels (this slot's gutter plus its neighbour's — see GUTTER_PX in- * atlas.ts). A level-n block can therefore only reach ink from BOTH slots once 2^n exceeds that- * separation, so the last safe level is `floor(log2(2 * GUTTER_PX))` = 2 for the gutter of 2 this- * atlas lays out. Raising the gutter raises this on its own; the two can never disagree.+ * average of an aligned 2^n x 2^n block of level-0 texels, and two slots' CELLS are separated by+ * `2 * GUTTER_PX` texels that belong to one slot or the other and to no third party (this slot's+ * gutter plus its neighbour's — see GUTTER_PX in atlas.ts). A level-n block can therefore only+ * reach content from BOTH slots once 2^n exceeds that separation, so the last safe level is+ * `floor(log2(2 * GUTTER_PX))` = 2 for the gutter of 2 this atlas lays out. Raising the gutter+ * raises this on its own; the two can never disagree.** Levels deeper than this are neither generated nor sampled. `generateMipmap` builds levels* `base+1 .. q`, where `q` is clamped by `TEXTURE_MAX_LEVEL` (ES 3.0 §3.8.9) — so setting MAX_LEVEL@@ -24,8 +25,11 @@ import { plateRectDevice } from './plate'* to build fewer levels. It does; that sentence was wrong.)** The residual the clamp accepts is stated in GUTTER_PX's comment: at level 2 a bilinear tap can- * reach a pure-gutter texel holding a blend of two BACKGROUND colours. That is a soft edge between- * backgrounds at heavy zoom-out, never a ghost glyph.+ * reach a pure-gutter texel holding a blend of THIS SLOT'S EDGE COLOUR and the NEIGHBOUR'S. For+ * ordinary text both edges are background, so that is the background-vs-background softness it has+ * always been; where two full-bleed slots sit side by side (block art, box-drawing rules) the two+ * edges are ink and can tint each other's outermost sample. Same bounded, accepted class either+ * way — a soft edge at heavy zoom-out, never a ghost glyph.*/const MAX_SAFE_LOD = Math.floor(Math.log2(2 * GUTTER_PX))@@ -202,7 +206,9 @@ export function createWebgl2GL(canvas: HTMLCanvasElement): GlyphGL | null {* scale. LINEAR magnification of the same level-0 texels is the same class of bilinear* upscale the CSS transform applies — the user chose parity over the extra sharpness.* An edge tap reaches at most 1 texel outside the cell extent, which is the slot's own- * bg-filled gutter (2 texels) — never a neighbour's ink.+ * EDGE-EXTENDED gutter (2 texels) — never a neighbour's ink. Edge-extended rather than+ * bg-filled matters here too: on a full-bleed glyph that tap now continues the ink instead of+ * darkening towards the background.*/const applyAtlasMinFilter = (zoom: number): void => {const wantMin = zoom >= 1 ? gl.NEAREST : gl.LINEAR_MIPMAP_LINEARdiff --git a/src/renderer/glyphgrid/raster.test.ts b/src/renderer/glyphgrid/raster.test.tsindex c28bfe940..78801a0bd 100644--- a/src/renderer/glyphgrid/raster.test.ts+++ b/src/renderer/glyphgrid/raster.test.ts@@ -4,45 +4,148 @@ import { packColor } from './cells'import { createCanvasRasterizer } from './raster'/**- * These tests pin the two rects a colored draw uses, because the whole mip story rests on them:+ * These tests pin the three rects a colored draw uses, because the whole mip story rests on them:* the slot's own BACKGROUND covers the FULL PITCH rect (gutter included — that is what makes a- * level-1/2 texel blend this slot's background with itself rather than with the page ground),- * while the INK is clipped to the CELL rect and may never touch the gutter (the MAX_SAFE_LOD = 2- * derivation in `atlas.ts` counts on 2*GUTTER_PX clean texels between two slots' inks).+ * level-1/2 texel blend this slot's content with itself rather than with the page ground), the+ * INK is clipped to the CELL rect (a glyph may never draw NEW geometry into the gutter — the+ * MAX_SAFE_LOD = 2 derivation in `atlas.ts` counts on 2*GUTTER_PX texels of this-slot-only content+ * between two slots' inks), and the gutter is then EDGE-EXTENDED from the cell's own border texels+ * so a full-bleed glyph continues into it instead of fading to background.*- * Node has no OffscreenCanvas, so the contract is checked against a recording stub rather than- * real pixels.+ * Node has no OffscreenCanvas, so the contract is checked against a stub. The stub does two things:+ * it RECORDS the op list (order and geometry) and it maintains a tiny PIXEL MODEL of the page.+ * Both are needed — the replication is uniform by design (it runs for every glyph, and is a visual+ * no-op when the ink does not reach the cell edge), so the op list alone can never distinguish a+ * full-bleed glyph's gutter from an ordinary letter's.*/interface Op {- kind: 'fillRect' | 'fillText' | 'clip' | 'clearRect'+ kind: 'fillRect' | 'fillText' | 'clip' | 'clearRect' | 'drawImage'fill?: stringargs: number[]text?: string+ /** `imageSmoothingEnabled` as it stood when the op was recorded. Only meaningful for drawImage:+ * a 1-texel source stretched over the gutter must REPLICATE, never resample. */+ smoothing?: boolean+ /** Whether the drawImage source was the rasterizer's OWN canvas — the only source it ever uses. */+ self?: boolean}-function stubCanvas(): { ops: Op[]; restore: () => void } {+/** The active clip as half-open texel bounds, or `null` for "no clip". */+type Clip = { x0: number; y0: number; x1: number; y1: number } | null++/**+ * The pixel model is deliberately HARD-EDGED: it answers "whose content is in this texel", not+ * "what exact blend". A real canvas antialiases a fractional fill edge, and replicating such a+ * partial-coverage texel into the gutter is correct precisely because it is still the slot's OWN+ * edge colour — but a coverage model is not needed to check WHICH slot's content lands where.+ *+ * `fillText` paints NOTHING into the model: the stub has no font engine. That is not a gap for+ * these tests, it is the case they need — an ordinary letter is exactly a glyph whose ink stays+ * inside the cell, and the model then shows the replication copying background over background.+ */+function stubCanvas(sizePx = 256): {+ ops: Op[]+ pixelAt: (x: number, y: number) => string+ /** The page-wide `imageSmoothingEnabled` as it stands NOW — for asserting it was restored. */+ smoothingNow: () => boolean+ restore: () => void+} {const ops: Op[] = []+ const px: string[] = new Array(sizePx * sizePx).fill('')+ let selfCanvas: unknown = null+ let clip: Clip = null+ let pending: { x: number; y: number; w: number; h: number } | null = null+ const clipStack: Clip[] = []++ const setPixel = (x: number, y: number, color: string): void => {+ if (x < 0 || y < 0 || x >= sizePx || y >= sizePx) return+ if (clip && (x < clip.x0 || y < clip.y0 || x >= clip.x1 || y >= clip.y1)) return+ px[y * sizePx + x] = color+ }+ // Texel centres, i.e. the pixel whose centre falls inside [a, a+len). `Math.round` is that rule+ // for every rect these tests use (all of them start on a whole texel).+ const paint = (x: number, y: number, w: number, h: number, color: string): void => {+ for (let j = Math.round(y); j < Math.round(y + h); j++)+ for (let i = Math.round(x); i < Math.round(x + w); i++) setPixel(i, j, color)+ }+const ctx = {font: '',textBaseline: '',fillStyle: '',- save() {},- restore() {},- beginPath() {},+ imageSmoothingEnabled: true,+ save() {+ clipStack.push(clip)+ },+ restore() {+ clip = clipStack.pop() ?? null+ },+ beginPath() {+ pending = null+ },rect(x: number, y: number, w: number, h: number) {ops.push({ kind: 'clip', args: [x, y, w, h] })+ pending = { x, y, w, h }+ },+ clip() {+ if (!pending) return+ const next = {+ x0: Math.round(pending.x),+ y0: Math.round(pending.y),+ x1: Math.round(pending.x + pending.w),+ y1: Math.round(pending.y + pending.h)+ }+ clip = clip+ ? {+ x0: Math.max(clip.x0, next.x0),+ y0: Math.max(clip.y0, next.y0),+ x1: Math.min(clip.x1, next.x1),+ y1: Math.min(clip.y1, next.y1)+ }+ : next},- clip() {},fillRect(x: number, y: number, w: number, h: number) {ops.push({ kind: 'fillRect', fill: ctx.fillStyle, args: [x, y, w, h] })+ paint(x, y, w, h, ctx.fillStyle)},clearRect(x: number, y: number, w: number, h: number) {ops.push({ kind: 'clearRect', args: [x, y, w, h] })+ paint(x, y, w, h, '')},fillText(text: string, x: number, y: number) {ops.push({ kind: 'fillText', fill: ctx.fillStyle, args: [x, y], text })},+ /** Only the 9-argument form, and only with WHOLE-texel destination rects — which is all the+ * rasterizer's gutter replication uses. Nearest-neighbour sampling off a SNAPSHOT of the page,+ * which is what the spec guarantees for a self-referencing drawImage. */+ drawImage(+ src: unknown,+ sx: number,+ sy: number,+ sw: number,+ sh: number,+ dx: number,+ dy: number,+ dw: number,+ dh: number+ ) {+ ops.push({+ kind: 'drawImage',+ args: [sx, sy, sw, sh, dx, dy, dw, dh],+ smoothing: ctx.imageSmoothingEnabled,+ self: src === selfCanvas+ })+ const snap = px.slice()+ for (let j = 0; j < dh; j++) {+ for (let i = 0; i < dw; i++) {+ const u = Math.floor(sx + ((i + 0.5) * sw) / dw)+ const v = Math.floor(sy + ((j + 0.5) * sh) / dh)+ if (u < 0 || v < 0 || u >= sizePx || v >= sizePx) continue+ setPixel(dx + i, dy + j, snap[v * sizePx + u])+ }+ }+ },// A face whose line box exactly fills a 20px cell, so the baseline math is not the subject.measureText: () => ({ fontBoundingBoxAscent: 16, fontBoundingBoxDescent: 4 })}@@ -51,13 +154,21 @@ function stubCanvas(): { ops: Op[]; restore: () => void } {constructor(public width: number,public height: number- ) {}+ ) {+ selfCanvas = this+ }getContext(): unknown {return ctx}}return {ops,+ pixelAt(x: number, y: number) {+ return px[y * sizePx + x]+ },+ smoothingNow() {+ return ctx.imageSmoothingEnabled+ },restore() {;(globalThis as Record<string, unknown>).OffscreenCanvas = prev}@@ -68,6 +179,10 @@ const FONT = { family: 'monospace', sizePx: 16, cellW: 10, cellH: 20 }/** The pitch this font lays out on: ceil(cell) + a gutter on each side. */const PITCH_W = 10 + 2 * GUTTER_PXconst PITCH_H = 20 + 2 * GUTTER_PX+/** The WHOLE texel columns/rows a cell occupies — `ceil(cell)`, i.e. the pitch minus its gutters.+ * The edge-extension works in these because a texel is the smallest thing it can copy. */+const COLS_W = 10+const COLS_H = 20/** A realistic INK origin — the corner of a pitch cell plus one gutter on each axis, which is* exactly what `GlyphAtlas.cellXY` hands the rasterizer. */@@ -132,7 +247,13 @@ describe('createCanvasRasterizer', () => {expect(Number.isInteger(ink.args[1])).toBe(true)})- it('keeps every ink op inside the CELL rect — the gutter must stay clean for the mip chain', () => {+ // The claim is about GEOMETRY, not about pixels: no glyph may generate NEW ink outside the cell+ // rect, because the MAX_SAFE_LOD derivation counts on 2*GUTTER_PX texels between two slots' inks.+ // The gutter is not required to be BACKGROUND — the edge-extension strips below copy this slot's+ // own border texels into it, and a copy of the slot's own content is not a second slot's ink. So+ // this pin filters `fillRect`/`fillText` ops only, and the replication `drawImage`s are checked+ // separately for their exact (this-slot-only) source and destination rects.+ it('keeps every ink op inside the CELL rect — no glyph draws new geometry into the gutter', () => {const stub = stubCanvas()active = stubconst r = createCanvasRasterizer(FONT, 256)!@@ -227,4 +348,122 @@ describe('createCanvasRasterizer', () => {atlas.glyphFor(0x41, false, false, FG, BG)expect(stub.ops.some((o) => o.args[0] < PITCH_W && o.args[1] < PITCH_H)).toBe(false)})++ /**+ * EDGE-EXTENDED GUTTERS (device round, 2026-08-04). A gutter filled with flat background made the+ * mip chain average cell-edge INK with background, which drew a dark "grout" line along every+ * boundary between two full-bleed cells at zoom < 1 (the Claude mascot's block art, tmux's │ ─+ * pane separators). The fix is the standard atlas one: clamp-to-edge padding — the gutter carries+ * the cell's own outermost texel row/column, so a minified sample keeps averaging ink with ink.+ */+ describe('gutter edge-extension', () => {+ /** All four replication ops, in the order the rasterizer must emit them. */+ const strips = (ops: Op[]): Op[] => ops.filter((o) => o.kind === 'drawImage')++ it('replicates the cell border into the gutter — sides first, then full-pitch rows for the corners', () => {+ const stub = stubCanvas()+ active = stub+ const r = createCanvasRasterizer(FONT, 256)!+ stub.ops.length = 0+ r.draw(0x2588, false, false, INK_X, INK_Y, FG, BG) // █++ // Order is load-bearing: the LEFT/RIGHT strips run first over the cell's rows only, then the+ // TOP/BOTTOM strips copy a full-PITCH-wide row — by which time that row already holds the+ // side strips, so each corner of the gutter ends up with the cell's corner texel.+ expect(strips(stub.ops).map((o) => o.args)).toEqual([+ // left: the cell's first column, stretched over the left gutter+ [INK_X, INK_Y, 1, COLS_H, INK_X - GUTTER_PX, INK_Y, GUTTER_PX, COLS_H],+ // right: its last column, over the right gutter+ [+ INK_X + COLS_W - 1,+ INK_Y,+ 1,+ COLS_H,+ INK_X + COLS_W,+ INK_Y,+ GUTTER_PX,+ COLS_H+ ],+ // top: the (now side-extended) first row, over the full pitch width+ [INK_X - GUTTER_PX, INK_Y, PITCH_W, 1, INK_X - GUTTER_PX, INK_Y - GUTTER_PX, PITCH_W, GUTTER_PX],+ // bottom: mirrored+ [+ INK_X - GUTTER_PX,+ INK_Y + COLS_H - 1,+ PITCH_W,+ 1,+ INK_X - GUTTER_PX,+ INK_Y + COLS_H,+ PITCH_W,+ GUTTER_PX+ ]+ ])+ // The source is the page itself — a self-referencing drawImage, which 2D canvas defines as+ // reading a snapshot.+ expect(strips(stub.ops).every((o) => o.self)).toBe(true)+ })++ it('disables image smoothing while replicating and restores it afterwards', () => {+ const stub = stubCanvas()+ active = stub+ const r = createCanvasRasterizer(FONT, 256)!+ stub.ops.length = 0+ r.draw(0x2588, false, false, INK_X, INK_Y, FG, BG)+ // A 1-texel source stretched over GUTTER_PX texels has to REPLICATE, not resample: smoothing+ // would fade the copy back towards whatever the gutter held before.+ expect(strips(stub.ops).map((o) => o.smoothing)).toEqual([false, false, false, false])+ // …and the page-wide flag is left as it was found, because the next slot's bg fill and ink+ // are not this call's business. (Every draw restores it, so the second call still sees it+ // disabled only for its own strips.)+ r.draw(0x41, false, false, INK_X, INK_Y, FG, BG)+ expect(strips(stub.ops).map((o) => o.smoothing)).toEqual(new Array(8).fill(false))+ expect(stub.smoothingNow()).toBe(true)+ })++ /** Every texel of the slot's PITCH rect that lies outside its whole-texel cell box. */+ const gutterTexels = (): { x: number; y: number }[] => {+ const out: { x: number; y: number }[] = []+ for (let y = INK_Y - GUTTER_PX; y < INK_Y - GUTTER_PX + PITCH_H; y++)+ for (let x = INK_X - GUTTER_PX; x < INK_X - GUTTER_PX + PITCH_W; x++)+ if (x < INK_X || x >= INK_X + COLS_W || y < INK_Y || y >= INK_Y + COLS_H) out.push({ x, y })+ return out+ }++ it('a FULL-BLEED glyph leaves the whole gutter — corners included — carrying its ink', () => {+ const stub = stubCanvas()+ active = stub+ const r = createCanvasRasterizer(FONT, 256)!+ r.draw(0x2588, false, false, INK_X, INK_Y, FG, BG) // █ fills the cell edge to edge+ for (const { x, y } of gutterTexels()) expect(`${x},${y}:${stub.pixelAt(x, y)}`).toBe(`${x},${y}:${FG_CSS}`)+ })++ it('a glyph whose ink stays inside the cell leaves the gutter as background', () => {+ const stub = stubCanvas()+ active = stub+ const r = createCanvasRasterizer(FONT, 256)!+ r.draw(0x41, false, false, INK_X, INK_Y, FG, BG) // an ordinary letter — ink nowhere near the edge+ // Replication still runs (it is uniform, never conditional on where the ink landed); for+ // ordinary text it copies background over background, i.e. bit-identical to the old bg-filled+ // gutter. That is why no detection of "does this glyph bleed?" is needed anywhere.+ for (const { x, y } of gutterTexels()) expect(`${x},${y}:${stub.pixelAt(x, y)}`).toBe(`${x},${y}:${BG_CSS}`)+ })++ it('a half block continues the ink on ITS side only — the other gutter stays background', () => {+ const stub = stubCanvas()+ active = stub+ const r = createCanvasRasterizer(FONT, 256)!+ r.draw(0x258c, false, false, INK_X, INK_Y, FG, BG) // ▌ left half++ const midY = INK_Y + COLS_H / 2+ // Left gutter: ink, all the way out to the pitch edge.+ for (let x = INK_X - GUTTER_PX; x < INK_X; x++) expect(stub.pixelAt(x, midY)).toBe(FG_CSS)+ // Right gutter: background, because the cell's last column is background.+ for (let x = INK_X + COLS_W; x < INK_X + COLS_W + GUTTER_PX; x++)+ expect(stub.pixelAt(x, midY)).toBe(BG_CSS)+ // And the corners follow the side they belong to — the property the strip ORDER buys.+ expect(stub.pixelAt(INK_X - GUTTER_PX, INK_Y - GUTTER_PX)).toBe(FG_CSS)+ expect(stub.pixelAt(INK_X + COLS_W + GUTTER_PX - 1, INK_Y - GUTTER_PX)).toBe(BG_CSS)+ expect(stub.pixelAt(INK_X - GUTTER_PX, INK_Y + COLS_H + GUTTER_PX - 1)).toBe(FG_CSS)+ })+ })})diff --git a/src/renderer/glyphgrid/raster.ts b/src/renderer/glyphgrid/raster.tsindex befd6aa04..68931aa77 100644--- a/src/renderer/glyphgrid/raster.ts+++ b/src/renderer/glyphgrid/raster.ts@@ -101,8 +101,9 @@ function baselineIn(ctx: OffscreenCanvasRenderingContext2D, font: RasterFont): n* the backing store's format, and an alpha-less canvas would additionally let Chromium turn on* LCD/subpixel antialiasing, whose per-channel coverage the RGBA blit would bake in per channel.*- * THE PAGE INVARIANT, in one line: the backdrop is per-slot bg over the FULL PITCH rect, and no- * slot's INK can reach another slot's texels at any level up to MAX_SAFE_LOD.+ * THE PAGE INVARIANT, in one line: every texel of a slot's PITCH rect carries content OWNED BY+ * THAT SLOT, and no slot's content can reach another slot's texels at any level up to+ * MAX_SAFE_LOD.** Stated that way on purpose — an earlier wording claimed the inter-slot page ground is "never* sampled at LOD <= MAX_SAFE_LOD", which overstates it. Unallocated pitch cells DO enter a level-2@@ -135,11 +136,19 @@ function baselineIn(ctx: OffscreenCanvasRenderingContext2D, font: RasterFont): n* there would bleed into slot 1's minified texels.* 2. A slot's whole pitch rect is REPAINTED with its background before it is inked, so reusing a* cell after a reset can never leave a previous glyph's ink or a previous background behind.- * 3. INK NEVER ENTERS THE GUTTER. Every glyph is clipped to the CELL rect — one gutter inside the- * pitch rect on each axis — so two slots' inks stay 2*GUTTER_PX texels apart, which is exactly- * the separation `MAX_SAFE_LOD = 2` is derived from (see GUTTER_PX in atlas.ts). A glyph wider- * than the cell (a CJK cell, an overhanging italic) is CUT, not allowed to overhang: a soft- * edge is a cosmetic loss on one glyph, a ghost glyph in a neighbour's mip is a rendering bug.+ * 3. NO GLYPH DRAWS NEW GEOMETRY INTO THE GUTTER. Every glyph is clipped to the CELL rect — one+ * gutter inside the pitch rect on each axis — so two slots' inks stay 2*GUTTER_PX texels apart,+ * which is exactly the separation `MAX_SAFE_LOD = 2` is derived from (see GUTTER_PX in+ * atlas.ts). A glyph wider than the cell (a CJK cell, an overhanging italic) is CUT, not+ * allowed to overhang: a soft edge is a cosmetic loss on one glyph, a ghost glyph in a+ * neighbour's mip is a rendering bug.+ *+ * What the gutter then HOLDS is a separate question, and the answer changed in the 2026-08-04+ * device round: it carries this slot's OWN EDGE-EXTENDED CONTENT — background wherever the ink+ * does not reach the cell edge (all ordinary text, i.e. bit-identical to the old flat bg fill),+ * the edge ink where it does (blocks, box-drawing lines, progress bars). What must never enter+ * the gutter is a NEIGHBOUR's content, and pitch tiling still guarantees exactly that. See+ * step 3 in `draw` for why a bg-only gutter grew a dark seam between full-bleed cells.* 4. The background fill covers the pitch EXACTLY — not more (it would erase a neighbour's* gutter, and with it that neighbour's mip skirt) and not less (a strip of page ground inside* the mip neighbourhood would blend transparency into the slot at LOD 1/2).@@ -166,6 +175,13 @@ export function createCanvasRasterizer(// below has to cover exactly one pitch cell.const pitchW = slotPitch(font.cellW)const pitchH = slotPitch(font.cellH)+ // The WHOLE texel columns/rows the cell occupies — the pitch minus its two gutters, by+ // construction (`slotPitch` is `max(1, ceil(cell)) + 2*GUTTER_PX`). The edge extension works in+ // these rather than in the fractional cell because a texel is the smallest thing it can copy,+ // and deriving them from `slotPitch`'s own expression is what keeps "cell box + two gutters ==+ // pitch" true for a sub-texel cell too.+ const colsW = Math.max(1, Math.ceil(font.cellW))+ const colsH = Math.max(1, Math.ceil(font.cellH))return {cellW: font.cellW,cellH: font.cellH,@@ -189,16 +205,20 @@ export function createCanvasRasterizer(// It also repaints everything a previous tenant of this slot left behind.// UNCLIPPED, and the two candidate clips fail differently: a CELL clip — the one installed// below for the ink — would be actively WRONG here, since it is exactly the gutter (the- // part of the pitch outside the cell) that has to carry this slot's background for the mip- // chain to blend background into background instead of into page ground. A PITCH clip+ // part of the pitch outside the cell) that has to carry this slot's own content for the+ // mip chain to blend this slot with itself instead of with page ground. A PITCH clip// would merely be REDUNDANT: the rect is already exact and `cellXY` is the only source of// the origin, so there is nothing for it to catch.+ // This is the BASE layer of the gutter, not the last word on it: step 3 replaces the parts+ // of it that sit against ink with that ink, and leaves the rest exactly as filled here.ctx.fillStyle = cssColor(bg)ctx.fillRect(x - GUTTER_PX, y - GUTTER_PX, pitchW, pitchH)// 2. THE INK, clipped to the CELL rect — never the pitch rect. The cell always fits inside- // the pitch (the pitch rounds the cell UP and adds a gutter on each side), so this clip- // leaves at least GUTTER_PX ink-free texels on every side, which is the separation- // MAX_SAFE_LOD = 2 is derived from. A glyph that overflows the cell is CUT here.+ // the pitch (the pitch rounds the cell UP and adds a gutter on each side), so no glyph can+ // generate geometry closer than GUTTER_PX to the next slot, which is the separation+ // MAX_SAFE_LOD = 2 is derived from. A glyph that overflows the cell is CUT here. (Step 3+ // may then COPY this ink outward into our own gutter — a copy of our own content, never a+ // reason to relax this clip.)ctx.save()ctx.beginPath()ctx.rect(x, y, font.cellW, font.cellH)@@ -220,6 +240,74 @@ export function createCanvasRasterizer(ctx.fillText(String.fromCodePoint(code), x, y + baseline)}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.+ //+ // WHY (device round, 2026-08-04). The Claude mascot — solid block glyphs — grew dark+ // "grout" lines along every cell boundary at zoom < 1, and tmux's │ ─ pane separators went+ // dashed. The signature was exact: dips at the cell PITCH, deepest ≈ (ink+bg)/2 — a mip+ // texel averaging cell-edge INK with the slot's bg-filled gutter. Ordinary text never+ // showed it because its outer texels are background anyway; every glyph whose ink TOUCHES+ // the cell edge did. GPU mode is immune because CSS downscales the COMPOSED frame, where+ // a cell edge blends with the NEIGHBOUR'S ink rather than with per-slot background.+ //+ // The MAX_SAFE_LOD derivation never asked the gutter to be BACKGROUND — it asks that+ // levels 0..2 be free of the NEIGHBOUR's texels, which pitch tiling gives regardless of+ // what this slot writes into its own gutter. So the gutter may carry this slot's edge+ // colour, and then a minified sample at the cell edge keeps averaging ink with ink.+ //+ // THE SAMPLED EXTENT DOES NOT CHANGE. `GlyphAtlas.slotRect` (and the shader's derivation+ // of it) still spans exactly the cell — the extension is a mip/filter SKIRT, not extra+ // glyph. Growing the uv rect to include the gutter would pull the padding into the glyph+ // at zoom 1 and stretch every cell by two texels; that is a different (and wrong) change.+ //+ // UNIFORM, never conditional: this runs for every glyph, including the ones whose ink+ // stops short of the edge — there it copies background over background and is a visual+ // no-op, bit-identical to what the fill in step 1 already left. Detecting "does this glyph+ // bleed?" would cost a readback per slot and buy nothing.+ //+ // OUTSIDE THE CLIP, deliberately: `ctx.restore()` above has dropped the CELL clip, and it+ // would eat these strips whole — they land entirely in the gutter, which is the part of+ // the pitch that clip exists to exclude.+ //+ // The source is the page CANVAS ITSELF. A self-referencing `drawImage` is well-defined in+ // 2D canvas (the source region is read as a snapshot before anything is written), which is+ // what lets the top/bottom strips below read a row the side strips have just extended.+ //+ // FRACTIONAL CELLS: the cell's outer edge falls inside a texel in general, so the border+ // texel being copied may be a partial-coverage ANTIALIASED blend of ink and background.+ // Replicating the blend is CORRECT — it is still this slot's own edge colour, and it is+ // exactly the colour the sampler would tap just inside the cell.+ const prevSmoothing = ctx.imageSmoothingEnabled+ // A 1-texel source stretched over GUTTER_PX texels must REPLICATE, not resample: with+ // smoothing on the copy would fade back towards whatever the gutter held, which is the+ // background this whole step exists to get out of the way.+ ctx.imageSmoothingEnabled = false+ // ORDER: the two SIDE strips first, over the cell's rows only; then the two full-PITCH-wide+ // ROW strips. By the time the top strip copies row `y`, that row already carries the side+ // strips' texels in the left and right gutters — so each corner of the gutter ends up+ // holding the cell's CORNER texel, which is what a clamp-to-edge pad means. Doing the rows+ // first (and the sides over the full pitch height) would work equally well; what must not+ // happen is both passes covering only the cell's own extent, which leaves the four corner+ // squares as stale background.+ ctx.drawImage(canvas, x, y, 1, colsH, x - GUTTER_PX, y, GUTTER_PX, colsH)+ ctx.drawImage(canvas, x + colsW - 1, y, 1, colsH, x + colsW, y, GUTTER_PX, colsH)+ ctx.drawImage(canvas, x - GUTTER_PX, y, pitchW, 1, x - GUTTER_PX, y - GUTTER_PX, pitchW, GUTTER_PX)+ ctx.drawImage(+ canvas,+ x - GUTTER_PX,+ y + colsH - 1,+ pitchW,+ 1,+ x - GUTTER_PX,+ y + colsH,+ pitchW,+ GUTTER_PX+ )+ // Restored rather than left off: the flag is page-wide state, and the next slot's fills are+ // not this call's business.+ ctx.imageSmoothingEnabled = prevSmoothing}}}