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): one prompt length, one indicator rule, two docs that told the truth again
enes5bbe7a7e8872
diff --git a/docs/notch-hud.md b/docs/notch-hud.mdindex 0a661705a..8a8bdacce 100644--- a/docs/notch-hud.md+++ b/docs/notch-hud.md@@ -18,9 +18,10 @@ alwaysOnTop:true, focusable:false, skipTaskbar:true}` + `setAlwaysOnTop(true,'sc- **Geometry** from `screen.getPrimaryDisplay()`: the window spans the full top edge (`bounds`,`y = bounds.y`), sized to the EXPANDED box (`HUD_WINDOW_HEIGHT`); we never resize the frame. Mainsends the renderer everything it needs to draw the capsule: `bar` (= `workArea.y - bounds.y`,- floor `NOTCH_BAR_FLOOR` 24 — the fused top zone height), `width`, `notchWidth` (= `NOTCH_WIDTH`,- ~200, a tunable — Electron exposes no `auxiliaryTopLeftArea`, so assume a centered notch of this- width), `notchCenterX` (= `bounds.width/2`), and `hasNotch` (`inset > 0 && inset >= NOTCH_MIN_BAR`+ floor `NOTCH_BAR_FLOOR` 24 — the fused top zone height), `width`, `notchWidth` (`settings.notchWidth`+ clamped to `NOTCH_WIDTH_MIN/MAX` 100–320, falling back to `NOTCH_WIDTH` **168** — Electron exposes+ no `auxiliaryTopLeftArea`, so assume a centered notch of this width; 200 left a visible gap),+ `notchCenterX` (= `bounds.width/2`), and `hasNotch` (`inset > 0 && inset >= NOTCH_MIN_BAR`32 — a notched Mac's menu bar is ~37 px vs ~24 on a notchless display; when false the rendererdraws a standalone floating pill instead of fusing). Re-asserted on `screen``display-metrics-changed` + `display-added/removed`.@@ -46,8 +47,11 @@ Row shape sent to the HUD:```ts{ nodeId, agentId, title, model?, state: 'working'|'needsYou'|'done'|'idle',prompt?, activity?, contextPercent?,- subagents: [{ id, label?, state: 'working'|'done' }] }+ subagents: [{ id, label?, state: 'working'|'done' }], updatedAt }```+- **`prompt` is clipped at the mirror's `PROMPT_MAX` (120)** — `firstPromptLine` imports that+ constant rather than keeping its own number, because the phone's Live Activity line is fed by the+ SAME `onNodeStateChange` seam and the two surfaces must not show one prompt at two lengths.- **done latch + clear**: `done` state is latched by the mirror already. Clearing is **strictly perrow**: clicking/Go-ing a row (`hudFocusNode` → `model.noteFocus`) clears THAT node, and reading thesession inside nodeterm clears it through the mirror's read-ack (`state:'done', ack:true`). Opening@@ -77,7 +81,9 @@ Row shape sent to the HUD:Reuse `src/renderer/lib/mascot.ts` (`CLAUDE_MASCOT` data-URI + `CODEX_MASCOT` geometry +`pet-codex.webp`) and the walk-cycle CSS from AgentMascot/styles.css — plain DOM, no React-coupling needed (React optional; keep the HUD lean). Master clock 120 ms.+coupling needed (React optional; keep the HUD lean). Animation is CSS-driven, not a JS clock: the+claude walk cycle is `0.8s steps(1)` (2 frames) and the brand-mark breathe `1.6s ease-in-out`, both+disabled under `prefers-reduced-motion`.The HUD is **one black rounded-bottom capsule (`.hud-capsule`) that EXTENDS the physical notch** —fused, seamless: its TOP edge is at `y=0` sharing the notch's black (top corners SQUARE), only the@@ -86,17 +92,22 @@ BOTTOM corners are rounded (`--capsule-radius`), and it is anchored at the notchthe click-through hotspot (`pointerenter` → main `setIgnoreMouse(false)`, leave → `true` + collapse);the transparent rest of the window stays click-through. Hidden entirely when idle (no empty pill).-- **Collapsed capsule**: width = `--notch-width` (so it reads as the notch itself), height =- `--bar + --capsule-drop` — it hangs `--capsule-drop` (~28 px) BELOW the menu-bar line, the classic- Dynamic-Island bulge. The indicator content is pushed past the fused top zone- (`padding-top: var(--bar)`) so the **mascots sit in that drop zone, below the bar line** — the- intended content zone (this is what fixes the old "mascots floating below the bar, beside the- notch" reading: the black capsule now frames them there, reading as the notch swelling). A slot per- agent kind that is working: claude → 2-frame coral pixel mascot walking; codex → the pet- spritesheet first-row crop (`image-rendering: pixelated`); plus a shimmering green blob for a+- **Collapsed capsule**: never taller than the real notch (owner: "notch'a ekstra height vermek+ istemiyorum"). It is `--bar` tall (`max-height`), shrink-to-fit wide, anchored at the notch's+ horizontal centre, and the mascots are vertically centred in that strip — the notch reads as+ WIDER, not taller, so the Dynamic-Island bulge below the bar line was dropped (`--capsule-drop` is+ now `0px` and only survives for the expand math). The content occupies the strip LEFT of the+ notch, so `syncCapsuleSymmetry` pads the right by `notchWidth + measured content width` and the+ black sticks out by the same amount on both sides. The collapsed content is decided by ONE pure+ rule, `buildIndicator` (`src/renderer/hud/indicator.ts`, unit-tested with `orderIndicatorAgents`):+ a slot per agent kind that is working: claude → 2-frame coral pixel mascot walking; codex → the pet+ spritesheet first-row crop (`image-rendering: pixelated`); grok/gemini/opencode → their own brand+ mark breathing instead of a critter (`lib/brandPulse.ts`, the same call the canvas badge makes);+ plus a shimmering green blob for adone-unseen slot and a red "needs you" dot for a waiting session (so the capsule is never an emptyblack pill). Nothing shown when all idle.-- **Expanded panel**: clicking grows the SAME black surface — width → `--panel-width`, height+- **Expanded panel**: clicking — or, with `settings.notchHoverExpand` on (the default), hovering for+ `HOVER_OPEN_MS` (180 ms) — grows the SAME black surface — width → `--panel-width`, height(driven by `max-height`, so content of unknown height animates) → the rows box, bottom cornersstill rounded, top still fused — a spring-ish `--capsule-dur` (~220 ms) `--capsule-ease` expandfrom the notch, NOT a separate floating panel. Rows fade in and start below the bar line@@ -116,9 +127,11 @@ the transparent rest of the window stays click-through. Hidden entirely when idlCollapsed height = `--pill-height`; the mascots center in the pill (no `--bar` padding to clear).**Tunables** (main constants in `notch-hud.ts`; CSS vars in `hud.css :root`, defaults in parens —-tune on a Mac): `NOTCH_WIDTH` (200) / `--notch-width`, `NOTCH_MIN_BAR` (32, notch-detection-threshold), `NOTCH_BAR_FLOOR` (24), `--capsule-drop` (28 px bulge — must exceed the tallest mascot),-`--capsule-radius` (16), `--panel-width` (400), `--panel-max-h` (420), `--capsule-dur`/`--capsule-ease`,+tune on a Mac): `NOTCH_WIDTH` (168) / `--notch-width` (the CSS fallback is 200; main pushes the real+value on the first geometry push), `NOTCH_WIDTH_MIN/MAX` (100/320, the settings clamp),+`NOTCH_MIN_BAR` (32, notch-detection threshold), `NOTCH_BAR_FLOOR` (24), `HUD_WINDOW_HEIGHT` (460),+`--capsule-drop` (0 — the bulge was dropped; kept only for the expand math),+`--capsule-radius` (16), `--panel-width` (400), `--panel-max-h` (420), `--capsule-dur` (0.22s)/`--capsule-ease`,and the notchless `--pill-top-gap` (6) / `--pill-radius` (18) / `--pill-height` (30).## Settings + lifecyclediff --git a/src/main/notch-hud-model.test.ts b/src/main/notch-hud-model.test.tsindex e37bc0287..0896071ee 100644--- a/src/main/notch-hud-model.test.ts+++ b/src/main/notch-hud-model.test.ts@@ -1,11 +1,11 @@import { describe, it, expect } from 'vitest'import type { NormalizedAgentEvent } from '@shared/agents/normalize'import type { NodeStateChange, NodeNowChange, MirrorFile } from '../core/agent-status-mirror'+import { PROMPT_MAX, firstLine } from '../core/agent-status-mirror'import {createHudModel,bucketState,firstPromptLine,- buildIndicator,HUD_STALE_DROP_MS,type HudRow,WORKING_STALE_MS@@ -45,6 +45,14 @@ describe('firstPromptLine', () => {expect(clipped.length).toBe(10)expect(clipped.endsWith('…')).toBe(true)})++ it('clips at the mirror’s PROMPT_MAX by default, so both surfaces say the same sentence', () => {+ // The HUD row and the phone's Live Activity line are fed by the same seams and must not show+ // one prompt at two lengths (the HUD used to clip at 140 while the mirror clipped at 120).+ const clipped = firstPromptLine('y'.repeat(300))!+ expect(clipped.length).toBe(PROMPT_MAX)+ expect(clipped).toBe(firstLine('y'.repeat(300), PROMPT_MAX))+ })})describe('createHudModel — state → bucket', () => {@@ -203,19 +211,18 @@ describe('6h drop', () => {})})-describe('buildIndicator + ordering', () => {- it('lists distinct working agents and flags done-unseen', () => {+// The collapsed-indicator aggregation is NOT here: it is the renderer's pure `buildIndicator`+// (src/renderer/hud/indicator.ts + indicator.test.ts), the only side that draws it.+describe('row ordering', () => {+ it('sorts newest-active first', () => {const m = createHudModel()m.applyStateChange(stateChange({ nodeId: 'a', state: 'working', agentId: 'claude', ts: T0 + 1 }))m.applyStateChange(stateChange({ nodeId: 'b', state: 'working', agentId: 'codex', ts: T0 + 2 }))m.applyStateChange(stateChange({ nodeId: 'c', state: 'working', agentId: 'claude', ts: T0 + 3 }))m.applyStateChange(stateChange({ nodeId: 'd', state: 'done', agentId: 'gemini', ts: T0 + 4 }))const rows = m.buildRows(T0 + 10, titleOf)- // newest-active firstexpect(rows.map((r) => r.nodeId)).toEqual(['d', 'c', 'b', 'a'])- const ind = buildIndicator(rows)- expect(ind.workingAgents.sort()).toEqual(['claude', 'codex'])- expect(ind.doneUnseen).toBe(true)+ expect(rows.map((r) => r.state)).toEqual(['done', 'working', 'working', 'working'])})})diff --git a/src/main/notch-hud-model.ts b/src/main/notch-hud-model.tsindex 18af985a7..0ec498115 100644--- a/src/main/notch-hud-model.ts+++ b/src/main/notch-hud-model.ts@@ -5,9 +5,11 @@// table, and the normalized agent-event stream for prompt + subagents, plus context-update for the// model) into the row array the HUD renderer draws. Kept separate from the window so vitest can// cover the state→bucket mapping, subagent grouping, the done latch, the 6h drop, and the-// prompt/model join without an Electron runtime. Imports only TYPES from core, never electron.+// prompt/model join without an Electron runtime. Imports TYPES from core plus the one shared+// clipping constant (PROMPT_MAX) — never electron.import type { NormalizedAgentEvent, AgentState } from '../shared/agents/normalize'+import { PROMPT_MAX } from '../core/agent-status-mirror'import type { NodeStateChange, NodeNowChange, MirrorFile } from '../core/agent-status-mirror'import { WORKING_STALE_MS } from '@shared/agents/stale'@@ -46,14 +48,10 @@ export interface HudRow {updatedAt: number}-/** Collapsed-indicator aggregation: which agent kinds are actively working, and whether any- * finished-but-unseen session should show the green "done" blob. */-export interface HudIndicator {- /** Distinct agentIds that have at least one working node (drives a walking mascot slot each). */- workingAgents: string[]- /** True if any row is a finished-but-unseen (`done`) session. */- doneUnseen: boolean-}+// The collapsed-indicator aggregation used to be duplicated here (`buildIndicator`/`HudIndicator`)+// with no production caller — the HUD renderer, which is the only thing that draws it, cannot+// import src/main. It lived on as dead code and drifted (it never learned the `needsYou` dot the+// renderer draws). The single definition is now `buildIndicator` in src/renderer/hud/indicator.ts.interface NodeAccum {agentId?: string@@ -82,8 +80,17 @@ export function bucketState(s: AgentState): Exclude<HudRowState, 'idle'> {return 'needsYou' // waiting | blocked}-/** First non-empty line of a prompt/message, trimmed and clipped — the second-line summary. */-export function firstPromptLine(text: string | undefined, max = 140): string | undefined {+/**+ * First non-empty line of a prompt/message, trimmed and clipped — the second-line summary.+ *+ * The default clip is the mirror's `PROMPT_MAX`, the SAME constant the phone's Live Activity line+ * is cut at (core/agent-status-mirror.ts): both surfaces are fed by `onNodeStateChange` /+ * `onNodeNowChange` and are meant to say the same sentence, so one prompt must not appear at two+ * lengths. The HUD's own 140 was never load-bearing — `.hud-row__sub` is a single nowrap line with+ * `text-overflow: ellipsis` inside a ~400 px panel, so the visible cut is the CSS one either way.+ * `max` stays a parameter so the helper is reusable for any other clip.+ */+export function firstPromptLine(text: string | undefined, max = PROMPT_MAX): string | undefined {if (!text) return undefinedconst line = text.split('\n')@@ -320,18 +327,3 @@ export function createHudModel(): HudModel {buildRows}}--/** Pure collapsed-indicator aggregation from the built rows. */-export function buildIndicator(rows: HudRow[]): HudIndicator {- const workingAgents: string[] = []- let doneUnseen = false- for (const r of rows) {- if (r.state === 'working') {- const id = r.agentId || 'unknown'- if (!workingAgents.includes(id)) workingAgents.push(id)- } else if (r.state === 'done') {- doneUnseen = true- }- }- return { workingAgents, doneUnseen }-}diff --git a/src/renderer/hud/indicator.test.ts b/src/renderer/hud/indicator.test.tsindex b063d6827..420947c07 100644--- a/src/renderer/hud/indicator.test.ts+++ b/src/renderer/hud/indicator.test.ts@@ -1,5 +1,48 @@import { describe, it, expect } from 'vitest'-import { orderIndicatorAgents } from './indicator'+import { buildIndicator, orderIndicatorAgents, type IndicatorRow } from './indicator'++const row = (state: IndicatorRow['state'], agentId?: string): IndicatorRow => ({ state, agentId })++describe('buildIndicator', () => {+ it('lists distinct working agents in first-seen order and flags done-unseen', () => {+ const ind = buildIndicator([+ row('done', 'gemini'),+ row('working', 'claude'),+ row('working', 'codex'),+ row('working', 'claude')+ ])+ expect(ind.workingAgents).toEqual(['claude', 'codex'])+ expect(ind.doneUnseen).toBe(true)+ expect(ind.needsYou).toBe(false)+ })++ it('flags needsYou, so a waiting session is never an empty black pill', () => {+ // The rule this aggregation is the single definition of: a session waiting on the user with+ // nothing working must still put the red dot in the collapsed capsule.+ const ind = buildIndicator([row('needsYou', 'claude')])+ expect(ind.needsYou).toBe(true)+ expect(ind.workingAgents).toEqual([])+ expect(ind.doneUnseen).toBe(false)+ })++ it('buckets a working row with no agentId under "unknown"', () => {+ expect(buildIndicator([row('working')]).workingAgents).toEqual(['unknown'])+ })++ it('ignores idle rows and handles an empty list', () => {+ expect(buildIndicator([row('idle', 'claude')])).toEqual({+ workingAgents: [],+ doneUnseen: false,+ needsYou: false+ })+ expect(buildIndicator([])).toEqual({ workingAgents: [], doneUnseen: false, needsYou: false })+ })++ it('reports all three at once', () => {+ const ind = buildIndicator([row('working', 'codex'), row('done', 'claude'), row('needsYou', 'gemini')])+ expect(ind).toEqual({ workingAgents: ['codex'], doneUnseen: true, needsYou: true })+ })+})describe('orderIndicatorAgents', () => {it('puts Claude rightmost (last) and Codex to its left, matching agent-notch', () => {diff --git a/src/renderer/hud/indicator.ts b/src/renderer/hud/indicator.tsindex d218d4ec4..33d4416ba 100644--- a/src/renderer/hud/indicator.ts+++ b/src/renderer/hud/indicator.ts@@ -1,12 +1,55 @@-// Pure ordering for the collapsed Notch HUD indicator (docs/notch-hud.md).+// Pure aggregation + ordering for the collapsed Notch HUD indicator (docs/notch-hud.md).//-// The indicator hugs the LEFT edge of the notch and reads right→left. agent-notch draws Claude+// `buildIndicator` is the ONE definition of what the collapsed capsule shows, derived from the same+// row array the expanded panel draws. It lives here rather than beside the main-process HUD model+// because the renderer is the only side that draws it, and a renderer must never import src/main+// (process-model boundary) — a copy over there could only ever be dead code that drifts, which is+// exactly what happened: it never grew the `needsYou` dot this renderer has been drawing.+//+// The ordering below: the indicator hugs the LEFT edge of the notch and reads right→left. agent-notch draws Claude// rightmost (nearest the notch) and Codex to its left (main.swift IndicatorView.draw: claude is// drawn first at bounds.maxX, then codex to the left). Our indicator is a normal left→right flex// row, so the LAST element is the rightmost/notch-side one. This helper returns the working agent// ids in left→right paint order (Claude last) so the DOM matches agent-notch's slot order.//-// Kept pure + Electron-free so it is unit-tested without a DOM.+// Kept pure + Electron-free so both are unit-tested without a DOM.++/** The minimal row shape the aggregation reads — a structural subset of the HUD row contract, so+ * this module needs no type from main/preload (main.ts mirrors that contract locally on purpose). */+export interface IndicatorRow {+ state: 'working' | 'needsYou' | 'done' | 'idle'+ agentId?: string+}++/** What the collapsed capsule draws: a walking mascot per working agent kind, plus the two dots. */+export interface HudIndicator {+ /** Distinct agentIds that have at least one working node (drives a walking mascot slot each),+ * in first-seen order — pass through `orderIndicatorAgents` for the paint order. */+ workingAgents: string[]+ /** True if any row is a finished-but-unseen (`done`) session → the green blob. */+ doneUnseen: boolean+ /** True if any row is waiting/blocked (`needsYou`) → the red dot. Without it the capsule reads as+ * EMPTY (and hides) for a session that is waiting on the user while nothing else is working. */+ needsYou: boolean+}++/** Fold the HUD rows into the collapsed indicator's content. */+export function buildIndicator(rows: readonly IndicatorRow[]): HudIndicator {+ const workingAgents: string[] = []+ let doneUnseen = false+ let needsYou = false+ for (const r of rows) {+ if (r.state === 'working') {+ const id = r.agentId || 'unknown'+ if (!workingAgents.includes(id)) workingAgents.push(id)+ } else if (r.state === 'done') {+ doneUnseen = true+ } else if (r.state === 'needsYou') {+ needsYou = true+ }+ }+ return { workingAgents, doneUnseen, needsYou }+}/** Higher rank = drawn further RIGHT (closer to the notch). Claude is the notch-side anchor. */const SLOT_RANK: Record<string, number> = {diff --git a/src/renderer/hud/main.ts b/src/renderer/hud/main.tsindex 9dd866e94..7cac160f9 100644--- a/src/renderer/hud/main.ts+++ b/src/renderer/hud/main.ts@@ -7,7 +7,7 @@ import './hud.css'import { CLAUDE_MASCOT, CODEX_MASCOT, DONE_BLOB } from '../lib/mascot'import { HUD_BRAND_PULSE_CLASS, brandPulseBackground, brandPulsePlan } from '../lib/brandPulse'import { createGrokMarkSvg } from '../lib/grokMark'-import { orderIndicatorAgents } from './indicator'+import { buildIndicator, orderIndicatorAgents } from './indicator'import codexPet from '../assets/pet-codex.webp'// Local mirror of the preload's HUD contract (src/preload/hud.ts) — kept self-contained so this@@ -219,19 +219,9 @@ function rowIcon(row: HudRow): Element {function renderIndicator(rows: HudRow[]): void {indicator.replaceChildren()- const workingAgents: string[] = []- let doneUnseen = false- let needsYou = false- for (const r of rows) {- if (r.state === 'working') {- const id = r.agentId || 'unknown'- if (!workingAgents.includes(id)) workingAgents.push(id)- } else if (r.state === 'done') {- doneUnseen = true- } else if (r.state === 'needsYou') {- needsYou = true- }- }+ // The aggregation is the pure `buildIndicator` (./indicator) — one definition of the rule, unit+ // tested; this function only paints its result.+ const { workingAgents, doneUnseen, needsYou } = buildIndicator(rows)// Left→right paint order, centered inside the capsule's drop zone: a red "needs you" dot and the// green "done" blob sit furthest left, then the working mascots with Claude last (notch-side).// Surfacing needsYou here keeps the collapsed capsule meaningful (never an empty black pill) for adiff --git a/src/shared/ipc.ts b/src/shared/ipc.tsindex 98fa4cb10..86ed60f68 100644--- a/src/shared/ipc.ts+++ b/src/shared/ipc.ts@@ -88,7 +88,12 @@ export const IPC = {/** hud → main: a HUD row was clicked — focus the node in nodeterm + clear its done latch.* Arg: `nodeId: string`. Reuses the notification-click focus path. */hudFocusNode: 'hud:focus-node',- /** hud → main: the panel expanded/collapsed. `true` clears every done latch (you looked). */+ /** hud → main: the panel expanded/collapsed. Arg: `expanded: boolean`. Marks NOTHING as read —+ * the handler is deliberately a no-op (notch-hud.ts `onExpanded`). It used to clear every done+ * latch ("you looked"), which with three finished sessions waiting meant opening the panel and+ * clicking one silently swallowed the other two. Read is strictly per row: `hudFocusNode` clears+ * that row, `hudDismiss` hides one by hand. Still wired because the expand state may drive more+ * main-side behavior later. */hudExpanded: 'hud:expanded',/** hud → main: dismiss one HUD row by hand (a stuck session). Arg: `nodeId: string`. */hudDismiss: 'hud:dismiss',