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): stop showing a working session nobody has heard from
enesc2ea080c8ac7
diff --git a/src/core/agent-status-mirror.ts b/src/core/agent-status-mirror.tsindex 61d146bdf..2c234b053 100644--- a/src/core/agent-status-mirror.ts+++ b/src/core/agent-status-mirror.ts@@ -513,6 +513,10 @@ export interface NodeStateChange {/** approval needsYou only: the deterministic hook-reply ticket from the just-produced approval* event, letting an intent answer the held hook. Absent otherwise. */pendingId?: string+ /** done only: the turn ended because the user interrupted it (Esc/Ctrl-C) rather than finishing.+ * Consumers that celebrate a completion (notification, the notch HUD's "finished, unseen"+ * highlight) skip it — nothing was accomplished, so there is nothing to go and read. */+ interrupted?: boolean/** done only: this 'end' was produced by an explicit desktop/browser READ of the finished* session (`ackDone`), NOT the natural turn-end edge. Both send event:'end', which is what the* phone uses to dismiss the Live Activity — `ack` only distinguishes them for internal@@ -1129,7 +1133,13 @@ function produceInboxFromState(// working from re-entering, and the normalizer collapses an Esc-spam into one done).const detail = firstLine(ev.lastMessage, INBOX_DETAIL_MAX) || undefinedconst title = ev.interrupted ? 'Stopped' : 'Finished'- fireNodeStateChange({ ...stateBase, event: 'end', state: 'done', message: title })+ fireNodeStateChange({+ ...stateBase,+ event: 'end',+ state: 'done',+ message: title,+ ...(ev.interrupted ? { interrupted: true } : {})+ })pushInboxEvent({...baseEvent,kind: 'done',diff --git a/src/main/notch-hud-model.test.ts b/src/main/notch-hud-model.test.tsindex 1f8f6b443..e37bc0287 100644--- a/src/main/notch-hud-model.test.ts+++ b/src/main/notch-hud-model.test.ts@@ -7,7 +7,8 @@ import {firstPromptLine,buildIndicator,HUD_STALE_DROP_MS,- type HudRow+ type HudRow,+ WORKING_STALE_MS} from './notch-hud-model'const T0 = 1_000_000@@ -192,9 +193,11 @@ describe('6h drop', () => {expect(rowFor(rows, 'present')?.state).toBe('done')})- it('never drops a working node', () => {+ it('never drops a LIVE working node', () => {const m = createHudModel()m.applyStateChange(stateChange({ nodeId: 'w', state: 'working', ts: T0 }))+ // Keep it alive across the 6h mark — a node still reporting activity is never dropped.+ m.applyNowChange({ nodeId: 'w', ts: T0 + HUD_STALE_DROP_MS, activity: 'still going' } as never)expect(m.prune(T0 + HUD_STALE_DROP_MS + 1)).toBe(false)expect(rowFor(m.buildRows(T0 + HUD_STALE_DROP_MS + 1, titleOf), 'w')?.state).toBe('working')})@@ -266,3 +269,33 @@ describe('mirror restore', () => {expect(rowFor(m.buildRows(T0 + 1, titleOf), 'a')?.state).toBe('needsYou')})})++describe('working watchdog', () => {+ it('stops showing a working node nobody has heard from, and restores it on any event', () => {+ const m = createHudModel()+ m.applyStateChange(stateChange({ nodeId: 'w', state: 'working', agentId: 'claude', ts: T0 }))+ // A long turn is still working — the gap has to be big before we presume anything.+ expect(rowFor(m.buildRows(T0 + WORKING_STALE_MS - 1, titleOf), 'w')?.state).toBe('working')+ // Past the window (Esc during a tool call, killed CLI, slept machine): the row goes quiet.+ expect(rowFor(m.buildRows(T0 + WORKING_STALE_MS + 1, titleOf), 'w')).toBeUndefined()+ // DISPLAY-only: one live event and it's back, no state was destroyed.+ m.applyNowChange({ nodeId: 'w', ts: T0 + WORKING_STALE_MS + 2, activity: 'Running tests' } as never)+ expect(rowFor(m.buildRows(T0 + WORKING_STALE_MS + 3, titleOf), 'w')?.state).toBe('working')+ })++ it('lets a stale working node be pruned once it is gone from the mirror', () => {+ const m = createHudModel()+ m.applyStateChange(stateChange({ nodeId: 'w', state: 'working', ts: T0 }))+ expect(m.prune(T0 + WORKING_STALE_MS + 1)).toBe(false) // stale, but not yet past the 6h drop+ expect(m.prune(T0 + HUD_STALE_DROP_MS + 1)).toBe(true)+ })+})++describe('interrupted turns', () => {+ it('an Esc-interrupted done never lights the finished highlight', () => {+ const m = createHudModel()+ m.applyStateChange(stateChange({ nodeId: 'a', state: 'working', ts: T0 }))+ m.applyStateChange({ ...stateChange({ nodeId: 'a', state: 'done', ts: T0 + 1 }), interrupted: true })+ expect(rowFor(m.buildRows(T0 + 2, titleOf), 'a')).toBeUndefined()+ })+})diff --git a/src/main/notch-hud-model.ts b/src/main/notch-hud-model.tsindex 1cf423f40..9ec5e50ac 100644--- a/src/main/notch-hud-model.ts+++ b/src/main/notch-hud-model.ts@@ -13,6 +13,18 @@ import type { NodeStateChange, NodeNowChange, MirrorFile } from '../core/agent-s/** A node dropped once it's gone from the mirror AND has been idle longer than this. */export const HUD_STALE_DROP_MS = 6 * 60 * 60 * 1000+/**+ * A `working` node with NO event for this long stops being displayed as working.+ *+ * A session leaves `working` only when something says so — and some exits say nothing: an Esc+ * during a tool call, a killed CLI, a machine that slept, an SSH drop. The node then walks its+ * mascot forever. This is the watchdog, and it is deliberately DISPLAY-ONLY: the state is not+ * mutated, so any later event (a tool result, a new turn, a mirror flush) brings the row straight+ * back. 20 min is well past a real gap between hook events — Claude's Bash tool caps out around 10+ * — so a genuinely long turn is never hidden.+ */+export const WORKING_STALE_MS = 20 * 60 * 1000+/** The phone-facing bucket the HUD colors rows by. `idle` = a seen/finished session. */export type HudRowState = 'working' | 'needsYou' | 'done' | 'idle'@@ -141,8 +153,10 @@ export function createHudModel(): HudModel {// A fresh working edge clears a stale done highlight.a.doneSeen = false} else if (c.state === 'done') {- // New done → unseen (highlight it) unless this end was an explicit read-ack.- a.doneSeen = c.ack === true ? true : false+ // New done → unseen (highlight it) unless this end was an explicit read-ack, or the turn was+ // INTERRUPTED (Esc): nothing was accomplished, so there is nothing to go and read. Same rule+ // the notification path uses.+ a.doneSeen = c.ack === true || c.interrupted === true}}@@ -243,14 +257,15 @@ export function createHudModel(): HudModel {if (!a) return// Latch the state we're hiding AT, not a boolean: a node stuck in `working` stays hidden, but// the moment it really moves (done / needs-you / a new turn) it earns its row back.- a.dismissedAt = displayState(a)+ a.dismissedAt = a.stateif (a.state === 'done') a.doneSeen = true}function prune(now: number): boolean {let changed = falsefor (const [nodeId, a] of nodes) {- if (a.state === 'working') continue+ // A LIVE working node is never dropped; a stale one (watchdog above) is fair game.+ if (a.state === 'working' && now - a.updatedAt <= WORKING_STALE_MS) continueif (a.presentInMirror) continueif (now - a.updatedAt > HUD_STALE_DROP_MS) {nodes.delete(nodeId)@@ -260,19 +275,23 @@ export function createHudModel(): HudModel {return changed}- function displayState(a: NodeAccum): HudRowState {+ function displayState(a: NodeAccum, now: number): HudRowState {// A done session that's been acknowledged demotes to idle (drops out of the row list below).if (a.state === 'done' && a.doneSeen) return 'idle'+ // Watchdog: a working session nobody has heard from in WORKING_STALE_MS is presumed gone.+ if (a.state === 'working' && now - a.updatedAt > WORKING_STALE_MS) return 'idle'return a.state}- function buildRows(_now: number, getTitle: (nodeId: string) => string | undefined): HudRow[] {+ function buildRows(now: number, getTitle: (nodeId: string) => string | undefined): HudRow[] {const rows: HudRow[] = []for (const [nodeId, a] of nodes) {- const state = displayState(a)+ const state = displayState(a, now)// The HUD shows active sessions only — nothing when a node is idle/seen.if (state === 'idle') continue- if (a.dismissedAt === state) continue+ // Compare against the RAW state, not the display one: the watchdog can flip a dismissed+ // node's display to idle and back without that counting as "it changed".+ if (a.dismissedAt === a.state) continuea.dismissedAt = undefinedconst model = a.sessionId ? modelBySession.get(a.sessionId) : undefinedrows.push({diff --git a/src/main/notch-hud.ts b/src/main/notch-hud.tsindex 468dc5d4c..8c55308f3 100644--- a/src/main/notch-hud.ts+++ b/src/main/notch-hud.ts@@ -47,7 +47,8 @@ const HUD_WINDOW_HEIGHT = 460/** Debounce for coalescing feed changes into one push to the HUD renderer. */const PUSH_DEBOUNCE_MS = 150/** Low-frequency sweep so stale (gone + idle > 6h) nodes drop even with no live events. */-const SWEEP_MS = 10 * 60 * 1000+// Also the tick that lets the model's working watchdog and the relative times age without events.+const SWEEP_MS = 60 * 1000/*** Keep the app a REGULAR Dock app even though the HUD is a `focusable:false` (non-activating@@ -168,7 +169,10 @@ class NotchHudController {screen.on('display-added', this.onDisplayChange)screen.on('display-removed', this.onDisplayChange)this.sweepTimer = setInterval(() => {- if (this.model.prune(Date.now())) this.schedulePush()+ // Always re-push: the working watchdog and the relative timestamps both age with the clock,+ // so a row has to be able to change with no incoming event at all.+ this.model.prune(Date.now())+ this.schedulePush()}, SWEEP_MS)this.sweepTimer.unref?.()}