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): glyph in the open, DOM when stacked — the overlap rule the canvas can keep
enes010784714151
diff --git a/docs/superpowers/plans/2026-08-03-phase1b-device-checklist.md b/docs/superpowers/plans/2026-08-03-phase1b-device-checklist.mdindex 590864013..58026cfc0 100644--- a/docs/superpowers/plans/2026-08-03-phase1b-device-checklist.md+++ b/docs/superpowers/plans/2026-08-03-phase1b-device-checklist.md@@ -144,33 +144,32 @@ Auto after you switched builds, that is why: re-select Shared and carry on.- [ ] **3.8 Overlap occlusion.** Drag two terminals until they overlap: the one on top hides theone below — its text does not bleed through, and the lower one's text does not paint overthe upper node's chrome.-- [ ] **3.9 Selecting the LOWER of two overlapping terminals.** Click the partially-covered one.- **CHANGED in round 4:** clicking no longer raises it. While Shared is on, selection does not- elevate anything (`elevateNodesOnSelect={false}`) — whichever node is later in the array is on- top in BOTH the DOM and the canvas, selected or not. What you must confirm is that the two- agree: the selection ring appears on the lower node, its chrome stays under the upper node's,- and its text stays under the upper node's plate. The failure this replaced is the one to watch- for — the upper node's crisp chrome with the LOWER node's text legible through its body.- Bring a node to the front the ordinary way (drag it / re-create it) rather than by selecting.- Also check the flip itself: with a terminal SELECTED, toggle Shared on and then off. The- selection is cleared on each transition (deliberate — React Flow only recomputes z on a nodes- change, so the prop flip alone would leave that node stuck at z 1000), and no node is left- floating above the others afterwards.-- [ ] **3.9c Node-attached UI that escapes the node box (round 4).** On an overlapping canvas, open- the 💬 comments flyout on a terminal that another terminal overlaps, and look at a session- node carrying a kanban column half-pill. Both are positioned OUTSIDE their node's rect, and- with the elevation off they are no longer lifted above nodes later in the array — so either- may be partly covered by a neighbouring terminal, and selecting the node will not fix it.- That is the known trade (L15). Judge how often it actually bites: report the overlap depth at- which the flyout becomes unusable, if it does.-- [ ] **3.9b Overlap, contents vs frame (round 4).** With two terminals overlapping, look at the- covered region closely. Expected: the upper node's CONTENTS occlude the lower one's- completely — no text, no cursor, no selection band from the lower node is readable through- the upper node's body. The one artifact that REMAINS is **L15**: the lower node's thin- border/frame (and the hairline where its header meets its body) may ghost through the upper- node's transparent body window, because that chrome is DOM and the upper node's occluding- plate is canvas. A HAIRLINE is expected; **report anything more than a hairline** — a visible- band, a readable label, or any of the lower node's text — as a defect, not as L15.+- [ ] **3.9 Selecting / raising the LOWER of two overlapping terminals (REWRITTEN in round 5).**+ Round 4's trade — selection stopped elevating anything while Shared was on — is **REVERTED**.+ Selection elevation is back on in every renderer mode, and what changed instead is that a+ terminal which sits over another node **leaves the shared canvas** and renders on its own DOM+ renderer for as long as it is stacked (L15). Confirm the ordinary behaviour is ordinary:+ click the partially-covered terminal → it comes to the FRONT, chrome and contents together,+ and nothing of the node it now covers is visible through it. Click the other one → they swap,+ cleanly, with no intermediate frame in which both are legible in the same rectangle. Drag one+ over the other and back: the same, throughout the gesture and after it settles.+- [ ] **3.9c Node-attached UI that escapes the node box (round 5: the round-4 trade is GONE).** The+ 💬 comments flyout (`.term-node__comments`) and the kanban column half-pill (`ColumnPill`) are+ positioned OUTSIDE their node's rect. With selection elevation restored they are lifted with+ their node again, so: open a flyout on a terminal that another terminal overlaps, click the+ node — the flyout must come to the front with it and be fully readable and clickable. Same+ for a session node's column pill. Anything covered here is a defect now, not a known trade.+- [ ] **3.9b Overlap, the whole of it (round 5).** With two terminals overlapping, look at the+ covered region closely. Expected: the upper node hides the lower one **completely** — no text,+ no cursor, no selection band, **and no frame hairline**. Round 4's L15 ghost (the lower node's+ 1px border showing through the upper node's transparent body) is gone, because the upper node+ is not a transparent body any more: being stacked put it on the DOM renderer, opaque, with+ native stacking. **Report ANY trace of the lower node inside the upper node's box as a+ defect.** The expected tell that this is working is the opposite one: the upper node's text+ may look very slightly softer than its un-stacked neighbours' at zoom ≠ 1 (DOM renderer vs+ GPU glyphs). Note whether you can see that difference and how objectionable it is — that is+ the round-5 question. Also: move the nodes apart again and confirm the upper one goes BACK to+ the shared canvas (its text sharpens up) once they no longer overlap.- [ ] **3.10 Group-parented terminal.** A terminal inside a group frame: its text sits exactly inits body (offset chain resolves through the parent), and its paint order relative toungrouped terminals is sane (known limitation L7).@@ -305,8 +304,12 @@ Auto after you switched builds, that is why: re-select Shared and carry on.can land after it. Refreshing the node re-registers at the correct size.- **L7 — Group-parented z is an approximation.** The paint order is the node array order withselected nodes elevated (mirroring React Flow's `elevateNodesOnSelect`); React Flow additionally- gives a grouped node `parentZ + 1`, which the order signature does not model. Overlaps that mix- grouped and ungrouped terminals can therefore order differently from the DOM.+ gives a grouped node `parentZ + 1`, which `effectiveStackOrder` does not model. Overlaps that mix+ grouped and ungrouped terminals can therefore order differently from the DOM. Round 5 shrinks the+ blast radius rather than fixing it: a terminal that overlaps anything below it is off the shared+ canvas entirely (L15), so a mis-ordered pair of GRIDS needs both terminals to believe they are in+ the clear — and being wrong about the order there costs a trip to the DOM renderer, never a+ bleed-through, because the two rules read the same `effectiveStackOrder`.- **L8 — The kanban card modal stays on xterm's DOM renderer, by design in v1.** The modal is asecond, co-attached view of the same tmux session living outside the canvas' coordinate space;it has no grid, no camera and no z in the shared canvas. Board parity here is a Phase-2 question.@@ -342,32 +345,36 @@ Auto after you switched builds, that is why: re-select Shared and carry on.`warnOnCellDrift` logs one `[glyphgrid] atlas cell … does not match …` line per context lifetime,so a soft terminal can be told apart from a soft display. Phase 2 (re-rasterize on`document.fonts.ready` / per-cell atlas pages).-- **L15 — Where two terminals overlap, the LOWER one's frame can ghost through the upper one's- body.** A shared-mode terminal body is transparent — its text lives on the one shared canvas- underneath the node layer — so the upper node's occluding surface is its canvas PLATE, and a- plate is painted below all DOM chrome. Contents therefore occlude correctly (the upper plate is- drawn after the lower one, so no text, cursor or selection band from the lower node survives),- but the lower node's own chrome — its 1px border, the seam under its header — is DOM and paints- over the plate. What remains visible is a hairline of the lower node's frame inside the upper- node's body window. **This is the residue of a much worse bug, and the trade was deliberate.**- Before round 4 the DOM and the canvas ordered the nodes DIFFERENTLY: React Flow's- `elevateNodesOnSelect` lifted the selected node's chrome to z 1000 while the canvas painted grids- in the order Canvas pushed, so the two disagreed about which node was on top and the user saw one- node's crisp chrome with the OTHER node's text readable through it. Turning that prop off while- the layer is active (Canvas.tsx, `elevateNodesOnSelect={!glyphLayerActive}`) makes array order- the single rule on both sides; the hairline is what is left, and it cannot be removed by any- ordering because canvas can never paint over DOM. The two real fixes are Phase 2 questions: draw- the node frame into the shared canvas too, or give the plate the node's full chrome geometry.- Side effect to be aware of: **clicking a covered terminal no longer brings it to the front** in- shared mode (checklist 3.9) — selection is no longer a stacking input there. That reaches- node-attached UI that deliberately ESCAPES the node box, too: the 💬 comments flyout- (`.term-node__comments`, a sibling of the overflow:hidden root) and the kanban column half-pill- (`ColumnPill`, likewise a sibling) are positioned outside their node's rect, and with the- elevation off they are no longer lifted above nodes that sit LATER in the array — so on an- overlapping canvas a flyout or a pill can be partly covered by a neighbouring terminal, and- selecting its node no longer fixes it. Both are transient, node-attached surfaces rather than- content, which is why this ships; the Phase-2 fix is the one L15 already needs (make chrome and- canvas agree for real, instead of turning one of the two orderings off).+- **L15 — A terminal that is STACKED OVER another node temporarily leaves the shared renderer.**+ (Rewritten in round 5. The round-4 entry — a hairline of the lower node's frame ghosting through+ the upper node's transparent body, plus "selection no longer raises a covered node" — described a+ trade that was **rejected** and no longer exists.)++ The structural fact: one canvas cannot interleave itself with per-node DOM stacking. A shared-mode+ terminal is a transparent WINDOW whose text lives on a canvas UNDER the whole node layer, so its+ only occluding surface is its grid's plate — also under every node's chrome. It can hide another+ node's canvas text (plate over plate) but never that node's border, header seam or label pill,+ which paint straight through. No z-ordering in either world fixes this.++ Round 4 tried to make the two orders agree by turning `elevateNodesOnSelect` off in shared mode.+ That worked and cost too much: dragging or selecting a node stopped bringing it to the front, and+ the frame hairline remained anyway. Round 5 replaces it with **"glyph in the open, DOM when+ stacked"**: a terminal renders through the shared canvas only while its body sits over empty+ canvas. The moment it could reveal a node beneath it, it hands the grid back and renders on+ xterm's own DOM renderer — opaque body, native stacking, total occlusion. The rule is+ `opaqueNodeIds` (`canvas/SharedGlyphLayer.tsx`): OPAQUE when the node's rect intersects the rect+ of any node BELOW it in the effective paint order, or while it is being dragged. A terminal that+ is only UNDERNEATH others stays on the canvas — the opaque node above hides it natively.+ Selection elevation is back on everywhere, and the frame ghost is gone with the transparency that+ caused it.++ **What remains, and what to watch for on device:** a stacked terminal is on the DOM renderer for+ as long as it is stacked, so its text is very slightly softer than its neighbours' at zoom ≠ 1+ (checklist 3.9b). The switch itself is the existing teardown/setup machinery that collapse and ⌘M+ already use, so it also costs one renderer swap per transition; the opaque set is frozen while+ anything is dragging so a neighbour cannot be swapped twice a frame. Phase 2's answer if the DOM+ fallback turns out to be frequent enough to matter is a SECOND canvas above the node layer for an+ elevated tier — the two-tier design this envelope deliberately defers.---diff --git a/src/renderer/canvas/Canvas.tsx b/src/renderer/canvas/Canvas.tsxindex abbc92f7b..f9e9f58af 100644--- a/src/renderer/canvas/Canvas.tsx+++ b/src/renderer/canvas/Canvas.tsx@@ -32,7 +32,9 @@ import {SharedGlyphLayer,idsFromOrderSig,nodeOrderSig,+ opaqueNodeIds,setNodeZOrder,+ setOpaqueNodeIds,setSharedGlyphCamera,useSharedGlyphActive} from './SharedGlyphLayer'@@ -4963,15 +4965,15 @@ export function Canvas() {}, [nodes, markDirty])// ---- glyphgrid (experimental shared renderer) ----- // Both feeds below are INERT unless the resolved renderer mode is 'shared': the hook returns- // false for every user today, the signature memo short-circuits on it, and setSharedGlyphCamera- // is a field write plus a null check when no engine exists.+ // Every feed below is INERT unless the resolved renderer mode is 'shared': the hook returns+ // false for every user today, the signature memo and the opaque-set effect short-circuit on it,+ // and setSharedGlyphCamera is a field write plus a null check when no engine exists.const glyphLayerActive = useSharedGlyphActive()- // The terminal nodes' paint order IS the grids' z order — plain ARRAY order, which is exactly- // what the DOM does too while the layer is on (see `elevateNodesOnSelect` on <ReactFlow> below- // for the invariant that ties the two together). `nodeOrderSig` owns the rule. One string so the- // effect below fires on a real order change only — a drag or an edit rebuilds `nodes` many times- // per second with the order untouched.+ // The terminal nodes' paint order IS the grids' z order — array order with SELECTED nodes last,+ // mirroring React Flow's own `elevateNodesOnSelect` (which stays at its default in every mode).+ // `nodeOrderSig` owns the rule and explains why mirroring is safe again. One string so the effect+ // below fires on a real order change only — a drag or an edit rebuilds `nodes` many times per+ // second with the order untouched.const glyphOrderSig = useMemo(() => (glyphLayerActive ? nodeOrderSig(nodes) : ''),[glyphLayerActive, nodes]@@ -4980,21 +4982,27 @@ export function Canvas() {setNodeZOrder(idsFromOrderSig(glyphOrderSig))}, [glyphOrderSig])- // Flipping the mode changes `elevateNodesOnSelect`, but React Flow computes a node's z only in- // `adoptUserNodes` — which runs on a NODES change, not on a prop change. So a node that happens- // to be selected at the moment of the flip keeps the z 1000 it was given under the old prop, and- // stays wrongly on top (in the DOM only) until something else touches the nodes array. Clearing- // the selection is the minimal correct nudge: it is a real nodes change, so every node is- // re-adopted under the new rule, and it costs the user nothing (selection is not a stacking input- // in shared mode anyway — see L15). Change-gated on both the transition and on anything actually- // being selected, and skipped on mount so a project load's restored selection survives.- const prevGlyphActiveRef = useRef<boolean | null>(null)+ // The OPAQUE SET: which terminals must leave the shared canvas and paint their own pixels right+ // now, because their transparent body would otherwise reveal a node stacked beneath them. The+ // rule, and why it is the rule, is documented at `opaqueNodeIds`.+ //+ // WHEN it runs is this effect's job, and there is exactly one subtlety: it is FROZEN while any+ // node is being dragged. `nodes` is rebuilt every frame of a drag, and recomputing there would+ // flip the dragged node's neighbours between the two renderers at 60 Hz — each flip is a real+ // xterm renderer swap, which is both jank and a chance to land blank. Nothing is lost by+ // waiting: the DRAGGED node needs nothing from this set (TerminalNode reads React Flow's own+ // `dragging` prop and goes DOM for the whole gesture, so it occludes correctly the entire time),+ // and the drag's settle is itself a nodes change, so the set is recomputed exactly once, at rest.+ // Same cadence as the order signature above — this effect adds one `some()` per nodes change and+ // an O(n²) rect sweep per SETTLED change, over a node count that is tens.useEffect(() => {- const prev = prevGlyphActiveRef.current- prevGlyphActiveRef.current = glyphLayerActive- if (prev === null || prev === glyphLayerActive) return- setNodes((ns) => (ns.some((n) => n.selected) ? ns.map((n) => ({ ...n, selected: false })) : ns))- }, [glyphLayerActive, setNodes])+ if (!glyphLayerActive) {+ setOpaqueNodeIds([])+ return+ }+ if (nodes.some((n) => n.dragging)) return+ setOpaqueNodeIds(opaqueNodeIds(nodes))+ }, [glyphLayerActive, nodes])const zoomRafRef = useRef<number | null>(null)const gestureSettleRef = useRef<ReturnType<typeof setTimeout> | null>(null)@@ -7507,22 +7515,6 @@ export function Canvas() {zoomActivationKeyCode={null}snapToGrid={settings.snapToGrid}snapGrid={[settings.gridSize, settings.gridSize]}- // INVARIANT (shared glyph layer): the shared canvas can only paint in ONE global order,- // so every DOM stacking rule that diverges from array order — `elevateNodesOnSelect`,- // React Flow's default-on lift of the selected node to z 1000, is the only one we use —- // must be disabled while the shared layer is on, or chrome and text disagree about who- // is on top. That disagreement is not cosmetic: a shared-mode terminal body is- // TRANSPARENT (the glyphs are on the canvas underneath), so with the two orders split- // the user sees the upper node's opaque chrome AND the lower node's text through the- // same rectangle — "this node is on top, and I can read the other one through it".- // Mirroring the elevation in `nodeOrderSig` (what round 3 did) cannot fix it, because- // canvas text can never paint over DOM chrome; only agreeing on array order can.- // Dynamic, and false ONLY while shared is active: the default renderer modes have opaque- // bodies and keep React Flow's normal selection behavior, untouched. Flipping this prop- // is NOT enough on its own — React Flow assigns z in `adoptUserNodes`, which runs on a- // nodes change — so the effect above clears the selection on the transition to force a- // re-adopt; without it a node selected at the moment of the flip keeps z 1000.- elevateNodesOnSelect={!glyphLayerActive}><Backgroundvariant={BackgroundVariant.Dots}diff --git a/src/renderer/canvas/SharedGlyphLayer.test.ts b/src/renderer/canvas/SharedGlyphLayer.test.tsindex fb6d74ce4..7c8fdc0c4 100644--- a/src/renderer/canvas/SharedGlyphLayer.test.ts+++ b/src/renderer/canvas/SharedGlyphLayer.test.ts@@ -3,14 +3,19 @@ import {failSharedGlyph,getSharedGlyphContext,idsFromOrderSig,+ nodeIsOpaque,nodeOrderSig,nodeZFor,+ opaqueNodeIds,setNodeZOrder,+ setOpaqueNodeIds,setSharedGlyphCamera,sharedGlyphActive,sharedGlyphAvailable,subscribeNodeZOrder,- useSharedGlyph+ subscribeOpaqueSet,+ useSharedGlyph,+ type StackedNode} from './SharedGlyphLayer'// Only the PURE parts are unit-testable here: there is no WebGL2, no OffscreenCanvas and no@@ -24,6 +29,7 @@ beforeEach(() => {// order-independent.useSharedGlyph.setState({ enabled: false, generation: 0, failed: false })setNodeZOrder([])+ setOpaqueNodeIds([])})describe('nodeOrderSig', () => {@@ -58,35 +64,46 @@ describe('nodeOrderSig', () => {expect(a).not.toBe(b)})- it('does NOT elevate a selected terminal — selection is not a stacking input here', () => {- // Round 3 sorted selected nodes last, mirroring React Flow's elevateNodesOnSelect. Round 4- // turns that PROP off while the shared layer is active (Canvas.tsx) instead, because the DOM- // and the canvas have to agree on ONE order: a selected node whose grid was on top but whose- // chrome sat under its neighbour's showed both nodes' contents in the same rectangle. With the- // elevation disabled, array order is the whole rule on both sides.+ it('elevates a SELECTED terminal above the unselected ones, wherever it sits in the array', () => {+ // React Flow's elevateNodesOnSelect (default on, and now on in EVERY renderer mode) lifts the+ // selected node's DOM to z 1000; the grids mirror it so canvas and DOM tell the same story.+ // Round 4 removed the mirroring and turned the prop off instead — rejected in round 5, because+ // that takes away "selecting/dragging brings a node to the front". The overlap it was trying to+ // fix is handled by `opaqueNodeIds` (a stacked terminal leaves the canvas entirely) instead.const sig = nodeOrderSig([{ id: 'a', type: 'terminal' },{ id: 'b', type: 'terminal', selected: true },{ id: 'c', type: 'terminal' }])- expect(idsFromOrderSig(sig)).toEqual(['a', 'b', 'c'])+ expect(idsFromOrderSig(sig)).toEqual(['a', 'c', 'b'])})- it('a multi-select changes nothing at all', () => {+ it('keeps selected nodes in their own relative order (a multi-select is stable)', () => {const sig = nodeOrderSig([{ id: 'a', type: 'terminal', selected: true },{ id: 'b', type: 'terminal' },{ id: 'c', type: 'terminal', selected: true }])- expect(idsFromOrderSig(sig)).toEqual(['a', 'b', 'c'])+ expect(idsFromOrderSig(sig)).toEqual(['b', 'a', 'c'])})- it('selecting and deselecting does not churn the signature (no needless z re-push)', () => {- const nodes = [- { id: 'a', type: 'terminal' },- { id: 'b', type: 'terminal' }- ]- expect(nodeOrderSig(nodes)).toBe(nodeOrderSig(nodes.map((n) => ({ ...n, selected: true }))))+ it('an all-selected canvas keeps plain array order', () => {+ const sig = nodeOrderSig([+ { id: 'a', type: 'terminal', selected: true },+ { id: 'b', type: 'terminal', selected: true }+ ])+ expect(idsFromOrderSig(sig)).toEqual(['a', 'b'])+ })++ it('a selected NON-terminal does not reorder the terminals', () => {+ // The elevation is applied over ALL nodes (that is what the DOM does) and terminals are+ // filtered out of the result afterwards — so a selected sticky must be invisible here.+ const sig = nodeOrderSig([+ { id: 't1', type: 'terminal' },+ { id: 's1', type: 'sticky', selected: true },+ { id: 't2', type: 'terminal' }+ ])+ expect(idsFromOrderSig(sig)).toEqual(['t1', 't2'])})it('an untyped node is not a terminal (React Flow defaults type to "default")', () => {@@ -259,6 +276,181 @@ describe('setNodeZOrder', () => {})})+describe('opaqueNodeIds', () => {+ /** A 100×100 node at (x, y). Sizes come through `measured` (a live canvas) unless overridden. */+ const at = (+ id: string,+ x: number,+ y: number,+ extra: Partial<StackedNode> = {}+ ): StackedNode => ({+ id,+ type: 'terminal',+ position: { x, y },+ measured: { width: 100, height: 100 },+ ...extra+ })++ it('leaves a terminal that overlaps nothing on the shared canvas', () => {+ expect(opaqueNodeIds([at('a', 0, 0), at('b', 200, 0)])).toEqual([])+ })++ it('marks the UPPER terminal of an overlapping pair, and only it', () => {+ // The lower one may stay on the canvas: the opaque node above hides it natively, which is the+ // asymmetry the whole design rests on.+ expect(opaqueNodeIds([at('low', 0, 0), at('high', 50, 50)])).toEqual(['high'])+ })++ it('a terminal stacked over a NON-terminal node counts too', () => {+ // "Reveals another node" is about any kind — a sticky's text under a transparent body is the+ // same defect as a terminal's.+ const nodes = [at('note', 0, 0, { type: 'sticky' }), at('t', 20, 20)]+ expect(opaqueNodeIds(nodes)).toEqual(['t'])+ })++ it('follows the SELECTION elevation, not raw array order', () => {+ // Selecting the lower node lifts it above its neighbour in the DOM, so it is now the one whose+ // body could reveal something — and the neighbour is free to go back on the canvas.+ const nodes = [at('a', 0, 0, { selected: true }), at('b', 50, 50)]+ expect(opaqueNodeIds(nodes)).toEqual(['a'])+ expect(opaqueNodeIds([at('a', 0, 0), at('b', 50, 50)])).toEqual(['b'])+ })++ it('edge-to-edge nodes are not overlapping', () => {+ // A snapped grid or a tidy row shares boundaries everywhere; treating that as an overlap would+ // send half a neat canvas to the DOM renderer.+ expect(opaqueNodeIds([at('a', 0, 0), at('b', 100, 0)])).toEqual([])+ })++ it('does NOT count a node\'s own group frame as something beneath it', () => {+ // A grouped terminal is inside its frame's rect by construction. Counting it would put every+ // grouped terminal on the DOM renderer permanently.+ const group: StackedNode = {+ id: 'g',+ type: 'group',+ position: { x: 0, y: 0 },+ measured: { width: 400, height: 400 }+ }+ const child = at('t', 20, 20, { parentId: 'g' })+ expect(opaqueNodeIds([group, child])).toEqual([])+ })++ it('counts an UNRELATED group frame beneath it', () => {+ const group: StackedNode = {+ id: 'g',+ type: 'group',+ position: { x: 0, y: 0 },+ measured: { width: 400, height: 400 }+ }+ expect(opaqueNodeIds([group, at('t', 20, 20)])).toEqual(['t'])+ })++ it('resolves a grouped node\'s position through its parent chain', () => {+ // The child's own `position` is frame-relative: read raw it would sit at (10,10) and miss the+ // terminal it actually covers at (510,510).+ const group: StackedNode = {+ id: 'g',+ type: 'group',+ position: { x: 500, y: 500 },+ measured: { width: 400, height: 400 }+ }+ // `out` is placed BEFORE the frame so it is beneath everything and cannot be marked itself —+ // the assertion is about the child's resolved position and nothing else.+ const outside = at('out', 510, 510)+ const child = at('t', 10, 10, { parentId: 'g' })+ expect(opaqueNodeIds([outside, group, child])).toEqual(['t'])+ })++ it('ignores collapsed and ⌘M terminals — they hold no grid either way', () => {+ expect(opaqueNodeIds([at('a', 0, 0), at('b', 50, 50, { data: { collapsed: true } })])).toEqual(+ []+ )+ expect(opaqueNodeIds([at('a', 0, 0), at('b', 50, 50, { data: { mdMode: true } })])).toEqual([])+ })++ it('a collapsed terminal is still something to be stacked OVER', () => {+ // It is an opaque header strip on screen; covering it is a real overlap.+ const nodes = [at('c', 0, 0, { data: { collapsed: true } }), at('t', 50, 50)]+ expect(opaqueNodeIds(nodes)).toEqual(['t'])+ })++ it('falls back to width/height when React Flow has not measured the node yet', () => {+ const a: StackedNode = { id: 'a', type: 'terminal', position: { x: 0, y: 0 }, width: 100, height: 100 }+ const b: StackedNode = { id: 'b', type: 'terminal', position: { x: 50, y: 50 }, width: 100, height: 100 }+ expect(opaqueNodeIds([a, b])).toEqual(['b'])+ })++ it('a node of unknowable size contributes nothing, in either direction', () => {+ const sizeless: StackedNode = { id: 'x', type: 'terminal', position: { x: 0, y: 0 } }+ expect(opaqueNodeIds([sizeless, at('t', 10, 10)])).toEqual([])+ expect(opaqueNodeIds([at('t', 10, 10), sizeless])).toEqual([])+ })++ it('survives a parentId cycle instead of spinning', () => {+ const a = at('a', 0, 0, { parentId: 'b' })+ const b = at('b', 0, 0, { parentId: 'a' })+ expect(() => opaqueNodeIds([a, b])).not.toThrow()+ })++ it('reports every stacked terminal on a pile, not just the top one', () => {+ expect(opaqueNodeIds([at('a', 0, 0), at('b', 20, 20), at('c', 40, 40)])).toEqual(['b', 'c'])+ })+})++describe('setOpaqueNodeIds', () => {+ it('answers membership', () => {+ setOpaqueNodeIds(['a', 'b'])+ expect(nodeIsOpaque('a')).toBe(true)+ expect(nodeIsOpaque('c')).toBe(false)+ })++ it('notifies subscribers when the set changes', () => {+ const seen = vi.fn()+ const unsub = subscribeOpaqueSet(seen)+ setOpaqueNodeIds(['a'])+ setOpaqueNodeIds(['a', 'b'])+ expect(seen).toHaveBeenCalledTimes(2)+ unsub()+ })++ it('does NOT notify when the same MEMBERSHIP arrives in a different order', () => {+ // This is a set, not a sequence: a node reorder that changes nothing about who overlaps whom+ // must not wake every terminal on the canvas.+ setOpaqueNodeIds(['a', 'b'])+ const seen = vi.fn()+ const unsub = subscribeOpaqueSet(seen)+ setOpaqueNodeIds(['b', 'a'])+ expect(seen).not.toHaveBeenCalled()+ unsub()+ })++ it('does NOT notify when the same set is pushed again', () => {+ setOpaqueNodeIds(['a', 'b'])+ const seen = vi.fn()+ const unsub = subscribeOpaqueSet(seen)+ setOpaqueNodeIds(['a', 'b'])+ expect(seen).not.toHaveBeenCalled()+ unsub()+ })++ it('clears back to empty and notifies once', () => {+ setOpaqueNodeIds(['a'])+ const seen = vi.fn()+ const unsub = subscribeOpaqueSet(seen)+ setOpaqueNodeIds([])+ expect(seen).toHaveBeenCalledTimes(1)+ expect(nodeIsOpaque('a')).toBe(false)+ unsub()+ })++ it('stops notifying after unsubscribe', () => {+ const seen = vi.fn()+ subscribeOpaqueSet(seen)()+ setOpaqueNodeIds(['z'])+ expect(seen).not.toHaveBeenCalled()+ })+})+describe('graceful degrade without a GPU', () => {/** A plausible xterm device cell (13px font at dpr 2): fractional width, integer height. */const CELL = { cellW: 15.66, cellH: 31 }diff --git a/src/renderer/canvas/SharedGlyphLayer.tsx b/src/renderer/canvas/SharedGlyphLayer.tsxindex 168092a9e..d78233fb0 100644--- a/src/renderer/canvas/SharedGlyphLayer.tsx+++ b/src/renderer/canvas/SharedGlyphLayer.tsx@@ -16,9 +16,11 @@* `failSharedGlyph()`: warn once, tear the context down, and flip the store's `failed` — the* session-level "everyone back to the DOM renderer" signal that TerminalNode reads.* 3. **The seams the rest of the integration reads**: `useSharedGlyph` (mode + generation +- * failure), `setNodeZOrder`/`nodeZFor`/`subscribeNodeZOrder` (paint order), and- * `setSharedGlyphCamera` (pan/zoom). Every one of them is a no-op while no context exists, so- * Canvas can call them unconditionally and a default-mode user pays a null check.+ * failure), `setNodeZOrder`/`nodeZFor`/`subscribeNodeZOrder` (paint order),+ * `setOpaqueNodeIds`/`nodeIsOpaque`/`subscribeOpaqueSet` (which terminals must leave the shared+ * canvas — see the stacking rule above that set), and `setSharedGlyphCamera` (pan/zoom). Every+ * one of them is a no-op while no context exists, so Canvas can call them unconditionally and a+ * default-mode user pays a null check.** The component and the GL singleton have NO unit tests by design — there is no WebGL2, no* OffscreenCanvas and no layout in vitest's node environment. The pure parts (order signature,@@ -179,6 +181,37 @@ let zOrder = new Map<string, number>()let zOrderSig = ''const zListeners = new Set<() => void>()+/**+ * The order React Flow actually PAINTS the nodes in: array order, with selected nodes moved to+ * the end (stable within each of the two groups). That is `elevateNodesOnSelect` — on by default,+ * and the only DOM stacking rule this app uses that diverges from array order.+ *+ * ONE function, because two consumers must never disagree about it: `nodeOrderSig` (the grids' z)+ * and `opaqueNodeIds` (which terminals may stay on the shared canvas at all). If the opaque set+ * were derived from a different order than the z, a terminal could be told it is in the clear by+ * one rule and painted underneath by the other — the mixed-order soup of round 4, reintroduced+ * one level down.+ *+ * Approximation, deliberately: React Flow also gives a group frame's children a z above the frame+ * itself, and honours an explicit `zIndex`, neither of which we set. `opaqueNodeIds` is written so+ * that being wrong here costs a terminal a trip to the DOM renderer, never a bleed-through.+ */+export function effectiveStackOrder<T extends { selected?: boolean }>(+ nodes: readonly T[]+): readonly T[] {+ let elevated: T[] | null = null+ for (const n of nodes) {+ if (!n.selected) continue+ if (!elevated) elevated = []+ elevated.push(n)+ }+ // Nothing selected — the overwhelmingly common case — is the input array itself, no copy.+ if (!elevated) return nodes+ const base: T[] = []+ for (const n of nodes) if (!n.selected) base.push(n)+ return base.concat(elevated)+}+/*** The paint order of the TERMINAL nodes, as one string. Canvas recomputes it per nodes change and* only pushes when it differs — a string compare instead of an array diff, the same trick the@@ -187,28 +220,29 @@ const zListeners = new Set<() => void>()* Only terminals: they are the only kind that registers a grid, and mixing other kinds in would* churn the signature on every sticky edit.*- * **The rule is plain ARRAY order, and nothing else.** It used to mirror React Flow's- * `elevateNodesOnSelect` by sorting selected nodes last, because that prop (on by default) lifts a- * selected node's DOM z-index to 1000 wherever it sits in the array. Mirroring it fixed one half of- * the overlap and created the other: the shared canvas paints in ONE global order, so with the- * selected node's grid on top, its text correctly occluded the neighbour's text — while the- * neighbour's opaque DOM chrome still sat over the selected node's TRANSPARENT body. The user saw- * crisp chrome from one node and the other node's text through it, in the same rectangle. There is- * no ordering of the grids that fixes that, because canvas text can never paint over DOM chrome.+ * **The rule is `effectiveStackOrder` — array order, with SELECTED nodes last** — because that is+ * what the DOM does: React Flow's `elevateNodesOnSelect` is on by default and lifts a selected+ * node's z-index to 1000 wherever it sits in the array. The canvas z among the glyph grids mirrors+ * the DOM elevation, so both worlds tell the same story about who is on top.+ *+ * Round 4 removed the mirroring and turned the PROP off instead. That was the wrong end of the+ * problem: it did make the two orders agree, but at the cost of "click/drag brings a node to the+ * front", which the user rejected outright. Round 5 fixes the overlap where it actually lives —+ * a terminal whose transparent body could reveal a node BENEATH it leaves the shared canvas and+ * paints itself on its own DOM renderer (`opaqueNodeIds` below). With every overlapping-top+ * terminal off the canvas, no two grids can be in the configuration this signature used to be+ * blamed for, so mirroring the elevation is free again.*- * The fix is upstream: while the shared layer is active Canvas passes `elevateNodesOnSelect={false}`- * so the DOM follows the array too, and both worlds agree that "later in the array is on top". The- * elevation this function existed to mirror no longer happens in the only mode that reads this- * signature, so the selection-awareness is gone with it — see the invariant at that prop.+ * It matters mainly for TRANSIENT states — the frames between an overlap starting and the opaque+ * set being recomputed, and the frames after it clears — since a terminal that is durably stacked+ * over something is on the DOM renderer and owns no grid at all. Those are precisely the frames in+ * which a wrong z is visible, which is why the mirroring is worth its handful of lines.*/-// `selected` is still in the accepted shape and deliberately unread: it says out loud that the-// signature SEES the selection and chooses to ignore it, which is the thing a future reader is-// most likely to try to "fix" back.export function nodeOrderSig(nodes: readonly { id: string; type?: string; selected?: boolean }[]): string {let sig = ''- for (const n of nodes) {+ for (const n of effectiveStackOrder(nodes)) {if (n.type !== 'terminal') continuesig = sig === '' ? n.id : sig + ORDER_SEP + n.id}@@ -249,6 +283,184 @@ export function subscribeNodeZOrder(fn: () => void): () => void {}}+// ---------------------------------------------------------------------------------------------+// The opaque set — "glyph in the open, DOM when stacked"+// ---------------------------------------------------------------------------------------------++/**+ * THE STACKING RULE OF THE SHARED RENDERER, and the thing to read before touching any of this.+ *+ * A shared-mode terminal is a TRANSPARENT WINDOW: its body has no background, its text lives on+ * the one canvas that sits UNDER the whole node layer, and the only thing it puts between itself+ * and whatever is behind it is its grid's opaque plate — which is also on that canvas, i.e. also+ * under every node's DOM chrome. So a glyph terminal cannot occlude a node beneath it the way an+ * ordinary node does. It can hide the node's canvas TEXT (plate over plate) but never its chrome:+ * the border, the header seam, a label pill all paint straight through.+ *+ * There is no z-ordering that fixes that, in either world — one canvas cannot interleave itself+ * with per-node DOM stacking. Round 4 tried to make the two orders agree by taking selection+ * elevation away; that removed "click/drag brings it to the front", which is not negotiable.+ *+ * Round 5's rule instead: **a terminal renders through the shared canvas only while it is in the+ * open.** The moment its body could reveal something underneath, it drops the grid and goes back+ * to xterm's own DOM renderer — opaque body, native stacking, total occlusion. Concretely a+ * terminal is OPAQUE (DOM) when either holds:+ *+ * a) its rect intersects the rect of ANY node — of any kind — that is BELOW it in the effective+ * paint order (`effectiveStackOrder`), or+ * b) it is being DRAGGED (TerminalNode reads React Flow's own `dragging` prop for this, not this+ * set — a drag is about to put the node above things, and the flag flips synchronously so the+ * visuals are right for the whole gesture rather than one recompute late).+ *+ * A terminal that is only UNDERNEATH others stays on the canvas: the opaque node above it hides it+ * natively, which is the case this whole design leans on. The cost is that a stacked terminal is+ * rendered by the DOM renderer for as long as it is stacked — its text is very slightly softer at+ * zoom ≠ 1 than its neighbours', which is the expected tell, not a defect.+ *+ * Two deliberate exclusions from "below it":+ * - **A node's own ANCESTOR chain.** Every grouped terminal sits inside its group frame's rect by+ * construction; counting that as an overlap would put every grouped terminal on the DOM+ * renderer forever, which would gut the feature on the canvases most likely to use it.+ * - **Nodes with unknowable geometry** (no `measured`, no `width`/`height` — the tick before+ * React Flow has measured a fresh node). They contribute nothing in either direction, and the+ * measurement lands as an ordinary nodes change that recomputes the set.+ *+ * Known gap, small and stated rather than papered over: the EPHEMERAL subagent/loop cards are+ * merged into React Flow at the `<ReactFlow>` prop and are not in Canvas's `nodes` array, so they+ * are invisible to this rule. They are display-only cards that live for the length of one turn.+ */++/** Node shape this derivation reads. Loose on purpose: it must accept a live measured node and a+ * freshly deserialized one (`width`/`height`, no `measured`) alike. */+export interface StackedNode {+ id: string+ type?: string+ selected?: boolean+ position: { x: number; y: number }+ parentId?: string+ width?: number | null+ height?: number | null+ measured?: { width?: number | null; height?: number | null }+ data?: { collapsed?: unknown; mdMode?: unknown }+}++interface StackRect {+ x: number+ y: number+ w: number+ h: number+}++/** A `parentId` chain longer than this is a data bug (or a cycle) — stop walking. Same constant,+ * same reason, as `lib/nodeFocus`. */+const MAX_PARENT_DEPTH = 20++const positiveSize = (v: unknown): number | null =>+ typeof v === 'number' && Number.isFinite(v) && v > 0 ? v : null++/** The node's rect in ABSOLUTE canvas coordinates (a grouped node's `position` is relative to its+ * frame, so the parent chain is walked), or null when its size is not knowable yet. */+function absoluteRect(node: StackedNode, byId: Map<string, StackedNode>): StackRect | null {+ const w = positiveSize(node.measured?.width) ?? positiveSize(node.width)+ const h = positiveSize(node.measured?.height) ?? positiveSize(node.height)+ if (w === null || h === null) return null+ let { x, y } = node.position+ let parentId = node.parentId+ const seen = new Set<string>([node.id])+ for (let depth = 0; parentId && depth < MAX_PARENT_DEPTH; depth++) {+ if (seen.has(parentId)) break+ seen.add(parentId)+ const parent = byId.get(parentId)+ if (!parent) break+ x += parent.position.x+ y += parent.position.y+ parentId = parent.parentId+ }+ return { x, y, w, h }+}++/** Strictly overlapping AREA. Edge-to-edge nodes (a snapped grid, a tidy row) share a boundary and+ * nothing else — treating that as an overlap would send half a neat canvas to the DOM renderer. */+function rectsOverlap(a: StackRect, b: StackRect): boolean {+ return a.x < b.x + b.w && b.x < a.x + a.w && a.y < b.y + b.h && b.y < a.y + a.h+}++/** Whether `ancestorId` is on `node`'s parent chain — see the exclusion note above. */+function isAncestorOf(node: StackedNode, ancestorId: string, byId: Map<string, StackedNode>): boolean {+ let parentId = node.parentId+ const seen = new Set<string>([node.id])+ for (let depth = 0; parentId && depth < MAX_PARENT_DEPTH; depth++) {+ if (parentId === ancestorId) return true+ if (seen.has(parentId)) return false+ seen.add(parentId)+ parentId = byId.get(parentId)?.parentId+ }+ return false+}++/**+ * The terminals that must render on their OWN (opaque, DOM) renderer right now, by the rule+ * documented above. Pure — Canvas owns WHEN to run it (see the settle gate there), this owns what+ * the answer is.+ *+ * Collapsed / ⌘M terminals are left out: they hold no grid either way, so naming them here would+ * only churn the pushed signature. They still count as nodes something else can be stacked over —+ * a collapsed terminal is an opaque header strip, and covering one is a real overlap.+ */+export function opaqueNodeIds(nodes: readonly StackedNode[]): string[] {+ const order = effectiveStackOrder(nodes)+ const byId = new Map<string, StackedNode>()+ for (const n of nodes) byId.set(n.id, n)+ const rects = order.map((n) => absoluteRect(n, byId))+ const out: string[] = []+ for (let i = 0; i < order.length; i++) {+ const node = order[i]+ if (node.type !== 'terminal') continue+ if (node.data?.collapsed || node.data?.mdMode) continue+ const rect = rects[i]+ if (!rect) continue+ for (let j = 0; j < i; j++) {+ const below = rects[j]+ if (!below || !rectsOverlap(rect, below)) continue+ if (isAncestorOf(node, order[j].id, byId)) continue+ out.push(node.id)+ break+ }+ }+ return out+}++let opaqueIds = new Set<string>()+let opaqueSig = ''+const opaqueListeners = new Set<() => void>()++/**+ * Publish the opaque set. Change-gated on a SORTED signature — this is a set, not a sequence, so+ * the same membership arriving in a different order (a node reorder that changes nothing about who+ * overlaps whom) must not wake every terminal on the canvas.+ */+export function setOpaqueNodeIds(ids: readonly string[]): void {+ const sig = [...ids].sort().join(ORDER_SEP)+ if (sig === opaqueSig) return+ opaqueSig = sig+ opaqueIds = new Set(ids)+ for (const fn of opaqueListeners) fn()+}++/** Must this node paint its own pixels right now? Always false while nothing has been pushed,+ * which is every default-mode session. */+export function nodeIsOpaque(id: string): boolean {+ return opaqueIds.has(id)+}++/** Terminals subscribe here and re-read `nodeIsOpaque` — same lifecycle as the z subscription. */+export function subscribeOpaqueSet(fn: () => void): () => void {+ opaqueListeners.add(fn)+ return () => {+ opaqueListeners.delete(fn)+ }+}+// ---------------------------------------------------------------------------------------------// The engine singleton// ---------------------------------------------------------------------------------------------diff --git a/src/renderer/nodes/TerminalNode.tsx b/src/renderer/nodes/TerminalNode.tsxindex 2ac6af82e..d6c11ed53 100644--- a/src/renderer/nodes/TerminalNode.tsx+++ b/src/renderer/nodes/TerminalNode.tsx@@ -58,10 +58,12 @@ import { attachGlyphGrid, type GlyphGridAttachment } from '../terminal/glyphgridimport type { GridHandle } from '../glyphgrid/engine'import {getSharedGlyphContext,+ nodeIsOpaque,nodeZFor,sharedGlyphActive,sharedGlyphAvailable,subscribeNodeZOrder,+ subscribeOpaqueSet,useSharedGlyph} from '../canvas/SharedGlyphLayer'import {@@ -474,6 +476,11 @@ export function TerminalNode({data,selected,parentId,+ // True for the whole of a node drag, flipped synchronously by React Flow at gesture start and+ // end. Read only by the glyphgrid participation decision below (a dragged terminal is about to+ // be above other nodes, so it renders its OWN opaque pixels for the gesture); every other+ // renderer mode destructures it and never looks at it again.+ dragging,// React Flow's own absolute position (a group parent's chain already resolved), updated per// frame during a drag. Read only by the glyphgrid origin sync below; for every other renderer// mode these two are destructured and never looked at again.@@ -558,6 +565,19 @@ export function TerminalNode({// to move the RE-SETUP out of the (synchronous) generation notification and into an effect that// runs after the font options have reached xterm — see the participation effect below.const [glyphEpoch, setGlyphEpoch] = useState(0)+ // Is this node in the shared layer's OPAQUE SET — i.e. does its body currently sit over another+ // node, so that a transparent glyph window would let that node show through? Pushed by Canvas+ // and read back here; see the stacking rule at `opaqueNodeIds`. Always false while the shared+ // layer is off (nothing is ever pushed), so the subscription below costs a default-mode session+ // one Set insert per terminal and no renders at all.+ const [glyphOpaque, setGlyphOpaque] = useState(() => nodeIsOpaque(id))+ useEffect(() => {+ const read = (): void => setGlyphOpaque(nodeIsOpaque(id))+ // Read once on (re-)subscribe: the set can have been pushed between this node's render and+ // this effect, and nothing would notify us about a change we were not yet listening for.+ read()+ return subscribeOpaqueSet(read)+ }, [id])const [mdHtml, setMdHtml] = useState('')const [editingTitle, setEditingTitle] = useState(false)const hoveredRef = useRef(false)@@ -596,11 +616,26 @@ export function TerminalNode({const skipBlurRef = useRef(false)const mdMode = !!data.mdModeconst collapsed = !!data.collapsed- // "This node's terminal is not on screen right now": collapsed hides the body outright- // (`display: none`), the ⌘M view covers it with an opaque panel. A glyph grid left registered- // through either would keep painting its last frame on the shared canvas at the node's world- // rect, with nothing of ours in front of it. Mirrored into a ref for the lifecycle effect's- // closures (which cannot see fresh props).+ // "This node must NOT hold a grid on the shared canvas right now." Four states, two reasons:+ //+ // - NOT ON SCREEN — collapsed hides the body outright (`display: none`), the ⌘M view covers it+ // with an opaque panel. A grid left registered through either would keep painting its last+ // frame on the shared canvas at the node's world rect, with nothing of ours in front of it.+ // - MUST BE OPAQUE — the node is stacked over another node (`glyphOpaque`), or it is being+ // DRAGGED, which is the same thing a moment early. A shared-mode body is a transparent window,+ // so a terminal that is on top of something has to paint its own pixels or the node beneath it+ // shows through. See the stacking rule at `opaqueNodeIds`.+ //+ // Mirrored into a ref for the lifecycle effect's closures (which cannot see fresh props), and+ // read by `setupGlyph` itself — the mount-time setup runs from that effect, not from the+ // participation effect below, so the gate has to live where every caller passes through it.+ const glyphOff = collapsed || mdMode || glyphOpaque || dragging+ const glyphOffRef = useRef(glyphOff)+ glyphOffRef.current = glyphOff+ // The NOT-ON-SCREEN half on its own. `setupGlyph`'s gate needs to tell the two reasons apart:+ // a terminal that is merely covered up has no pixels to accelerate, while one held opaque is+ // fully visible and painting its own — so the latter must be a WebGL budget client, exactly like+ // a default-mode terminal. That is the "never both renderers, and never NEITHER" invariant.const glyphHiddenRef = useRef(collapsed || mdMode)glyphHiddenRef.current = collapsed || mdMode// Derive the node's agent once, through the shared helper — the canvas menu decides whether to@@ -1229,7 +1264,16 @@ export function TerminalNode({*/const setupGlyph = (forcedCell?: { cellW: number; cellH: number }): void => {if (disposed || glyphAttach || glyphGrid) return- if (glyphHiddenRef.current) return+ if (glyphOffRef.current) {+ // Held OFF the shared canvas — and which half of `glyphOff` it is decides the budget+ // client. Covered up (collapsed / ⌘M): nothing to draw, so no client, exactly as before.+ // Held OPAQUE (stacked over another node, or being dragged): this terminal is fully+ // visible and painting its own pixels, so it is a WebGL client like any default-mode+ // terminal — without this it would end up with NEITHER renderer coordinated and quietly+ // run on xterm's DOM renderer for as long as the overlap lasts.+ if (!glyphHiddenRef.current) ensureWebglClient()+ return+ }// The gate, re-evaluated on every call (mount, generation bump, expand): mode on, session not// failed, and a context that actually exists — no WebGL2/OffscreenCanvas returns null here// and this terminal simply stays where it is.@@ -2186,16 +2230,23 @@ export function TerminalNode({// settings are in the deps as well as the epoch, so the re-setup still lands after the options// even if the two ever arrive in separate renders. Do not move this effect above the one above.//- // It also owns the two states in which the terminal is NOT on screen although it is mounted:- // collapsed (the body is `display: none`) and the ⌘M markdown/chat view (an opaque panel over- // the body). Both drop the grid — and re-register on the way back — for the same reason a parked- // terminal drops its WebGL context: there is nothing to draw, and a grid left registered keeps- // painting its last frame at the node's world rect with nothing of ours in front of it.+ // It also owns every state in which this node must not be on the shared canvas although it is+ // mounted — `glyphOff` names them all (collapsed, ⌘M, stacked over another node, being dragged)+ // and the ref beside it carries the same answer to `setupGlyph`'s own gate. Each drops the grid+ // and re-registers on the way back, through the SAME teardown/setup machinery that collapse and+ // ⌘M have always used: `teardownGlyph` clears `glyphMounted` (so `term-node--glyphgrid` comes off+ // the node root) and removes `glyphgrid-mode` from the xterm element, which is exactly what makes+ // the body opaque and the DOM rows visible again. Nothing here is a special case for stacking.+ //+ // `dragging` flips synchronously at gesture start, so a drag goes DOM before the node has moved a+ // pixel and stays there until it settles — no mid-gesture flip back, and the drop position's+ // overlap answer arrives with the settle. HYSTERESIS is otherwise Canvas's job: it freezes the+ // opaque set while anything is dragging, so a neighbour cannot be swapped renderer twice a frame.//// No-op (one ref null check) unless this node participates in the shared canvas.useEffect(() => {- glyphSyncRef.current?.(!collapsed && !mdMode)- }, [collapsed, mdMode, glyphEpoch, fontSize, fontFamily])+ glyphSyncRef.current?.(!glyphOff)+ }, [glyphOff, glyphEpoch, fontSize, fontFamily])// Kanban board opened/closed: re-evaluate our size vote. Open → applyFit reports null (yield the// grid to a card-modal viewer); close → it re-reports the real fit. On the first run boardOpen