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.

perf(canvas): bound the unread glow, minimap beats and waiting-rope flow

enesfe82993ab5a0
diff --git a/CLAUDE.md b/CLAUDE.md
index 11a32ad80..9cafc31a4 100644
--- a/CLAUDE.md
+++ b/CLAUDE.md
@@ -6887,12 +6887,11 @@ unpatched number while looking correct in the diff. When you add a gate, verify
The gate itself: `renderer/lib/windowActivity.ts` sets `data-nt-window="idle"` on the document
element when the window loses focus or the page hides, `:root[data-nt-window='idle']` flips
`--nt-anim-state` to `paused`, and the three per-node glows take a static-lit rule instead of the
-shared pause — `nt-unread-glow` rests at `opacity: 0`, so pausing it is a coin flip on whether the
-glow that says "this agent finished while you were away" is still on screen when you come back to
-look for it. `hud.css` is deliberately excluded: the notch HUD's window is never focused, so the
+shared pause — pausing freezes a glow wherever its clock stopped, and the glow that says "this
+agent finished while you were away" must still be on screen when you come back to look for it. `hud.css` is deliberately excluded: the notch HUD's window is never focused, so the
shared gate would freeze it permanently rather than while nobody is looking.
-**The working glow is BOUNDED; the unread and attention glows are not.** The idle gate only helps an
+**The working and unread glows are BOUNDED; the attention glow is not.** The idle gate only helps an
unfocused window, and an agent mid-turn in a FOCUSED one kept `nt-working-glow` looping for the
whole turn — MEASURED (production build, M2, focused): one visible working node cost **+3 points
total CPU and ~25 style recalcs/s** for as long as it ran. It now runs 4 cycles of 2.6 s (~10 s) and
@@ -6900,9 +6899,19 @@ rests at `opacity: 0.7`, the same static-lit value the idle gate and Reduce Moti
at; the keyframes start and end at 0.7, so the settle is seamless. A new turn re-adds `.working`,
which restarts the pulse — and so does anything else that re-applies the animation: a window
refocus (the idle gate sets `animation: none`, so lifting it starts the shorthand afresh) and a node
-remount (a project switch, a park re-adopt) each replay the four pulses. Still bounded every time. Unread and attention stay infinite on purpose — they exist to pull the
-eye, and the idle gate covers the unfocused case. `styles.animation-gate.test.ts` pins the bounded
-shorthand, the resting opacity and the keyframe endpoints.
+remount (a project switch, a park re-adopt) each replay the four pulses. Still bounded every time.
+**Unread is bounded the same way** (4 cycles of 2 s, resting lit at `opacity: 0.85`), and so are the
+minimap's working and unread beats (`mm-pulse-soft` / `mm-pulse-unread`, resting at full stroke), and
+a WAITING `--after` rope is dashed + ⏳ but no longer `animated` (React Flow's `dashdraw`, 0.5 s
+infinite): an unread node stays unread until someone looks, and a wait can last hours, so on a busy
+canvas those three kept the frame loop open indefinitely. MEASURED (46-node SSH canvas, 14 unread
+nodes, 8 waiting ropes, FOCUSED window, dev build): idle renderer+GPU **~120% → ~25%**, and pausing
+every remaining animation no longer moves it. Pausing any ONE family alone saved far less (85–104%),
+which is the first-animation step above again. Only the attention glow (and its minimap beat) stays
+infinite — needs-you is the one state that must keep pulling the eye — and the idle gate covers the
+unfocused case. The driven-browser rope still flows (it lasts only while an agent drives the page).
+`styles.animation-gate.test.ts` pins the bounded shorthands, the resting values and the keyframe
+endpoints.
**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
diff --git a/src/renderer/canvas/Canvas.tsx b/src/renderer/canvas/Canvas.tsx
index e2152bd09..c8a2047c0 100644
--- a/src/renderer/canvas/Canvas.tsx
+++ b/src/renderer/canvas/Canvas.tsx
@@ -2602,7 +2602,10 @@ export function Canvas() {
const base = {
...e,
type: 'floating',
- animated: v.waiting,
+ // A waiting rope is dashed + ⏳ but does NOT flow: an `--after` wait can last hours, and
+ // React Flow's `animated` (dashdraw, 0.5 s, infinite) kept the compositor producing frames
+ // for the whole wait. The driven-browser rope below still flows; it is short-lived.
+ animated: false,
style: { stroke: v.color, strokeWidth: 1.5, ...(v.waiting ? { strokeDasharray: '6 4' } : {}) },
markerEnd: { type: MarkerType.ArrowClosed, color: v.color, width: 14, height: 14 },
...(v.waiting
diff --git a/src/renderer/styles.animation-gate.test.ts b/src/renderer/styles.animation-gate.test.ts
index e6ba1d78b..3d294d07a 100644
--- a/src/renderer/styles.animation-gate.test.ts
+++ b/src/renderer/styles.animation-gate.test.ts
@@ -30,7 +30,9 @@ const PLAY_STATE = 'animation-play-state: var(--nt-anim-state)'
* rule without removing the entry fails below.
*/
const STATIC_WHEN_IDLE: Record<string, string> = {
- 'nt-unread-glow': 'rests at opacity 0; pausing could hide the "finished while you were away" glow',
+ // Bounded (4 cycles) and resting lit since the second CPU/GPU pass; the entry stays for the same
+ // reason as the working glow's.
+ 'nt-unread-glow': 'held lit rather than frozen mid-cycle, alongside its two siblings',
// Bounded (4 cycles) since the CPU/GPU pass, so the infinite scan no longer sees it; the entry
// stays because its idle and Reduce Motion rules still hold it lit mid-pulse.
'nt-working-glow': 'held lit rather than frozen mid-cycle, alongside its two siblings',
@@ -130,6 +132,25 @@ describe('idle-window animation gate', () => {
expect(kf).toMatch(/0%,\s*100%\s*\{\s*opacity:\s*0\.7/)
})
+ it('the unread glow and the minimap working/unread beats are bounded and rest lit', () => {
+ // Infinite, these kept the compositor at display rate for as long as any node stayed unread
+ // (measured: ~120% -> ~26% idle renderer+GPU with every status animation paused).
+ const rule = ruleBody(css, '.react-flow__node:has(.term-node.unread)::after')
+ expect(rule).toMatch(/animation:\s*nt-unread-glow\s+2s\s+ease-in-out\s+4\b/)
+ expect(rule).toMatch(/opacity:\s*0\.85/)
+ expect(keyframesBody(css, 'nt-unread-glow')).toMatch(/0%,\s*100%\s*\{\s*opacity:\s*0\.85/)
+ for (const [sel, kf] of [
+ ['.minimap .mm-unread', 'mm-pulse-unread'],
+ ['.minimap .mm-working', 'mm-pulse-soft']
+ ]) {
+ // The selector also heads a shared stroke-width group rule; take the rule that animates.
+ const r = css.split(sel + ' {').slice(1).map((b) => b.slice(0, b.indexOf('}'))).find((b) => b.includes('animation:')) ?? ''
+ expect(r).toMatch(new RegExp(`animation:\\s*${kf}\\s+[\\d.]+s\\s+ease-in-out\\s+4\\b`))
+ expect(r).not.toMatch(/infinite/)
+ expect(keyframesBody(css, kf)).toMatch(/0%,\s*100%\s*\{\s*stroke-opacity:\s*1\b/)
+ }
+ })
+
it('never pauses the notch HUD, whose window is never focused', () => {
// hud.css belongs to a separate always-on-top panel window that by design never takes focus,
// so the shared gate would freeze it permanently rather than while nobody is looking.
diff --git a/src/renderer/styles.css b/src/renderer/styles.css
index 1de5cfe60..0c63b87e3 100644
--- a/src/renderer/styles.css
+++ b/src/renderer/styles.css
@@ -1641,17 +1641,27 @@ body,
box-shadow:
0 0 0 1px color-mix(in srgb, var(--state-unread) 80%, transparent),
0 0 26px 4px color-mix(in srgb, var(--state-unread) 60%, transparent);
- opacity: 0;
- animation: nt-unread-glow 2s ease-in-out infinite;
+ opacity: 0.85;
+ animation: nt-unread-glow 2s ease-in-out 4;
will-change: opacity;
}
+/* Bounded like the working glow (4 cycles, ~8 s) and resting LIT at 0.85, the value the idle gate
+ and Reduce Motion already hold it at, so the glow still says "finished while you were away" after
+ the pulse ends. It used to run forever: an unread node stays unread until someone looks at it,
+ which on a busy canvas is many nodes for hours, and one running animation keeps the compositor at
+ display rate for the whole window. MEASURED (46-node SSH canvas, 14 unread nodes, focused window,
+ dev build): pausing every status animation took idle renderer+GPU CPU from ~120% to ~26%, and no
+ single family alone got there — see styles.animation-gate.test.ts. */
@keyframes nt-unread-glow {
0%,
100% {
- opacity: 0;
+ opacity: 0.85;
}
- 50% {
+ 40% {
+ opacity: 0.1;
+ }
+ 75% {
opacity: 1;
}
}
@@ -7681,7 +7691,7 @@ button.group-node__setup:disabled {
}
.minimap .mm-working {
filter: drop-shadow(0 0 3px color-mix(in srgb, var(--mm-working) 80%, transparent));
- animation: mm-pulse-soft 2.6s ease-in-out infinite;
+ animation: mm-pulse-soft 2.6s ease-in-out 4;
animation-play-state: var(--nt-anim-state);
}
.minimap .mm-attention {
@@ -7694,16 +7704,23 @@ button.group-node__setup:disabled {
stroke THICKENS on the beat as well, which is what makes it findable on a busy map. */
.minimap .mm-unread {
filter: drop-shadow(0 0 4px color-mix(in srgb, var(--mm-unread) 95%, transparent));
- animation: mm-pulse-unread 1.6s ease-in-out infinite;
+ animation: mm-pulse-unread 1.6s ease-in-out 4;
animation-play-state: var(--nt-anim-state);
}
+/* Working and unread beat 4 times and then REST at full stroke (the drop-shadow halo is static),
+ mirroring their bounded canvas glows: an infinite beat repainted the minimap's filtered SVG every
+ frame for as long as a node stayed unread. Needs-you keeps beating, like its canvas glow. */
@keyframes mm-pulse-unread {
0%,
100% {
+ stroke-opacity: 1;
+ stroke-width: 4px;
+ }
+ 40% {
stroke-opacity: 0.3;
stroke-width: 3px;
}
- 50% {
+ 75% {
stroke-opacity: 1;
stroke-width: 6px;
}
@@ -7721,10 +7738,10 @@ button.group-node__setup:disabled {
@keyframes mm-pulse-soft {
0%,
100% {
- stroke-opacity: 0.45;
+ stroke-opacity: 1;
}
50% {
- stroke-opacity: 1;
+ stroke-opacity: 0.45;
}
}