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(notch-hud): don't resurrect old finished sessions at every launch
enes76505e6e04ed
diff --git a/docs/notch-hud.md b/docs/notch-hud.mdindex bb556b770..42f938b69 100644--- a/docs/notch-hud.md+++ b/docs/notch-hud.md@@ -54,6 +54,11 @@ Row shape sent to the HUD:or closing the panel clears NOTHING — an earlier "the panel was opened, so you looked at it"blanket clear meant that with three finished sessions waiting, opening the panel and clicking onesilently swallowed the other two. Drop a node from the HUD when it's gone + idle > 6 h.+ A `done` first learned about from a MIRROR FLUSH is seeded as already-seen: the mirror keeps+ entries for hours and is re-read at every launch, so without that rule every app start (and every+ re-enable of the setting) resurrected old finished sessions as fresh green blobs. Only a live done+ EDGE — a turn ending while the HUD is running — raises the highlight. A restored `needsYou` still+ shows, because it genuinely still needs you.## Indicator + panel (hud renderer) — the DynamicNotch capsulediff --git a/src/main/notch-hud-model.test.ts b/src/main/notch-hud-model.test.tsindex 014150462..1f8f6b443 100644--- a/src/main/notch-hud-model.test.ts+++ b/src/main/notch-hud-model.test.ts@@ -175,6 +175,9 @@ describe('6h drop', () => {const m = createHudModel()// present in mirror → never dropped, even if stalem.applyMirrorFlush({ v: 1, updatedAt: T0, nodes: { present: { state: 'done', updatedAt: T0 } } })+ // A done restored from the mirror is pre-seen (see "mirror restore"), so give this one a LIVE+ // finish too — the subject here is what prune keeps, not what the restore highlights.+ m.applyStateChange(stateChange({ nodeId: 'present', state: 'done', ts: T0 }))// gone node, recently donem.applyStateChange(stateChange({ nodeId: 'gone', state: 'done', ts: T0 }))// it's not in the mirror flush above → presentInMirror stays false@@ -235,3 +238,31 @@ describe('dismiss', () => {expect(() => m.dismiss('nope')).not.toThrow()})})++describe('mirror restore', () => {+ it('does not resurrect already-finished sessions on first sight', () => {+ const m = createHudModel()+ // Fresh process: the mirror file is read and it remembers hours of finished turns.+ m.applyMirrorFlush({+ nodes: {+ old1: { state: 'done', agentId: 'claude', updatedAt: T0 },+ old2: { state: 'done', agentId: 'codex', updatedAt: T0 }+ }+ } as never)+ expect(m.buildRows(T0 + 1, titleOf)).toHaveLength(0)++ // A turn that finishes while we ARE watching still lights up...+ m.applyStateChange(stateChange({ nodeId: 'old1', state: 'working', ts: T0 + 2 }))+ m.applyStateChange(stateChange({ nodeId: 'old1', state: 'done', ts: T0 + 3 }))+ expect(rowFor(m.buildRows(T0 + 4, titleOf), 'old1')?.state).toBe('done')+ // ...and a later flush repeating the same done doesn't clear it (only first sight is pre-seen).+ m.applyMirrorFlush({ nodes: { old1: { state: 'done', updatedAt: T0 + 3 } } } as never)+ expect(rowFor(m.buildRows(T0 + 5, titleOf), 'old1')?.state).toBe('done')+ })++ it('still surfaces a needs-you restored from the mirror', () => {+ const m = createHudModel()+ m.applyMirrorFlush({ nodes: { a: { state: 'waiting', updatedAt: T0 } } } as never)+ expect(rowFor(m.buildRows(T0 + 1, titleOf), 'a')?.state).toBe('needsYou')+ })+})diff --git a/src/main/notch-hud-model.ts b/src/main/notch-hud-model.tsindex 528480313..1cf423f40 100644--- a/src/main/notch-hud-model.ts+++ b/src/main/notch-hud-model.ts@@ -157,6 +157,10 @@ export function createHudModel(): HudModel {const seen = new Set<string>()for (const [nodeId, n] of Object.entries(doc.nodes ?? {})) {seen.add(nodeId)+ // Is this the FIRST time this process hears of the node? The mirror keeps entries for hours+ // and is re-read at every launch, so a node we're meeting through the file is HISTORY, not an+ // event that just happened here — see the done-seeding rule below.+ const firstSighting = !nodes.has(nodeId)const a = ensure(nodeId, n.updatedAt)a.presentInMirror = trueif (n.agentId) a.agentId = n.agentId@@ -168,6 +172,11 @@ export function createHudModel(): HudModel {const bucket = bucketState(n.state)if (bucket === 'done') {if (a.state !== 'done') a.state = 'done'+ // A `done` we learn about from the mirror on FIRST sight is pre-seen: it finished before+ // this HUD existed. Otherwise every app launch (and every re-enable of the setting)+ // resurrected up to 6 h of already-read "finished" sessions as fresh green blobs. Only a+ // live done EDGE — a turn that ends while we're watching — earns the highlight.+ if (firstSighting) a.doneSeen = true} else {a.state = bucketif (bucket === 'working') a.doneSeen = false