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): the z branch that actually runs is 'basic', and a test that runs the library
enes6f43e3aef6a4
diff --git a/docs/superpowers/plans/2026-08-03-phase1b-device-checklist.md b/docs/superpowers/plans/2026-08-03-phase1b-device-checklist.mdindex e524dc296..0b2e0ff94 100644--- a/docs/superpowers/plans/2026-08-03-phase1b-device-checklist.md+++ b/docs/superpowers/plans/2026-08-03-phase1b-device-checklist.md@@ -193,9 +193,17 @@ Auto after you switched builds, that is why: re-select Shared and carry on.GPU glyphs). Note whether you can see that difference and how objectionable it is — that isthe round-5 question. Also: move the nodes apart again and confirm the upper one goes BACK tothe 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 in- its body (offset chain resolves through the parent), and its paint order relative to- ungrouped terminals is sane (known limitation L7).+- [ ] **3.10 Group-parented terminal, and terminals ON a frame (L7 is now modelled — round 5).** A+ terminal inside a group frame: its text sits exactly in its body (the offset chain resolves+ through the parent). Then the two stacking cases the z model exists for:+ (a) **drag an UNGROUPED terminal over a populated group frame.** It paints on top of the frame+ (a frame is z 0, tied with ungrouped nodes, and frames sort first), so it must go opaque —+ **no part of the frame's dashed border, and no part of its label pill, may be visible inside+ that terminal's body.** This is the case a wrong z model leaves transparent, and it looks+ exactly like the frame-ghost round 5 deleted, so report it precisely.+ (b) **overlap a grouped terminal with an ungrouped one.** The grouped one is above (child z 1+ vs 0) regardless of which was created first: it must hide the ungrouped one completely, and+ clicking either must still bring it to the front.- [ ] **3.11 Letterboxed / oddly-sized node.** Resize a node so the fit leaves slack, and open aco-attached node that a smaller peer is letterboxing: the text stays inside the body, alignedwith the mouse, **and the letterbox bands are terminal background, not canvas**. Reasoning to@@ -325,18 +333,22 @@ Auto after you switched builds, that is why: re-select Shared and carry on.- **L6 — Adopting a parked terminal after a font change may keep a stale cell size.** The grid isregistered from the cell xterm reports at adopt time; a font change applied in the same commitcan land after it. Refreshing the node re-registers at the correct size.-- **L7 — Group-parented z: MODELLED in round 5, with one transient residual.** This used to read "an- approximation": the order was array order plus selection, while React Flow additionally bumps a- root frame into a band (`ROOT_PARENT_Z_INCREMENT`, 10 per frame in first-child order) and gives- each child `parentZ >= childZ ? parentZ + 1 : childZ`. That is why an unselected GROUPED terminal- sits above every ungrouped one wherever it is in the array, and why a selected FRAME carries its- children above a selected ungrouped node — both of which the old model got backwards.- `nodeStackZ` now reproduces the whole rule (`adoptUserNodes` → `calculateZ` / `calculateChildXYZ`- in `@xyflow/system`) and BOTH consumers read it — the grids' z and the opaque set — so they cannot- disagree about who is on top. **Residual:** React Flow reuses a node's internal object, and its z,- when the user node object is identical (`checkEquality`), so in a commit where only some nodes- were rebuilt a live z can lag this model by a pass. It converges on the next full adopt, and the- bands themselves are stable across the partial ones. Verify by item **3.10**.+- **L7 — Group-parented z: MODELLED in round 5, and no longer a limitation.** This used to read "an+ approximation": the order was array order plus selection, ignoring that React Flow gives a frame's+ child `parentZ >= childZ ? parentZ + 1 : childZ`. `nodeStackZ` now reproduces the rule for this+ app's configuration — no explicit `zIndex`, `elevateNodesOnSelect` on, and **`zIndexMode` at its+ default `'basic'`** (nothing in `src/` passes the prop) — and BOTH consumers read it, the grids' z+ and the opaque set, so they cannot disagree about who is on top. In `'basic'` the whole rule is:+ every node is `selected ? 1000 : 0`, and a child is one above its frame. So a group FRAME is z 0,+ **tied** with every ungrouped node — frames merely sort first in the array, which is why an+ ungrouped terminal overlapping a populated frame paints ON TOP of it — while that frame's children+ sit at 1, above both, and a selected frame carries its children to 1001. Nothing order-dependent+ is left in the model, so it is exact rather than approximate, and it is pinned by a differential+ test that runs the real `adoptUserNodes` over eleven canvas shapes. (The trap worth recording:+ `@xyflow/system` also has an `'auto'` branch that bands root frames by `ROOT_PARENT_Z_INCREMENT`,+ putting a populated frame at 10. Transcribing THAT branch is a way to conclude that a terminal+ lying on a frame is underneath it and leave it transparent — with the frame's dashed border and+ label pill showing through, the exact ghost round 5 removes.) Verify by item **3.10**.- **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.diff --git a/src/renderer/canvas/SharedGlyphLayer.test.ts b/src/renderer/canvas/SharedGlyphLayer.test.tsindex 4209fdfb2..24113a961 100644--- a/src/renderer/canvas/SharedGlyphLayer.test.ts+++ b/src/renderer/canvas/SharedGlyphLayer.test.ts@@ -1,3 +1,4 @@+import { adoptUserNodes } from '@xyflow/system'import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'import {failSharedGlyph,@@ -21,7 +22,8 @@ import {subscribeNodeZOrder,subscribeOpaqueSet,useSharedGlyph,- type StackedNode+ type StackedNode,+ type StackOrderNode} from './SharedGlyphLayer'// Only the PURE parts are unit-testable here: there is no WebGL2, no OffscreenCanvas and no@@ -113,9 +115,9 @@ describe('nodeOrderSig', () => {})it('puts a GROUPED terminal above an ungrouped one that follows it in the array', () => {- // React Flow gives a child `parentZ + 1`, and a root frame with children is itself bumped into- // a band — so a grouped node outranks every ungrouped one regardless of array position. The- // first cut of round 5 modelled selection only and got this backwards.+ // A child gets `parentZ + 1` = 1 while every ungrouped node is 0, so the grouped terminal is on+ // top regardless of array position. (The FRAME itself is 0 — tied with the ungrouped node, not+ // above it; that is the part the 'auto'-branch model got wrong.)const sig = nodeOrderSig([{ id: 'g', type: 'group' },{ id: 'inside', type: 'terminal', parentId: 'g' },@@ -304,45 +306,69 @@ describe('setNodeZOrder', () => {})describe('nodeStackZ (React Flow z, reproduced)', () => {+ // Every number below was READ OFF the real `adoptUserNodes` from @xyflow/system, called with what+ // @xyflow/react's store passes it: `{ elevateNodesOnSelect: true, zIndexMode: 'basic' }`. 'basic'+ // is the default in BOTH `getInitialState` and the <ReactFlow> component, and nothing in src/+ // passes the prop. That detail decides the load-bearing case: the 'auto' branch adds a+ // ROOT_PARENT_Z_INCREMENT band that would put a populated frame at 10 instead of 0, reversing+ // frame-vs-ungrouped — and a previous cut of this file shipped exactly that mistake.+it('is 0 for a plain node and 1000 for a selected one', () => {const z = nodeStackZ([{ id: 'a' }, { id: 'b', selected: true }])expect(z.get('a')).toBe(0)expect(z.get('b')).toBe(1000)})- it('bumps a root frame into a band and lifts its child one above it', () => {- // calculateChildXYZ: parentZ >= childZ ? parentZ + 1 : childZ, with the parent bumped by- // ROOT_PARENT_Z_INCREMENT (10) when its first child is processed.- const z = nodeStackZ([{ id: 'g' }, { id: 'c', parentId: 'g' }])- expect(z.get('g')).toBe(10)- expect(z.get('c')).toBe(11)+ it('leaves a group FRAME at 0 — tied with every ungrouped node — and lifts its child to 1', () => {+ // A frame does NOT outrank ungrouped nodes. Frames merely sort first in the array, so an+ // ungrouped node overlapping one paints ON TOP of it (and must therefore go opaque).+ const z = nodeStackZ([{ id: 'g' }, { id: 'inside', parentId: 'g' }, { id: 'outside' }])+ expect(z.get('g')).toBe(0)+ expect(z.get('inside')).toBe(1)+ expect(z.get('outside')).toBe(0)})- it('gives each root frame its own band, in first-child order', () => {+ it('does not band root frames — two frames tie, and so do their children', () => {const z = nodeStackZ([{ id: 'g1' },{ id: 'g2' },{ id: 'c1', parentId: 'g1' },{ id: 'c2', parentId: 'g2' }])- expect(z.get('g1')).toBe(10)- expect(z.get('c1')).toBe(11)- expect(z.get('g2')).toBe(20)- expect(z.get('c2')).toBe(21)+ expect(z.get('g1')).toBe(0)+ expect(z.get('g2')).toBe(0)+ expect(z.get('c1')).toBe(1)+ expect(z.get('c2')).toBe(1)})- it('a selected frame carries its children above 1000', () => {- const z = nodeStackZ([{ id: 'g', selected: true }, { id: 'c', parentId: 'g' }])- expect(z.get('g')).toBe(1010)- expect(z.get('c')).toBe(1011)+ it('a selected frame carries its children to 1001, above a selected ungrouped node', () => {+ const z = nodeStackZ([+ { id: 'g', selected: true },+ { id: 'c', parentId: 'g' },+ { id: 'outside', selected: true }+ ])+ expect(z.get('g')).toBe(1000)+ expect(z.get('c')).toBe(1001)+ expect(z.get('outside')).toBe(1000)})it('a selected CHILD of an unselected frame wins on its own z', () => {- // childZ 1000 > parentZ 10, so the child keeps 1000 rather than parentZ + 1.+ // childZ 1000 > parentZ 0, so the child keeps 1000 rather than parentZ + 1.const z = nodeStackZ([{ id: 'g' }, { id: 'c', parentId: 'g', selected: true }])expect(z.get('c')).toBe(1000)})+ it('nested frames stack one per level', () => {+ const z = nodeStackZ([+ { id: 'outer' },+ { id: 'inner', parentId: 'outer' },+ { id: 't', parentId: 'inner' }+ ])+ expect(z.get('outer')).toBe(0)+ expect(z.get('inner')).toBe(1)+ expect(z.get('t')).toBe(2)+ })+it('ignores a child whose parent is missing or comes later (React Flow warns and gives up)', () => {const z = nodeStackZ([{ id: 'c', parentId: 'g' }, { id: 'g' }])expect(z.get('c')).toBe(0)@@ -351,6 +377,91 @@ describe('nodeStackZ (React Flow z, reproduced)', () => {it('survives a parentId cycle', () => {expect(() => nodeStackZ([{ id: 'a', parentId: 'b' }, { id: 'b', parentId: 'a' }])).not.toThrow()})++ // The cases above are readable; THIS is the one that keeps them honest. `nodeStackZ` is+ // transcribed from someone else's algorithm, and transcription is how the last two bugs got in —+ // the first modelled selection only, the second modelled the `'auto'` branch of a library that+ // defaults to `'basic'`. Reading the source more carefully is not a fix for that class of+ // mistake; RUNNING it is. So every shape below goes through the real `adoptUserNodes`, called+ // exactly as `@xyflow/react`'s store calls it, and the answers must be identical. It needs no+ // DOM, which is why it can live in this suite at all.+ //+ // If this ever fails after a React Flow bump, the LIBRARY moved: re-derive `nodeStackZ` from the+ // new behaviour rather than pinning the old numbers.+ describe('agrees with the real adoptUserNodes', () => {+ const rf = (nodes: readonly StackOrderNode[]): Record<string, number> => {+ const lookup = new Map<string, { internals: { z: number } }>()+ adoptUserNodes(+ nodes.map((n) => ({+ ...n,+ position: { x: 0, y: 0 },+ data: {},+ measured: { width: 10, height: 10 }+ })) as never,+ lookup as never,+ new Map(),+ // The store's own options (index.mjs `setNodes`): everything else is left at its default,+ // which is where `zIndexMode: 'basic'` comes from.+ { elevateNodesOnSelect: true, checkEquality: true } as never+ )+ const out: Record<string, number> = {}+ for (const [id, n] of lookup) out[id] = n.internals.z+ return out+ }+ const ours = (nodes: readonly StackOrderNode[]): Record<string, number> =>+ Object.fromEntries(nodeStackZ(nodes))++ const shapes: Record<string, StackOrderNode[]> = {+ 'flat canvas': [{ id: 'a' }, { id: 'b' }],+ 'one selected': [{ id: 'a' }, { id: 'b', selected: true }],+ 'frame, child, ungrouped': [{ id: 'g' }, { id: 'inside', parentId: 'g' }, { id: 'outside' }],+ 'ungrouped before the frame': [+ { id: 'outside' },+ { id: 'g' },+ { id: 'inside', parentId: 'g' }+ ],+ 'two frames': [+ { id: 'g1' },+ { id: 'g2' },+ { id: 'c1', parentId: 'g1' },+ { id: 'c2', parentId: 'g2' }+ ],+ 'two frames, children interleaved': [+ { id: 'g1' },+ { id: 'g2' },+ { id: 'c2', parentId: 'g2' },+ { id: 'c1', parentId: 'g1' }+ ],+ 'selected frame': [+ { id: 'g', selected: true },+ { id: 'c', parentId: 'g' },+ { id: 'outside', selected: true }+ ],+ 'selected child': [{ id: 'g' }, { id: 'c', parentId: 'g', selected: true }],+ 'nested frames': [+ { id: 'outer' },+ { id: 'inner', parentId: 'outer' },+ { id: 't', parentId: 'inner' }+ ],+ 'nested frames, outer selected': [+ { id: 'outer', selected: true },+ { id: 'inner', parentId: 'outer' },+ { id: 't', parentId: 'inner' }+ ],+ 'several children of one frame': [+ { id: 'g' },+ { id: 'c1', parentId: 'g' },+ { id: 'c2', parentId: 'g' },+ { id: 'c3', parentId: 'g' }+ ]+ }++ for (const [name, nodes] of Object.entries(shapes)) {+ it(name, () => {+ expect(ours(nodes)).toEqual(rf(nodes))+ })+ }+ })})describe('effectiveStackOrder', () => {@@ -490,10 +601,28 @@ describe('opaqueNodeIds', () => {expect(opaqueNodeIds([at('a', 0, 0), at('b', 20, 20), at('c', 40, 40)])).toEqual(['b', 'c'])})- it('marks the GROUPED terminal, not the ungrouped one that follows it in the array', () => {- // The grouped terminal is above by React Flow's z (parentZ + 1) even though it comes FIRST.- // Reading array order alone marked the wrong node — the ungrouped one would have gone opaque- // while the grouped one stayed transparent ON TOP of it.+ it('marks a terminal lying on a POPULATED group frame — the frame is not above it', () => {+ // The case both wrong z models broke, from opposite sides. A frame is z 0, tied with every+ // ungrouped node, and frames sort FIRST in the array — so `outside` paints on top of the frame+ // and must be opaque, or the frame's dashed border and its label pill (DOM, above any canvas+ // plate) show straight through the terminal's transparent body. The banded 'auto' model gave+ // the frame z 10, concluded the terminal was underneath it, and left it transparent.+ // `inside` is placed clear of `outside` so this asserts only the frame relationship.+ const group: StackedNode = {+ id: 'g',+ type: 'group',+ position: { x: 0, y: 0 },+ measured: { width: 400, height: 400 }+ }+ const inside = at('inside', 300, 300, { parentId: 'g' })+ const outside = at('outside', 10, 10)+ expect(opaqueNodeIds([group, inside, outside])).toEqual(['outside'])+ })++ it('marks BOTH when a grouped and an ungrouped terminal overlap each other on a frame', () => {+ // z: frame 0, outside 0 (later in the array ⇒ above the frame), inside 1 (above both). So+ // `outside` is opaque for lying on the frame, and `inside` for lying on `outside`; the frame+ // is skipped for `inside` because it is its ancestor.const group: StackedNode = {id: 'g',type: 'group',@@ -502,7 +631,7 @@ describe('opaqueNodeIds', () => {}const inside = at('inside', 20, 20, { parentId: 'g' })const outside = at('outside', 60, 60)- expect(opaqueNodeIds([group, inside, outside])).toEqual(['inside'])+ expect(opaqueNodeIds([group, inside, outside])).toEqual(['outside', 'inside'])})})diff --git a/src/renderer/canvas/SharedGlyphLayer.tsx b/src/renderer/canvas/SharedGlyphLayer.tsxindex cd01e133f..1183e4d9b 100644--- a/src/renderer/canvas/SharedGlyphLayer.tsx+++ b/src/renderer/canvas/SharedGlyphLayer.tsx@@ -181,11 +181,9 @@ let zOrder = new Map<string, number>()let zOrderSig = ''const zListeners = new Set<() => void>()-/** React Flow's own stacking constants (`@xyflow/system`, `SELECTED_NODE_Z` /- * `ROOT_PARENT_Z_INCREMENT`). Copied rather than imported because they are not exported; pinned- * by `nodeStackZ`'s tests, which state the rule they came from. */+/** React Flow's selection elevation (`@xyflow/system`'s `SELECTED_NODE_Z`). Copied rather than+ * imported because it is not exported; pinned by `nodeStackZ`'s tests. */const SELECTED_NODE_Z = 1000-const ROOT_PARENT_Z_INCREMENT = 10/** The node fields the stacking model reads. */export interface StackOrderNode {@@ -196,36 +194,40 @@ export interface StackOrderNode {/*** REPRODUCTION of the z React Flow assigns each node, for this app's configuration: no explicit- * `zIndex` anywhere, default `zIndexMode` ('auto'), and `elevateNodesOnSelect` at its default- * (on). The algorithm is `adoptUserNodes` → `calculateZ` / `updateChildNode` / `calculateChildXYZ`- * in `@xyflow/system`, transcribed:- *- * - Every node starts at `selected ? 1000 : 0`.- * - The FIRST time a ROOT parent (a frame with no parent of its own) has a child processed, that- * parent's z is bumped by `++counter * 10`. Root frames are therefore separated into bands in- * the order their first child appears.- * - A child's z is `parentZ >= childZ ? parentZ + 1 : childZ` — so an unselected node inside a- * frame outranks EVERY ungrouped unselected node, wherever it sits in the array, and a SELECTED- * FRAME carries its children up with it (parentZ 1000+ ⇒ children 1001+, above a selected- * ungrouped node at 1000).- * - Returning to an already-indexed parent resets the running counter to that parent's index,- * which is why the counter is not monotonic. Reproduced, because it decides the bands.- *- * That last group of rules is the part round 5's first cut got wrong: it modelled selection only,- * which said a grouped terminal was BELOW an ungrouped one it is in fact above — and the opaque- * rule reads this order to decide who may stay transparent.- *- * Known residual, and why it is small: React Flow reuses a node's internal object (and its z) when- * the user node object is identical (`checkEquality`), so in a transient where only some nodes were- * rebuilt a live z can lag this model by a commit. It converges on the next full adopt, and the- * bands themselves (which frame is above which) are stable across those partial passes.+ * `zIndex` anywhere, `elevateNodesOnSelect` at its default (on), and — the detail that decides+ * everything below — **`zIndexMode` at its default, which is `'basic'`, not `'auto'`**. Nothing in+ * `src/` passes the prop, and `@xyflow/react` 12.11 defaults it to `'basic'` in both+ * `getInitialState` and the `<ReactFlow>` component. The whole rule is then two lines of+ * `calculateZ` / `calculateChildXYZ`:+ *+ * - Every node is `selected ? 1000 : 0`.+ * - A CHILD is then `parentZ >= childZ ? parentZ + 1 : childZ`, its parent resolved first (React+ * Flow requires parents before children in the array, which `nodeStatesToFlow` guarantees).+ *+ * What that means on this canvas: a group FRAME is z 0, tied with every ungrouped node — so array+ * order decides between them, and since frames sort FIRST, an ungrouped terminal overlapping a+ * populated frame paints ON TOP of it. A frame's child is 1, above both. A selected frame is 1000+ * and carries its children to 1001, above a selected ungrouped node at 1000. Nested frames stack+ * 0 / 1 / 2.+ *+ * **Two wrong models have been shipped here; both are worth naming.** Round 5's first cut modelled+ * selection only, which put a grouped terminal BELOW an ungrouped one it is in fact above. Its+ * replacement transcribed the `'auto'` branch, complete with the `ROOT_PARENT_Z_INCREMENT` banding+ * that gives a populated frame z 10 — which is gated on `zIndexMode === 'auto'` and therefore never+ * runs here. That one said an ungrouped terminal sitting on a frame was BELOW the frame, so the+ * terminal stayed transparent and the frame's border and label pill showed through it: exactly the+ * ghost this round exists to delete. The lesson is in the verification, not the reading — the model+ * is now checked against the real `adoptUserNodes`, and the tests state the numbers it returns.+ *+ * With the banding gone the model carries no order-dependent state, which also removes the+ * `checkEquality` caveat this comment used to carry: z depends only on `selected` and the parent+ * chain, React Flow recomputes every CHILD on each adopt regardless of reuse, and a reused ROOT's+ * z was computed from an identical node object. The model is exact, not approximate.*/export function nodeStackZ(nodes: readonly StackOrderNode[]): Map<string, number> {const z = new Map<string, number>()const byId = new Map<string, StackOrderNode>()for (const n of nodes) byId.set(n.id, n)- const rootParentIndex = new Map<string, number>()- let counter = 0for (const node of nodes) {const ownZ = node.selected ? SELECTED_NODE_Z : 0z.set(node.id, ownZ)@@ -234,13 +236,6 @@ export function nodeStackZ(nodes: readonly StackOrderNode[]): Map<string, number// React Flow warns and gives up on a child whose parent is missing or comes LATER in the// array; `nodeStatesToFlow` sorts parents first precisely so this cannot happen.if (!parent || !z.has(parent.id)) continue- if (!parent.parentId && !rootParentIndex.has(parent.id)) {- counter += 1- rootParentIndex.set(parent.id, counter)- z.set(parent.id, (z.get(parent.id) ?? 0) + counter * ROOT_PARENT_Z_INCREMENT)- }- const known = rootParentIndex.get(parent.id)- if (known !== undefined) counter = knownconst parentZ = z.get(parent.id) ?? 0z.set(node.id, parentZ >= ownZ ? parentZ + 1 : ownZ)}@@ -266,8 +261,11 @@ export function effectiveStackOrder<T extends StackOrderNode>(nodes: readonly T[break}}- // A flat, unselected canvas — the overwhelmingly common case — is already in paint order; return- // the input array itself rather than an identical copy.+ // Every z is 0 — no selection and no group frame with children anywhere — so the array is already+ // in paint order and the input is returned rather than an identical copy. Worth having (a canvas+ // with no groups and nothing selected is a real state, and this runs on every nodes change) but+ // NOT the common case it was once described as: one populated group frame gives its children z 1+ // and puts every nodes change through the sort.if (!ordered) return nodesreturn nodes.map((n, i) => ({ n, i, z: z.get(n.id) ?? 0 }))@@ -283,9 +281,9 @@ export function effectiveStackOrder<T extends StackOrderNode>(nodes: readonly T[* 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 `effectiveStackOrder`** — React Flow's own z (selection elevation AND group-frame- * banding; see `nodeStackZ`), ties broken by array order. The canvas z among the glyph grids- * mirrors the DOM's, so both worlds tell the same story about who is on top.+ * **The rule is `effectiveStackOrder`** — React Flow's own z (selection elevation and the+ * frame-child lift; see `nodeStackZ`), ties broken by array order. The canvas z among the glyph+ * grids mirrors the DOM's, 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@@ -370,9 +368,12 @@ export function subscribeNodeZOrder(fn: () => void): () => void {** 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).+ * b) it is in a GESTURE: it, or a group frame containing it, is being dragged or resized. A+ * gesture is "about to be above things", and holding the node opaque for its whole duration is+ * also what lets the rect sweep be frozen while `nodes` churns per frame. This set carries the+ * answer (`gestureTerminalIds`, which is the only thing that can see the children of a dragged+ * FRAME); TerminalNode additionally reads its own `dragging` prop, which flips synchronously+ * and needs nobody — two sources for one state, deliberately, and documented at both.** 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