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.

fix(canvas): pause React Flow's dashdraw edges with the idle and covered gates

Brandon Bridgesfd0b8e94555f
diff --git a/CLAUDE.md b/CLAUDE.md
index 17c8262ec..63efdf5b0 100644
--- a/CLAUDE.md
+++ b/CLAUDE.md
@@ -9076,6 +9076,18 @@ unfocused case. The driven-browser rope still flows (it lasts only while an agen
`styles.animation-gate.test.ts` pins the bounded shorthands, the resting values and the keyframe
endpoints.
+**React Flow's `dashdraw` is gated in `styles.css`, not by xyflow.** Every `animated` edge (working
+subagent and loop edges, the driven-browser rope) and an animated connection line run xyflow's own
+`dashdraw 0.5s linear infinite`, from a vendor sheet that never reads `--nt-anim-state` — so until
+this rule it escaped BOTH the idle and the covered gate, and "the idle gate covers the unfocused
+case" above was false for edges. MEASURED (dev build, one synthetic edge with React Flow's real
+classes, idle gate set, 3 alternating 30 s rounds): Liquid Glass 79 % GPU + 36 % renderer and
++340 MB GPU footprint; dark 31.5 % + 29 %; with the play-state rule, the 0.5 % / 3.3 % no-edge
+baseline. The rule repeats xyflow's selectors verbatim (same specificity, wins on order after the
+`@import`), and `styles.animation-gate.test.ts` scans the vendor sheet for infinite animations, so an
+xyflow upgrade that adds one fails there. A FOCUSED window still pays the full per-edge cost while an
+edge works; a cheaper working-edge style is an open design call (the driven rope keeps flowing).
+
**The viewport is never promoted — not even while the camera moves.** A `will-change: transform`
on `.react-flow__viewport` during pan/zoom was tried (00c9c5fc, measured 41–48% → 30–36% CPU on
12 WebGL terminals) and removed: the viewport layer spans the WHOLE canvas, and Chromium rasters it
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 3a8beda69..6a4fcd4ab 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -1477,8 +1477,10 @@ the step is at the FIRST animation, not the twentieth. Two consequences when you
`animation-play-state: var(--nt-anim-state);` right after the shorthand so it joins the idle-window
gate (`src/renderer/styles.animation-gate.test.ts` fails if you forget, because one ungated
animation takes the whole win back), and prefer a static state to a pulse wherever the pulse is not
-carrying information the user needs at a glance. The full measurement table and the reasoning are
-in CLAUDE.md § Idle energy.
+carrying information the user needs at a glance. A dependency's stylesheet counts too: React Flow's
+`dashdraw` on animated edges is gated by a rule in `styles.css` that repeats xyflow's selectors, and
+the same test scans `@xyflow/react/dist/style.css` so an upgrade that adds an infinite animation
+fails there. The full measurement table and the reasoning are in CLAUDE.md § Idle energy.
## Pull requests
diff --git a/src/renderer/styles.animation-gate.test.ts b/src/renderer/styles.animation-gate.test.ts
index 3d294d07a..955e3302d 100644
--- a/src/renderer/styles.animation-gate.test.ts
+++ b/src/renderer/styles.animation-gate.test.ts
@@ -1,4 +1,5 @@
import fs from 'node:fs'
+import { createRequire } from 'node:module'
import path from 'node:path'
import { describe, expect, it } from 'vitest'
@@ -104,6 +105,44 @@ describe('idle-window animation gate', () => {
).toEqual([])
})
+ it("gates React Flow's own infinite animations (dashdraw), which the scan above cannot see", () => {
+ // styles.css @imports xyflow's sheet, whose `dashdraw 0.5s linear infinite` on animated edges
+ // never read the variable, so both gates missed it — MEASURED: one working edge under Liquid
+ // Glass held 79 % GPU + 36 % renderer and +340 MB GPU footprint on an idle window; the
+ // play-state rule took it back to the 0.5 % / 3.3 % baseline. Every infinite rule in the vendor
+ // sheet needs a rule here with the SAME selector (same specificity, later by order, so it wins)
+ // that sets the play-state — an upgrade that adds one fails here instead of silently costing.
+ const vendor = fs
+ .readFileSync(createRequire(__filename).resolve('@xyflow/react/dist/style.css'), 'utf8')
+ .replace(/\r\n/g, '\n')
+ .replace(/\/\*[\s\S]*?\*\//g, '')
+ const vendorSelectors = [...vendor.matchAll(/([^{}]+)\{([^{}]*)\}/g)]
+ .filter((m) => /animation:[^;]*\binfinite\b/.test(m[2]))
+ .flatMap((m) => m[1].split(',').map((s) => s.trim().replace(/\s+/g, ' ')))
+ // Non-vacuous: the edge rule is the one that was measured.
+ expect(vendorSelectors).toContain('.react-flow__edge.animated path')
+
+ // Offsets below are all taken on the same comment-stripped text.
+ const stripped = css.replace(/\/\*[\s\S]*?\*\//g, '')
+ const ours = [...stripped.matchAll(/([^{}]+)\{([^{}]*)\}/g)]
+ .filter((m) => m[2].includes(PLAY_STATE))
+ .map((m) => ({
+ index: m.index ?? 0,
+ selectors: m[1].split(',').map((s) => s.trim().replace(/\s+/g, ' '))
+ }))
+ const importAt = stripped.indexOf("@import '@xyflow/react/dist/style.css'")
+ expect(importAt, 'styles.css no longer imports the xyflow sheet').toBeGreaterThanOrEqual(0)
+
+ const ungated = vendorSelectors.filter(
+ (sel) => !ours.some((r) => r.index > importAt && r.selectors.includes(sel))
+ )
+ expect(
+ ungated,
+ "These @xyflow/react rules run an infinite animation that ignores --nt-anim-state. Add the\n" +
+ `exact selector to the rule in styles.css that sets "${PLAY_STATE};" for React Flow.\n`
+ ).toEqual([])
+ })
+
it('backs every static-when-idle entry with a real idle rule', () => {
for (const [keyframe, reason] of Object.entries(STATIC_WHEN_IDLE)) {
// The keyframe still has to exist, or the entry is stale and is silently excusing nothing.
diff --git a/src/renderer/styles.css b/src/renderer/styles.css
index 657eb3e36..b1fdb0990 100644
--- a/src/renderer/styles.css
+++ b/src/renderer/styles.css
@@ -204,6 +204,28 @@
--nt-anim-state: paused;
}
+/* React Flow's own infinite animation joins the gate here. `@xyflow/react/dist/style.css`
+ (imported at the top of this file) runs `dashdraw 0.5s linear infinite` on every `animated`
+ edge — working subagent and loop edges, and the driven-browser rope — and on an animated
+ connection line. That sheet never reads `--nt-anim-state`, so inheriting the variable did
+ nothing and both the idle gate and the covered-canvas gate missed it. MEASURED (dev build, one
+ synthetic edge with React Flow's real classes on a silent 12-terminal canvas, idle gate set,
+ 3 alternating 30 s rounds): Liquid Glass 79 % of a core in the GPU process + 36 % renderer and
+ +340 MB GPU footprint; dark 31.5 % + 29 %; with this rule both fell to the no-edge baseline
+ (0.5 % GPU, 3.3 % renderer). The selectors are copied verbatim from xyflow's sheet, so the
+ specificity is identical and this wins on order alone (it comes after the @import); it sets ONLY
+ the play-state, so the shorthand, the dash and the interaction path's `animation: none` are
+ untouched. `styles.animation-gate.test.ts` scans xyflow's sheet too, and fails if an upgrade adds
+ an infinite animation under a selector not listed here.
+
+ This covers idle and covered only. A FOCUSED window still pays the full per-edge cost for as
+ long as an edge works; a cheaper working-edge style is a separate design call, and the driven
+ rope keeps flowing while focused by decision (see CLAUDE.md § Idle energy). */
+.react-flow__edge.animated path,
+.react-flow__connection .animated {
+ animation-play-state: var(--nt-anim-state);
+}
+
/* ---- Light appearance ----------------------------------------------------------------------
Set by App.tsx from `settings.appTheme` (see lib/appTheme.ts); absent = dark, so an install
that never picks one is byte-for-byte unchanged.