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.

docs(glyphgrid): the plate measures the HOST, and the CSS coincidence that lets it

enes0a589c17993c
diff --git a/docs/superpowers/plans/2026-08-03-phase1b-device-checklist.md b/docs/superpowers/plans/2026-08-03-phase1b-device-checklist.md
index 0ba12be95..971d3cfb2 100644
--- a/docs/superpowers/plans/2026-08-03-phase1b-device-checklist.md
+++ b/docs/superpowers/plans/2026-08-03-phase1b-device-checklist.md
@@ -94,7 +94,10 @@ Auto after you switched builds, that is why: re-select Shared and carry on.
plate is a SQUARE rect under a node with `border-radius: 10px`, so the body's four corners
read square. Judge how visible that is at normal zoom, and report any band you still see —
a band now means the plate rect is not tracking the body, not that it is undersized by
- design.
+ design. **Judge bands only AFTER a resize gesture settles.** The plate is re-pushed on the
+ ResizeObserver's coalesced tick (80 ms after the last resize event — the same settle the
+ terminal reflow waits for), so dragging a node's edge OUTWARD shows a transient band that
+ closes when you let go. That is expected; a band that survives the settle is the defect.
- [ ] **2.14 Scroll area after a font change.** Change the font size while shared is on, then look
at the scrollbar/scroll area geometry: the thumb matches the content, no phantom region.
- [ ] **2.15 Cursor on a wide glyph.** Put the cursor ON a double-width character (type `日本語`
diff --git a/src/renderer/glyphgrid/engine.ts b/src/renderer/glyphgrid/engine.ts
index 8185bb65d..6ad0688dd 100644
--- a/src/renderer/glyphgrid/engine.ts
+++ b/src/renderer/glyphgrid/engine.ts
@@ -174,10 +174,13 @@ export class GlyphGridEngine {
// canvas redrawing at the speed of the busiest invisible node.
//
// Safe because visibility can only change through `setCamera`/`setViewport`/`register`/
- // `resize`/`setOrigin`/`setZ`, and every one of those dirties UNCONDITIONALLY. So the
- // frame that brings a grid into view is always drawn, and its upload pass replays the
- // range accumulated while it was hidden — deferred, never lost. Do not "optimize" any of
- // those into a visibility-scoped dirty; that is the leg this stands on.
+ // `resize`/`setOrigin`/`setPlateRect`/`setZ`, and every one of those dirties
+ // UNCONDITIONALLY. (`setPlateRect` belongs on that list: culling is the union of the plate
+ // rect and the cell rect — see `drawOrder` — so the plate is a visibility INPUT, and a
+ // grid can become visible by its plate moving alone.) So the frame that brings a grid into
+ // view is always drawn, and its upload pass replays the range accumulated while it was
+ // hidden — deferred, never lost. Do not "optimize" any of those into a visibility-scoped
+ // dirty; that is the leg this stands on.
if (grid.lastVisible) engine.dirty = true
},
setOrigin(x, y) {
diff --git a/src/renderer/lib/glyphGridNode.ts b/src/renderer/lib/glyphGridNode.ts
index f4f6eb430..9a6e2c5fd 100644
--- a/src/renderer/lib/glyphGridNode.ts
+++ b/src/renderer/lib/glyphGridNode.ts
@@ -48,14 +48,20 @@ export interface WorldRect {
* (`.term-node--glyphgrid` drops the background from the node root and its body), so the plate IS
* the terminal's background — every square of body the plate does not cover shows raw canvas
* through the node. The GRID cannot supply that rect: a body's width/height are not exact cell
- * multiples, so xterm letterboxes the remainder, and the plate is therefore sized to the BODY
- * (`bodyEl.clientWidth/clientHeight`) rather than derived from cols×cellW.
+ * multiples, so xterm letterboxes the remainder, and the plate is therefore sized to the body box
+ * rather than derived from cols×cellW.
+ *
+ * Pure numbers in, so it does not care WHICH element the caller measured — but the caller's choice
+ * is load-bearing and is documented at ONE place: `TerminalNode`'s `measurePlateRect` measures the
+ * HOST (`.term-node__xterm`), which equals the body's box only while the host is `inset: 0` inside
+ * a padding-less, border-less `.term-node__body`. If either changes, the caller must measure
+ * `.term-node__body` instead or the plate silently under-covers again.
*
* This replaced a `padPx` scalar taken from the host's asymmetric CSS padding (`4px 2px 2px 6px`,
* reduced to its 6px maximum). That covered the left/top insets and nothing else, which is exactly
* why bands showed at the BOTTOM and RIGHT — the fit slack there routinely exceeds 6px, and a
* letterboxed node's bands are tens of pixels. The padding does not need reading at all now: it
- * lies INSIDE the body box, so a body-sized plate covers it on all four sides.
+ * lies INSIDE the measured box (`clientWidth/Height` include padding), covered on all four sides.
*
* `nodePos` + `bodyOffset` is the same LAYOUT sum `bodyWorldRect` does (zoom-independent — the
* canvas transform scales pixels, not offsets). Non-finite or negative extents (an element that
diff --git a/src/renderer/nodes/TerminalNode.tsx b/src/renderer/nodes/TerminalNode.tsx
index 4622ed9a1..2ac6af82e 100644
--- a/src/renderer/nodes/TerminalNode.tsx
+++ b/src/renderer/nodes/TerminalNode.tsx
@@ -317,10 +317,10 @@ function screenOffsetInNode(term: Terminal): Vec2 | null {
/**
* The `offsetParent` walk itself — see `screenOffsetInNode` for the coordinate contract.
*
- * Called with two different elements, which is why it is not folded back into that one. The
- * terminal SCREEN places the grid; the terminal BODY (`.term-node__body`) places the opaque PLATE.
- * The body is the node's transparent window onto the shared canvas, so its offset + client size IS
- * the ground the plate owes — and `.term-node__xterm`'s padding lies inside it, covered for free.
+ * Called with two different elements, which is why it is not folded back into that one:
+ * `.xterm-screen` places the grid, and the terminal HOST (`.term-node__xterm`, which stands in for
+ * the body — see `measurePlateRect` for the CSS invariant that makes it stand in) places the
+ * opaque PLATE.
*/
function offsetInNode(el: HTMLElement | null): Vec2 | null {
if (!el) return null
@@ -1128,11 +1128,12 @@ export function TerminalNode({
* Push the grid to where the terminal screen actually is, and the PLATE to where the body is,
* re-measuring both offsets inside the node. One null check when this terminal holds no grid.
*
- * Two independent rects on purpose (see `GridSpec.plateX`): the grid follows `.xterm-screen`
- * and the plate follows `.term-node__body`, which is larger — the character matrix rarely
- * divides the body exactly, and the leftover bands at the bottom/right are transparent node,
- * i.e. raw canvas, unless the plate covers them. Both mutators change-gate themselves, so a
- * settle tick that moved neither costs two comparisons.
+ * Two independent rects on purpose (see `GridSpec.plateX`): the grid follows `.xterm-screen`,
+ * the plate follows the host box `.term-node__xterm` standing in for the body (`measurePlateRect`
+ * states the CSS invariant behind that). The plate is the larger of the two — the character
+ * matrix rarely divides the body exactly, and the leftover bands at the bottom/right are
+ * transparent node, i.e. raw canvas, unless the plate covers them. Both mutators change-gate
+ * themselves, so a settle tick that moved neither costs two comparisons.
*/
const syncGridOrigin = (): void => {
const grid = glyphGrid
@@ -1147,8 +1148,24 @@ export function TerminalNode({
if (plate) grid.setPlateRect(plate.x, plate.y, plate.w, plate.h)
}
- /** The body's world rect — the plate. Null when the body is not laid out inside a React Flow
- * node (a parked, detached element): leave the plate where it is rather than collapse it. */
+ /**
+ * The plate's world rect. Null when the element is not laid out inside a React Flow node (a
+ * parked, detached element): leave the plate where it is rather than collapse it.
+ *
+ * **What is measured, and the invariant that makes it correct — the canonical statement; the
+ * other plate comments point here.** `container` is `bodyRef`, which is on
+ * **`.term-node__xterm`** — the HOST, not `.term-node__body`. The plate has to cover the BODY
+ * (that is the element `.term-node--glyphgrid` makes transparent, so every square of it the
+ * plate misses shows raw canvas), and the host's box is the body's box only because
+ * **`.term-node__xterm` is `position: absolute; inset: 0` inside a body that has no padding and
+ * no border**. Its own `4px 2px 2px 6px` padding is inside its border box and `clientWidth/
+ * Height` include it, so the two rects coincide exactly.
+ *
+ * That is a CSS coincidence, not a guarantee. **If the host stops being `inset: 0`, or
+ * `.term-node__body` gains padding or a border, this must measure `.term-node__body` instead**
+ * — otherwise the plate silently under-covers again, which is precisely the band this whole
+ * change removed, and every comment around it would still claim it cannot happen.
+ */
const measurePlateRect = (): { x: number; y: number; w: number; h: number } | null => {
const offset = offsetInNode(container)
if (!offset) return null
diff --git a/src/renderer/styles.css b/src/renderer/styles.css
index 3d21feab6..5d1d16034 100644
--- a/src/renderer/styles.css
+++ b/src/renderer/styles.css
@@ -1632,13 +1632,20 @@ body,
background) and the strip under the header showed the raw canvas through the node. The selection
ring and the unread glow are border-color + box-shadow, both independent of the background.
- The plate is the BODY rect (`lib/glyphGridNode.ts` `bodyPlateRect`: the body's offset inside the
- node plus its client size, pushed on the ResizeObserver's settled tick and carried along by the
- position effect during a drag). It is deliberately NOT derived from the grid: cols×cellW rarely
- divides a body exactly, xterm letterboxes the remainder, and nothing else paints it — a
- grid-sized plate is what left a band of raw dot grid at the bottom and right of every terminal,
- and tens of pixels of it on a letterboxed co-attach node. Being body-sized, it also swallows the
- host's asymmetric `4px 2px 2px 6px` padding, which lies inside the body box, on all four sides.
+ The plate is the BODY rect (`lib/glyphGridNode.ts` `bodyPlateRect`, pushed on the
+ ResizeObserver's settled tick and carried along by the position effect during a drag). It is
+ deliberately NOT derived from the grid: cols×cellW rarely divides a body exactly, xterm
+ letterboxes the remainder, and nothing else paints it — a grid-sized plate is what left a band of
+ raw dot grid at the bottom and right of every terminal, and tens of pixels of it on a letterboxed
+ co-attach node. Being body-sized it also swallows the host's asymmetric `4px 2px 2px 6px`
+ padding on all four sides.
+
+ THIS FILE OWNS THE INVARIANT BEHIND THAT. What TerminalNode actually measures is
+ `.term-node__xterm` (the host), NOT `.term-node__body` — see `measurePlateRect` for the full
+ statement. The host's box equals the body's only because the rule below is `position: absolute;
+ inset: 0` and `.term-node__body` has NO padding and NO border. Add padding or a border to the
+ body, or stop the host being inset:0, and the plate silently under-covers again — the exact band
+ this design removed. Change either and the measurement must move to `.term-node__body`.
ONE accepted degradation is left, and it is Phase 2's call (a rounded / stencilled plate),
judged on the device checklist: the plate is a square rect while the node has border-radius