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
feat(macos): notch HUD — walking agent mascots beside the notch + mini panel
enes28eefa2016d0
diff --git a/docs/notch-hud.md b/docs/notch-hud.mdnew file mode 100644index 000000000..9c3056e4c--- /dev/null+++ b/docs/notch-hud.md@@ -0,0 +1,80 @@+# Notch HUD (macOS) — contract++Agent-notch's UX, native to nodeterm: a transparent always-on-top strip along the top edge that+shows **walking agent mascots beside the MacBook notch** while agents work, and expands on click+into a **mini session panel**. macOS-only, desktop-only. Fed by nodeterm's own hook-based+agent-status (precise working/done — no ~30 s afterglow), reusing nodeterm's existing mascot art.+Owner decisions: hook-fed; its own mini panel with a "Go" button that opens the node in nodeterm;+**default ON** (guarded to darwin; toggleable in Settings).++## Window (src/main/notch-hud.ts, new)++One BrowserWindow: `{frame:false, transparent:true, hasShadow:false, resizable:false,+alwaysOnTop:true, focusable:false, skipTaskbar:true}` + `setAlwaysOnTop(true,'screen-saver')` ++`setVisibleOnAllWorkspaces(true,{visibleOnFullScreen:true})` + `setIgnoreMouseEvents(true,+{forward:true})`. Its own renderer entry `hud.html` (add to electron.vite.config.ts+`renderer.input`) sharing the existing preload plus a small HUD-specific API.++- **Geometry** from `screen.getPrimaryDisplay()`: strip at `bounds.y`, full `bounds.width`, height+ = notch bar height (`workArea.y - bounds.y`, floor 24). The notch is centered at `bounds.width/2`;+ Electron exposes no `auxiliaryTopLeftArea`, so assume a centered notch and place the mascot slot+ just LEFT of center (fake notch width ~200 px when `workArea.y === bounds.y`, i.e. no physical+ notch → center on a virtual pill). Re-assert on `screen` `display-metrics-changed` ++ `display-added/removed`.+- **Click-through with a hotspot**: window stays mouse-ignoring; the renderer reports pointer+ enter/leave of the indicator rect over IPC → main toggles `setIgnoreMouseEvents(false/true,+ {forward:true})`. Click in the hotspot → expand; click outside the expanded panel → collapse+ (a `blur`/global-ish check — simplest: an app-level click-away by tracking pointer-leave of the+ expanded bounds). Never animate the window frame — size it to the expanded box, drive a CSS+ `transform: scale()` from `transform-origin: top center` (≈0.25×0.06 → 1, 200 ms ease) + opacity+ for expand/collapse.++## Data (main-side controller, no core changes)++Subscribe to the SAME seams push-notify uses (`agent-status-mirror.ts`): `onNodeStateChange`+(working/needsYou/done edges), `onNodeNowChange` (activity + context%), `onMirrorFlush` (full+table). Join per node: `workspaceStore.getNodeTitle(nodeId)` (title), `IPC.contextUpdate` (model,+by sessionId), and a controller-local `Map<nodeId,lastPrompt>` fed from `emitAgentStatus`'s+`ev.task` on `newTurn` (no core change), plus a `Map<nodeId,Set<toolUseId>>` for subagents off the+subagent-start/end events (main already keeps `nodeSubagents`). Push a debounced snapshot array to+the HUD window via a `getHudWindow()`/`sendToHud()` singleton (mirror `main-window.ts`).++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' }] }+```+- **done latch + clear**: `done` state is latched by the mirror already; clear a node's done+ highlight when the user focuses that node in nodeterm (reuse `app:focus-node`) OR after the HUD+ panel is opened — a nodeterm-native "you looked at it" signal (better than agent-notch's+ terminal-bundle-id sniff). Drop a node from the HUD when it's gone + idle > 6 h.++## Indicator + panel (hud renderer)++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.+- **Indicator (collapsed)**: right-aligned toward the notch — a slot per agent kind that has a+ working/done node: claude → 2-frame coral pixel mascot walking (2.5 fps); codex → the pet+ spritesheet first-row crop (8 frames, 120 ms, `image-rendering: pixelated`); a shimmering green+ blob for a done-unseen slot. Nothing shown when all idle.+- **Panel (expanded)**: up to ~6 session rows, newest-active first. Each row: animated mascot/green+ check + title + `model · reltime` tag (blue working / gray idle / green done) + a `You: <prompt>`+ (or `activity`) second line + a `▸ N subagents` disclosure (child rows: label + state). A **Go**+ button (or row-tap) → IPC → main mirrors the notification-click handler:+ `getMainWindow().show()/focus()` + `sendToMain(app:focus-node, nodeId)` → `Canvas.focusNodeById`,+ and clears that node's done latch.++## Settings + lifecycle++New `settings.notchHud` (default **true**). `initNotchHud(win)` from `index.ts`, guarded+`process.platform === 'darwin'` and the setting; toggling the setting creates/destroys the HUD+window live. Three-surfaces: desktop/macOS-only — `src/server` and iOS untouched (pure reader of+existing main state; the no-electron tests stay green because all new code is in `src/main` + a+renderer entry).++## Out of scope (v1)++Pet-switching config, non-darwin (Windows/Linux) HUD, per-row context menu, multi-monitor notch+precision beyond centering, the SDK chat node in the panel.diff --git a/electron.vite.config.ts b/electron.vite.config.tsindex 6befc2805..13a5884b4 100644--- a/electron.vite.config.ts+++ b/electron.vite.config.ts@@ -40,7 +40,11 @@ export default defineConfig({},build: {rollupOptions: {- input: { index: resolve(__dirname, 'src/preload/index.ts') },+ input: {+ index: resolve(__dirname, 'src/preload/index.ts'),+ // Tiny HUD-only preload for the macOS Notch HUD window (src/main/notch-hud.ts).+ hud: resolve(__dirname, 'src/preload/hud.ts')+ },external: ['electron'],output: {// Same CJS requirement for the preload script inside asar.@@ -61,7 +65,11 @@ export default defineConfig({plugins: [react(), tailwindcss()],build: {rollupOptions: {- input: { index: resolve(__dirname, 'src/renderer/index.html') }+ input: {+ index: resolve(__dirname, 'src/renderer/index.html'),+ // Second renderer entry: the macOS Notch HUD overlay window (src/main/notch-hud.ts).+ hud: resolve(__dirname, 'src/renderer/hud.html')+ }}}}diff --git a/src/core/settings-store.ts b/src/core/settings-store.tsindex f8a7e2e13..0db07d2ce 100644--- a/src/core/settings-store.ts+++ b/src/core/settings-store.ts@@ -24,11 +24,20 @@ function mergeSettings(saved: Partial<Settings> | null | undefined): Settings {*/export class SettingsStore {private cache: Settings = DEFAULT_SETTINGS+ private listeners = new Set<(s: Settings) => void>()private get filePath(): string {return path.join(platform().userDataDir, 'settings.json')}+ /** Subscribe to saves (fires after each successful `settings:save`). Additive; used by the+ * desktop shell to create/destroy runtime-toggled subsystems (e.g. the Notch HUD). Returns an+ * unsubscribe. Never throws into a save. */+ onChange(cb: (s: Settings) => void): () => void {+ this.listeners.add(cb)+ return () => this.listeners.delete(cb)+ }+/** Load synchronously into cache (call after app is ready). */init(): void {try {@@ -51,6 +60,13 @@ export class SettingsStore {const tmp = `${this.filePath}.tmp`await fs.writeFile(tmp, JSON.stringify(this.cache, null, 2), 'utf-8')await fs.rename(tmp, this.filePath)+ for (const cb of this.listeners) {+ try {+ cb(this.cache)+ } catch {+ // A listener must never break a settings save (or its siblings).+ }+ }})}}diff --git a/src/main/index.ts b/src/main/index.tsindex 81f85724f..dadf71106 100644--- a/src/main/index.ts+++ b/src/main/index.ts@@ -26,6 +26,13 @@ import {syntheticAnsweredEvent} from '../core/agents/pending-approvals'import { setMainWindow, getMainWindow, sendToMain, shouldHideOnClose } from './main-window'+import {+ initNotchHud,+ setNotchHudEnabled,+ destroyNotchHud,+ notchHudOnAgentEvent,+ notchHudOnContextUpdate+} from './notch-hud'import {initAgentStatusMirror,onMirrorFlush,@@ -729,6 +736,10 @@ app.whenReady().then(async () => {})// Mirror live agent status to <userData>/agent-status.json for the external mobile host agent.initAgentStatusMirror()+ // macOS Notch HUD (docs/notch-hud.md): walking agent mascots by the notch. darwin + setting only;+ // reads the same agent-status seams the mirror does. Live-toggled via settings below.+ initNotchHud({ getNodeTitle: (nodeId) => workspaceStore.getNodeTitle(nodeId) }, settingsStore.get().notchHud)+ settingsStore.onChange((s) => setNotchHudEnabled(s.notchHud))// Advertise launch settings to the mobile companion through the mirror. The provider is// consulted at every flush (heartbeat ≤60s), so a settings change propagates without extra// plumbing. Caps arrive async: re-flush once the memoized probe answers.@@ -946,6 +957,8 @@ app.whenReady().then(async () => {}const contextTail = createContextTail((payload) => {if (!win.isDestroyed()) win.webContents.send(IPC.contextUpdate, payload)+ // Feed the macOS Notch HUD the model name (keyed by sessionId; no-op off/non-darwin).+ notchHudOnContextUpdate(payload as { sessionId?: string; model?: string; usedPercent?: number })// Feed the mirror's per-node context ring (mobile-usage-inbox). The context tail keys by// sessionId; map it back to the node via the raw-listener's nodeId↔sessionId association.const cw = payload as { sessionId?: string; usedPercent?: number }@@ -1117,6 +1130,8 @@ app.whenReady().then(async () => {// the same single source of truth as the mirror/phone. Then broadcast the enriched event.const enriched = recordAgentEvent(e) ?? esendToMain(IPC.agentStatus, enriched)+ // Feed the macOS Notch HUD its prompt (ev.task on newTurn) + subagent grouping (no-op off/non-darwin).+ notchHudOnAgentEvent(enriched)}hookServer.setListener(emitAgentStatus)// Deterministic hook-reply approvals (docs/hook-reply-approvals.md): the canvas Approve/Deny@@ -1624,6 +1639,7 @@ app.on('window-all-closed', () => {let quitFlushed = falseapp.on('before-quit', (e) => {quitting = true // from here on, window close-events must NOT be turned into hide+ destroyNotchHud()workspaceWatcher.dispose()if (quitFlushed) {// Second pass (the deferred app.quit() below): the flush had its chance — drop the masters.diff --git a/src/main/notch-hud-model.test.ts b/src/main/notch-hud-model.test.tsnew file mode 100644index 000000000..3269bd2e7--- /dev/null+++ b/src/main/notch-hud-model.test.ts@@ -0,0 +1,210 @@+import { describe, it, expect } from 'vitest'+import type { NormalizedAgentEvent } from '@shared/agents/normalize'+import type { NodeStateChange, NodeNowChange, MirrorFile } from '../core/agent-status-mirror'+import {+ createHudModel,+ bucketState,+ firstPromptLine,+ buildIndicator,+ HUD_STALE_DROP_MS,+ type HudRow+} from './notch-hud-model'++const T0 = 1_000_000++function stateChange(p: Partial<NodeStateChange> & { nodeId: string; state: NodeStateChange['state'] }): NodeStateChange {+ return { event: 'update', ts: T0, ...p }+}+function nowChange(p: Partial<NodeNowChange> & { nodeId: string }): NodeNowChange {+ return { ts: T0, ...p }+}+function titleOf(id: string): string {+ return `title-${id}`+}+function rowFor(rows: HudRow[], nodeId: string): HudRow | undefined {+ return rows.find((r) => r.nodeId === nodeId)+}++describe('bucketState', () => {+ it('collapses waiting/blocked to needsYou, keeps working/done', () => {+ expect(bucketState('working')).toBe('working')+ expect(bucketState('done')).toBe('done')+ expect(bucketState('waiting')).toBe('needsYou')+ expect(bucketState('blocked')).toBe('needsYou')+ })+})++describe('firstPromptLine', () => {+ it('returns the first non-empty trimmed line and clips long ones', () => {+ expect(firstPromptLine('\n\n hello world \nsecond')).toBe('hello world')+ expect(firstPromptLine(undefined)).toBeUndefined()+ expect(firstPromptLine(' ')).toBeUndefined()+ const long = 'x'.repeat(300)+ const clipped = firstPromptLine(long, 10)!+ expect(clipped.length).toBe(10)+ expect(clipped.endsWith('…')).toBe(true)+ })+})++describe('createHudModel — state → bucket', () => {+ it('maps working/needsYou/done edges into rows and drops idle', () => {+ const m = createHudModel()+ m.applyStateChange(stateChange({ nodeId: 'a', state: 'working', agentId: 'claude' }))+ m.applyStateChange(stateChange({ nodeId: 'b', state: 'needsYou', agentId: 'codex' }))+ let rows = m.buildRows(T0, titleOf)+ expect(rowFor(rows, 'a')?.state).toBe('working')+ expect(rowFor(rows, 'a')?.title).toBe('title-a')+ expect(rowFor(rows, 'b')?.state).toBe('needsYou')++ // done then acknowledged → demotes to idle → drops out of the row list+ m.applyStateChange(stateChange({ nodeId: 'a', state: 'done' }))+ rows = m.buildRows(T0, titleOf)+ expect(rowFor(rows, 'a')?.state).toBe('done')+ m.noteFocus('a')+ rows = m.buildRows(T0, titleOf)+ expect(rowFor(rows, 'a')).toBeUndefined()+ })++ it('mirror flush maps waiting/blocked to needsYou and seeds unseen nodes', () => {+ const m = createHudModel()+ const doc: MirrorFile = {+ v: 1,+ updatedAt: T0,+ nodes: {+ w: { state: 'working', agentId: 'claude', updatedAt: T0 },+ q: { state: 'waiting', agentId: 'gemini', updatedAt: T0 },+ x: { state: 'blocked', agentId: 'codex', updatedAt: T0 }+ }+ }+ m.applyMirrorFlush(doc)+ const rows = m.buildRows(T0, titleOf)+ expect(rowFor(rows, 'w')?.state).toBe('working')+ expect(rowFor(rows, 'q')?.state).toBe('needsYou')+ expect(rowFor(rows, 'x')?.state).toBe('needsYou')+ })+})++describe('done latch', () => {+ it('is cleared by noteFocus and by notePanelOpened', () => {+ const m = createHudModel()+ m.applyStateChange(stateChange({ nodeId: 'a', state: 'done' }))+ m.applyStateChange(stateChange({ nodeId: 'b', state: 'done' }))+ expect(rowFor(m.buildRows(T0, titleOf), 'a')?.state).toBe('done')+ m.noteFocus('a')+ expect(rowFor(m.buildRows(T0, titleOf), 'a')).toBeUndefined()+ expect(rowFor(m.buildRows(T0, titleOf), 'b')?.state).toBe('done')+ m.notePanelOpened()+ expect(rowFor(m.buildRows(T0, titleOf), 'b')).toBeUndefined()+ })++ it('an explicit read-ack end does not raise the highlight', () => {+ const m = createHudModel()+ m.applyStateChange(stateChange({ nodeId: 'a', state: 'done', ack: true }))+ // already-seen done → idle → not shown+ expect(rowFor(m.buildRows(T0, titleOf), 'a')).toBeUndefined()+ })++ it('a fresh working edge re-arms a previously seen done', () => {+ const m = createHudModel()+ m.applyStateChange(stateChange({ nodeId: 'a', state: 'done' }))+ m.noteFocus('a')+ m.applyStateChange(stateChange({ nodeId: 'a', state: 'working' }))+ m.applyStateChange(stateChange({ nodeId: 'a', state: 'done', ts: T0 + 1 }))+ expect(rowFor(m.buildRows(T0 + 1, titleOf), 'a')?.state).toBe('done')+ })+})++describe('subagent grouping', () => {+ const evt = (p: Partial<NormalizedAgentEvent> & { nodeId: string; kind: NormalizedAgentEvent['kind'] }): NormalizedAgentEvent =>+ ({ agentId: 'claude', ...p } as NormalizedAgentEvent)++ it('groups subagent start/end under the node and marks done', () => {+ const m = createHudModel()+ m.applyStateChange(stateChange({ nodeId: 'a', state: 'working', agentId: 'claude' }))+ m.applyAgentEvent(evt({ nodeId: 'a', kind: 'subagent-start', toolUseId: 't1', taskLabel: 'do-x' }))+ m.applyAgentEvent(evt({ nodeId: 'a', kind: 'subagent-start', toolUseId: 't2', subagentType: 'general' }))+ let row = rowFor(m.buildRows(T0, titleOf), 'a')!+ expect(row.subagents).toHaveLength(2)+ expect(row.subagents.find((s) => s.id === 't1')?.label).toBe('do-x')+ expect(row.subagents.find((s) => s.id === 't2')?.label).toBe('general')++ m.applyAgentEvent(evt({ nodeId: 'a', kind: 'subagent-end', toolUseId: 't1' }))+ row = rowFor(m.buildRows(T0, titleOf), 'a')!+ expect(row.subagents.find((s) => s.id === 't1')?.state).toBe('done')+ expect(row.subagents.find((s) => s.id === 't2')?.state).toBe('working')+ })++ it('clears fan-out on a new turn and captures the prompt', () => {+ const m = createHudModel()+ m.applyStateChange(stateChange({ nodeId: 'a', state: 'working', agentId: 'claude' }))+ m.applyAgentEvent(evt({ nodeId: 'a', kind: 'subagent-start', toolUseId: 't1' }))+ m.applyAgentEvent(evt({ nodeId: 'a', kind: 'state', newTurn: true, task: 'refactor the parser\nmore' }))+ const row = rowFor(m.buildRows(T0, titleOf), 'a')!+ expect(row.subagents).toHaveLength(0)+ expect(row.prompt).toBe('refactor the parser')+ })++ it('clears fan-out on session end', () => {+ const m = createHudModel()+ m.applyStateChange(stateChange({ nodeId: 'a', state: 'working' }))+ m.applyAgentEvent(evt({ nodeId: 'a', kind: 'subagent-start', toolUseId: 't1' }))+ m.applyAgentEvent(evt({ nodeId: 'a', kind: 'session', sessionPhase: 'end' }))+ expect(rowFor(m.buildRows(T0, titleOf), 'a')!.subagents).toHaveLength(0)+ })+})++describe('prompt / model / context join', () => {+ it('joins model by sessionId and context% by now-change', () => {+ const m = createHudModel()+ m.applyStateChange(stateChange({ nodeId: 'a', state: 'working', agentId: 'claude', sessionId: 's1' }))+ m.applyContextUpdate({ sessionId: 's1', model: 'claude-opus-4', usedPercent: 42 })+ m.applyNowChange(nowChange({ nodeId: 'a', activity: 'Editing file.ts' }))+ const row = rowFor(m.buildRows(T0, titleOf), 'a')!+ expect(row.model).toBe('claude-opus-4')+ expect(row.contextPercent).toBe(42)+ expect(row.activity).toBe('Editing file.ts')+ })+})++describe('6h drop', () => {+ it('drops a gone + idle node after 6h, keeps a present or recent one', () => {+ const m = createHudModel()+ // present in mirror → never dropped, even if stale+ m.applyMirrorFlush({ v: 1, updatedAt: T0, nodes: { present: { state: 'done', updatedAt: T0 } } })+ // gone node, recently done+ m.applyStateChange(stateChange({ nodeId: 'gone', state: 'done', ts: T0 }))+ // it's not in the mirror flush above → presentInMirror stays false++ expect(m.prune(T0 + HUD_STALE_DROP_MS - 1)).toBe(false)+ // still around, seen check: build after prune+ // now push past 6h+ expect(m.prune(T0 + HUD_STALE_DROP_MS + 1)).toBe(true)+ const rows = m.buildRows(T0 + HUD_STALE_DROP_MS + 1, titleOf)+ expect(rowFor(rows, 'gone')).toBeUndefined()+ // present node still tracked (done, unseen)+ expect(rowFor(rows, 'present')?.state).toBe('done')+ })++ it('never drops a working node', () => {+ const m = createHudModel()+ m.applyStateChange(stateChange({ nodeId: 'w', state: 'working', ts: T0 }))+ 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')+ })+})++describe('buildIndicator + ordering', () => {+ it('lists distinct working agents and flags done-unseen', () => {+ 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 first+ expect(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)+ })+})diff --git a/src/main/notch-hud-model.ts b/src/main/notch-hud-model.tsnew file mode 100644index 000000000..e542e5a44--- /dev/null+++ b/src/main/notch-hud-model.ts@@ -0,0 +1,300 @@+// Pure, Electron-free aggregation for the macOS Notch HUD (docs/notch-hud.md).+//+// The HUD controller (notch-hud.ts) owns the BrowserWindow and the mirror/IPC subscriptions; this+// module owns the DATA: it folds the four feeds (main-state edges, now-changes, the full mirror+// 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.++import type { NormalizedAgentEvent, AgentState } from '../shared/agents/normalize'+import type { NodeStateChange, NodeNowChange, MirrorFile } from '../core/agent-status-mirror'++/** 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++/** The phone-facing bucket the HUD colors rows by. `idle` = a seen/finished session. */+export type HudRowState = 'working' | 'needsYou' | 'done' | 'idle'++export interface HudSubagentRow {+ id: string+ label?: string+ state: 'working' | 'done'+}++/** One row the HUD window renders (contract shape). Title is joined in by the controller. */+export interface HudRow {+ nodeId: string+ agentId?: string+ title: string+ model?: string+ state: HudRowState+ prompt?: string+ activity?: string+ contextPercent?: number+ subagents: HudSubagentRow[]+ /** Last-change time (ms) — drives ordering + the row's "reltime" tag. */+ 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+}++interface NodeAccum {+ agentId?: string+ sessionId?: string+ state: HudRowState+ prompt?: string+ activity?: string+ contextPercent?: number+ subagents: Map<string, HudSubagentRow>+ /** Last time anything about this node changed — orders rows + gates the stale drop. */+ updatedAt: number+ /** Present in the most recent mirror flush (a node absent from it is "gone"). */+ presentInMirror: boolean+ /** The done highlight has been acknowledged (focused / panel opened) → demote to idle. */+ doneSeen: boolean+}++/** Map an agent's 4-state model to the HUD's 3 live buckets (waiting/blocked collapse to needsYou). */+export function bucketState(s: AgentState): Exclude<HudRowState, 'idle'> {+ if (s === 'working') return 'working'+ if (s === 'done') return 'done'+ 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 {+ if (!text) return undefined+ const line = text+ .split('\n')+ .map((l) => l.trim())+ .find((l) => l.length > 0)+ if (!line) return undefined+ return line.length > max ? line.slice(0, max - 1) + '…' : line+}++export interface HudModel {+ /** A main-state edge (working start / needsYou / done). Drives the row's live state + latch. */+ applyStateChange(c: NodeStateChange): void+ /** Activity line + context% tick. */+ applyNowChange(c: NodeNowChange): void+ /** The full mirror table — reconciles presence (for the gone-drop) and seeds unseen nodes. */+ applyMirrorFlush(doc: MirrorFile): void+ /** The normalized agent-event stream — the ONLY source of the user prompt + subagent grouping. */+ applyAgentEvent(ev: NormalizedAgentEvent): void+ /** A context-update {sessionId, model, usedPercent} — the ONLY source of the model name. */+ applyContextUpdate(p: { sessionId?: string; model?: string; usedPercent?: number }): void+ /** Clear a node's done highlight (the user looked at it). */+ noteFocus(nodeId: string): void+ /** Clear EVERY node's done highlight (the panel was opened — "you looked at it"). */+ notePanelOpened(): void+ /** Drop nodes gone from the mirror + idle > 6h. Returns true if anything changed. */+ prune(now: number): boolean+ /** Build the row array (active sessions, newest-active first), joining titles in. */+ buildRows(now: number, getTitle: (nodeId: string) => string | undefined): HudRow[]+}++/**+ * Create a HUD data model. Every mutation is deterministic and Electron-free; the controller feeds+ * it and calls buildRows on a debounce. `now` is threaded through prune/buildRows so tests control+ * the clock.+ */+export function createHudModel(): HudModel {+ const nodes = new Map<string, NodeAccum>()+ // Model name arrives keyed by sessionId (context tail) — joined to a node via its sessionId.+ const modelBySession = new Map<string, string>()++ function ensure(nodeId: string, ts: number): NodeAccum {+ let a = nodes.get(nodeId)+ if (!a) {+ a = {+ state: 'idle',+ subagents: new Map(),+ updatedAt: ts,+ presentInMirror: false,+ doneSeen: false+ }+ nodes.set(nodeId, a)+ }+ return a+ }++ function applyStateChange(c: NodeStateChange): void {+ const a = ensure(c.nodeId, c.ts)+ if (c.agentId) a.agentId = c.agentId+ if (c.sessionId) a.sessionId = c.sessionId+ a.state = c.state+ a.updatedAt = c.ts+ if (c.state === 'working') {+ // 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+ }+ }++ function applyNowChange(c: NodeNowChange): void {+ const a = ensure(c.nodeId, c.ts)+ if (c.activity !== undefined) a.activity = c.activity || undefined+ if (typeof c.contextPercent === 'number') a.contextPercent = c.contextPercent+ a.updatedAt = c.ts+ }++ function applyMirrorFlush(doc: MirrorFile): void {+ const seen = new Set<string>()+ for (const [nodeId, n] of Object.entries(doc.nodes ?? {})) {+ seen.add(nodeId)+ const a = ensure(nodeId, n.updatedAt)+ a.presentInMirror = true+ if (n.agentId) a.agentId = n.agentId+ if (n.sessionId) a.sessionId = n.sessionId+ // The mirror is authoritative for a node's coarse state; keep the finer edge-driven state+ // when they agree, but let the mirror move a node OFF working (e.g. holdoff expiry) and+ // seed a node we've never heard an edge from. Don't resurrect a seen-done into unseen.+ if (n.state) {+ const bucket = bucketState(n.state)+ if (bucket === 'done') {+ if (a.state !== 'done') a.state = 'done'+ } else {+ a.state = bucket+ if (bucket === 'working') a.doneSeen = false+ }+ }+ }+ for (const [nodeId, a] of nodes) if (!seen.has(nodeId)) a.presentInMirror = false+ }++ function applyAgentEvent(ev: NormalizedAgentEvent): void {+ const nodeId = ev.nodeId+ if (!nodeId) return+ const a = ensure(nodeId, Date.now())+ if (ev.agentId) a.agentId = ev.agentId+ if (ev.sessionId) a.sessionId = ev.sessionId+ // A genuine new turn: capture the user prompt and clear last turn's subagent fan-out.+ if (ev.kind === 'state' && ev.newTurn) {+ if (ev.task) a.prompt = firstPromptLine(ev.task)+ a.subagents.clear()+ a.updatedAt = Date.now()+ return+ }+ if (ev.kind === 'subagent-start' && ev.toolUseId) {+ a.subagents.set(ev.toolUseId, {+ id: ev.toolUseId,+ label: ev.taskLabel || ev.subagentType || undefined,+ state: 'working'+ })+ a.updatedAt = Date.now()+ return+ }+ if (ev.kind === 'subagent-end' && ev.toolUseId) {+ const s = a.subagents.get(ev.toolUseId)+ if (s) s.state = 'done'+ a.updatedAt = Date.now()+ return+ }+ // Session end clears the fan-out (the badge does the same).+ if (ev.kind === 'session' && ev.sessionPhase === 'end') {+ a.subagents.clear()+ }+ }++ function applyContextUpdate(p: { sessionId?: string; model?: string; usedPercent?: number }): void {+ if (!p.sessionId) return+ if (p.model) modelBySession.set(p.sessionId, p.model)+ if (typeof p.usedPercent === 'number') {+ for (const a of nodes.values()) {+ if (a.sessionId === p.sessionId) {+ a.contextPercent = p.usedPercent+ break+ }+ }+ }+ }++ function noteFocus(nodeId: string): void {+ const a = nodes.get(nodeId)+ if (a && a.state === 'done') a.doneSeen = true+ }++ function notePanelOpened(): void {+ for (const a of nodes.values()) if (a.state === 'done') a.doneSeen = true+ }++ function prune(now: number): boolean {+ let changed = false+ for (const [nodeId, a] of nodes) {+ if (a.state === 'working') continue+ if (a.presentInMirror) continue+ if (now - a.updatedAt > HUD_STALE_DROP_MS) {+ nodes.delete(nodeId)+ changed = true+ }+ }+ return changed+ }++ function displayState(a: NodeAccum): 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'+ return a.state+ }++ function buildRows(_now: number, getTitle: (nodeId: string) => string | undefined): HudRow[] {+ const rows: HudRow[] = []+ for (const [nodeId, a] of nodes) {+ const state = displayState(a)+ // The HUD shows active sessions only — nothing when a node is idle/seen.+ if (state === 'idle') continue+ const model = a.sessionId ? modelBySession.get(a.sessionId) : undefined+ rows.push({+ nodeId,+ agentId: a.agentId,+ title: getTitle(nodeId) || 'Session',+ ...(model ? { model } : {}),+ state,+ ...(a.prompt ? { prompt: a.prompt } : {}),+ ...(a.activity ? { activity: a.activity } : {}),+ ...(typeof a.contextPercent === 'number' ? { contextPercent: a.contextPercent } : {}),+ subagents: [...a.subagents.values()],+ updatedAt: a.updatedAt+ })+ }+ rows.sort((x, y) => y.updatedAt - x.updatedAt)+ return rows+ }++ return {+ applyStateChange,+ applyNowChange,+ applyMirrorFlush,+ applyAgentEvent,+ applyContextUpdate,+ noteFocus,+ notePanelOpened,+ prune,+ 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/main/notch-hud.ts b/src/main/notch-hud.tsnew file mode 100644index 000000000..a07bb5f4e--- /dev/null+++ b/src/main/notch-hud.ts@@ -0,0 +1,316 @@+// macOS Notch HUD (docs/notch-hud.md) — a transparent, always-on-top, click-through strip along+// the top edge that shows walking agent mascots beside the MacBook notch while agents work, and+// expands into a mini session panel. macOS + desktop only; default on (settings.notchHud).+//+// This module owns the BrowserWindow + the getHudWindow/sendToHud singleton (mirroring+// main-window.ts) and the mirror/IPC subscriptions. The DATA folding lives in the pure,+// Electron-free notch-hud-model.ts so it is unit-testable without a window. index.ts feeds two+// extra streams in (the normalized agent-event stream for prompt+subagents, and context-update for+// the model) via the module-level notchHudOn* functions, which no-op when the HUD is off.++import { BrowserWindow, ipcMain, screen } from 'electron'+import { join } from 'path'+import { IPC } from '../shared/ipc'+import { getMainWindow, sendToMain } from './main-window'+import {+ onNodeStateChange,+ onNodeNowChange,+ onMirrorFlush,+ type NodeStateChange,+ type NodeNowChange,+ type MirrorFile+} from '../core/agent-status-mirror'+import type { NormalizedAgentEvent } from '../shared/agents/normalize'+import { createHudModel, type HudModel } from './notch-hud-model'++/** Minimum strip height when there is no physical notch (menu-bar height floor). */+const NOTCH_BAR_FLOOR = 24+/** Total window height — sized to the EXPANDED box (we never resize the frame; the renderer scales+ * a CSS transform). Capped to the display height. */+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++// ---- Singleton (mirror main-window.ts) -----------------------------------------------------++let hudWin: BrowserWindow | null = null++export function getHudWindow(): BrowserWindow | null {+ return hudWin && !hudWin.isDestroyed() ? hudWin : null+}++export function sendToHud(channel: string, ...args: unknown[]): void {+ getHudWindow()?.webContents.send(channel, ...args)+}++// ---- Controller ----------------------------------------------------------------------------++export interface NotchHudDeps {+ /** Sync in-memory node title (workspaceStore.getNodeTitle). */+ getNodeTitle: (nodeId: string) => string | undefined+}++class NotchHudController {+ private model: HudModel = createHudModel()+ private unsubs: (() => void)[] = []+ private pushTimer: ReturnType<typeof setTimeout> | null = null+ private sweepTimer: ReturnType<typeof setInterval> | null = null+ private ipcBound = false+ private readonly onSetIgnoreMouse: (_e: unknown, ignore: boolean) => void+ private readonly onFocusNode: (_e: unknown, nodeId: string) => void+ private readonly onExpanded: (_e: unknown, expanded: boolean) => void+ private readonly onDisplayChange: () => void++ constructor(private deps: NotchHudDeps) {+ this.onSetIgnoreMouse = (_e, ignore) => {+ // Ignore-mouse ON = click-through (the strip is transparent to the app beneath); OFF while the+ // pointer is over the hotspot/panel so clicks land. `forward` keeps move events flowing so the+ // renderer still sees pointer-leave to re-enable click-through.+ getHudWindow()?.setIgnoreMouseEvents(!!ignore, { forward: true })+ }+ this.onFocusNode = (_e, nodeId) => {+ if (typeof nodeId !== 'string' || !nodeId) return+ // Reuse the notification-click focus path: bring the main window forward + ask the renderer to+ // center the node, then clear its done highlight (a nodeterm-native "you looked at it").+ const w = getMainWindow()+ if (w) {+ if (w.isMinimized()) w.restore()+ w.show()+ w.focus()+ sendToMain(IPC.appFocusNode, nodeId)+ }+ this.model.noteFocus(nodeId)+ this.schedulePush()+ }+ this.onExpanded = (_e, expanded) => {+ // Opening the panel is itself a "you looked at it" signal — clear every done latch.+ if (expanded) {+ this.model.notePanelOpened()+ this.schedulePush()+ }+ }+ this.onDisplayChange = () => this.reposition()+ }++ start(): void {+ this.createWindow()+ this.bindIpc()+ this.unsubs.push(onNodeStateChange((c: NodeStateChange) => this.onModelChange(() => this.model.applyStateChange(c))))+ this.unsubs.push(onNodeNowChange((c: NodeNowChange) => this.onModelChange(() => this.model.applyNowChange(c))))+ this.unsubs.push(onMirrorFlush((doc: MirrorFile) => this.onModelChange(() => this.model.applyMirrorFlush(doc))))+ screen.on('display-metrics-changed', this.onDisplayChange)+ screen.on('display-added', this.onDisplayChange)+ screen.on('display-removed', this.onDisplayChange)+ this.sweepTimer = setInterval(() => {+ if (this.model.prune(Date.now())) this.schedulePush()+ }, SWEEP_MS)+ this.sweepTimer.unref?.()+ }++ stop(): void {+ for (const u of this.unsubs) {+ try {+ u()+ } catch {+ /* ignore */+ }+ }+ this.unsubs = []+ screen.removeListener('display-metrics-changed', this.onDisplayChange)+ screen.removeListener('display-added', this.onDisplayChange)+ screen.removeListener('display-removed', this.onDisplayChange)+ if (this.pushTimer) {+ clearTimeout(this.pushTimer)+ this.pushTimer = null+ }+ if (this.sweepTimer) {+ clearInterval(this.sweepTimer)+ this.sweepTimer = null+ }+ this.unbindIpc()+ if (hudWin && !hudWin.isDestroyed()) hudWin.destroy()+ hudWin = null+ }++ /** Feed the normalized agent-event stream (prompt on newTurn + subagent grouping). */+ onAgentEvent(ev: NormalizedAgentEvent): void {+ this.onModelChange(() => this.model.applyAgentEvent(ev))+ }++ /** Feed a context-update {sessionId, model, usedPercent} (the model name). */+ onContextUpdate(p: { sessionId?: string; model?: string; usedPercent?: number }): void {+ this.onModelChange(() => this.model.applyContextUpdate(p))+ }++ private onModelChange(mutate: () => void): void {+ try {+ mutate()+ } catch {+ // A malformed event must never crash the HUD (or the main process).+ return+ }+ this.schedulePush()+ }++ private bindIpc(): void {+ if (this.ipcBound) return+ ipcMain.on(IPC.hudSetIgnoreMouse, this.onSetIgnoreMouse)+ ipcMain.on(IPC.hudFocusNode, this.onFocusNode)+ ipcMain.on(IPC.hudExpanded, this.onExpanded)+ this.ipcBound = true+ }++ private unbindIpc(): void {+ if (!this.ipcBound) return+ ipcMain.removeListener(IPC.hudSetIgnoreMouse, this.onSetIgnoreMouse)+ ipcMain.removeListener(IPC.hudFocusNode, this.onFocusNode)+ ipcMain.removeListener(IPC.hudExpanded, this.onExpanded)+ this.ipcBound = false+ }++ private geometry(): { x: number; y: number; width: number; height: number; bar: number } {+ const d = screen.getPrimaryDisplay()+ const b = d.bounds+ const wa = d.workArea+ // The notch bar height is the strip between the display top and the usable work area+ // (menu-bar / notch). Floor at 24 so we always have room for the mascots.+ const bar = Math.max(NOTCH_BAR_FLOOR, wa.y - b.y)+ const height = Math.min(HUD_WINDOW_HEIGHT, b.height)+ return { x: b.x, y: b.y, width: b.width, height, bar }+ }++ private reposition(): void {+ const w = getHudWindow()+ if (!w) return+ const g = this.geometry()+ w.setBounds({ x: g.x, y: g.y, width: g.width, height: g.height })+ this.schedulePush() // re-send geometry (bar can change with the notch/menu-bar)+ }++ private createWindow(): void {+ if (getHudWindow()) return+ const g = this.geometry()+ const win = new BrowserWindow({+ x: g.x,+ y: g.y,+ width: g.width,+ height: g.height,+ frame: false,+ transparent: true,+ hasShadow: false,+ resizable: false,+ movable: false,+ minimizable: false,+ maximizable: false,+ fullscreenable: false,+ alwaysOnTop: true,+ focusable: false,+ skipTaskbar: true,+ show: false,+ // Do not steal the space or animate; it is a passive overlay.+ acceptFirstMouse: true,+ backgroundColor: '#00000000',+ webPreferences: {+ preload: join(__dirname, '../preload/hud.js'),+ contextIsolation: true,+ nodeIntegration: false,+ sandbox: false+ }+ })+ hudWin = win+ // Float above full-screen apps and every Space; screen-saver level keeps it over normal windows.+ win.setAlwaysOnTop(true, 'screen-saver')+ win.setVisibleOnAllWorkspaces(true, { visibleOnFullScreen: true })+ // Passive by default: the strip is click-through; the renderer flips this OFF over the hotspot.+ win.setIgnoreMouseEvents(true, { forward: true })++ win.on('closed', () => {+ if (hudWin === win) hudWin = null+ })++ const devUrl = process.env['ELECTRON_RENDERER_URL']+ if (devUrl) {+ void win.loadURL(`${devUrl}/hud.html`)+ } else {+ void win.loadFile(join(__dirname, '../renderer/hud.html'))+ }+ win.webContents.on('did-finish-load', () => {+ win.showInactive() // show without stealing focus+ this.pushNow()+ })+ }++ private schedulePush(): void {+ if (this.pushTimer) return+ this.pushTimer = setTimeout(() => {+ this.pushTimer = null+ this.pushNow()+ }, PUSH_DEBOUNCE_MS)+ this.pushTimer.unref?.()+ }++ private pushNow(): void {+ const w = getHudWindow()+ if (!w) return+ const now = Date.now()+ this.model.prune(now)+ const rows = this.model.buildRows(now, this.deps.getNodeTitle)+ const g = this.geometry()+ w.webContents.send(IPC.hudRows, { rows, bar: g.bar, width: g.width })+ }+}++// ---- Module-level lifecycle + feed shims ---------------------------------------------------++let controller: NotchHudController | null = null+let controllerDeps: NotchHudDeps | null = null++/** Whether the HUD is supported on this platform (macOS desktop only). */+function supported(): boolean {+ return process.platform === 'darwin'+}++/**+ * Create the HUD (if darwin + enabled). Idempotent. `deps.getNodeTitle` is retained so a later+ * `setNotchHudEnabled(true)` (settings toggle) can recreate it without re-plumbing.+ */+export function initNotchHud(deps: NotchHudDeps, enabled: boolean): void {+ controllerDeps = deps+ if (!supported() || !enabled) return+ if (controller) return+ controller = new NotchHudController(deps)+ controller.start()+}++/** Live settings toggle: create or destroy the HUD window without a restart. */+export function setNotchHudEnabled(enabled: boolean): void {+ if (!supported()) return+ if (enabled) {+ if (controller || !controllerDeps) return+ controller = new NotchHudController(controllerDeps)+ controller.start()+ } else {+ controller?.stop()+ controller = null+ }+}++/** Tear the HUD down (app quit). */+export function destroyNotchHud(): void {+ controller?.stop()+ controller = null+}++/** Feed shims — cheap no-ops when the HUD is off. Called unconditionally from index.ts. */+export function notchHudOnAgentEvent(ev: NormalizedAgentEvent): void {+ controller?.onAgentEvent(ev)+}+export function notchHudOnContextUpdate(p: {+ sessionId?: string+ model?: string+ usedPercent?: number+}): void {+ controller?.onContextUpdate(p)+}diff --git a/src/preload/hud.ts b/src/preload/hud.tsnew file mode 100644index 000000000..cdc45008c--- /dev/null+++ b/src/preload/hud.ts@@ -0,0 +1,55 @@+// Tiny, HUD-only preload (docs/notch-hud.md). The Notch HUD is a separate BrowserWindow with a+// minimal surface — it does not need the full `window.nodeTerminal` API, so it gets its own bridge+// exposing exactly the four HUD channels. contextIsolation stays on; no node integration.++import { contextBridge, ipcRenderer } from 'electron'+import { IPC } from '../shared/ipc'++export interface HudSubagentRow {+ id: string+ label?: string+ state: 'working' | 'done'+}+export interface HudRow {+ nodeId: string+ agentId?: string+ title: string+ model?: string+ state: 'working' | 'needsYou' | 'done' | 'idle'+ prompt?: string+ activity?: string+ contextPercent?: number+ subagents: HudSubagentRow[]+ updatedAt: number+}+export interface HudPush {+ rows: HudRow[]+ /** Notch/menu-bar strip height in px (indicator vertical placement). */+ bar: number+ /** Primary-display width in px. */+ width: number+}++export interface HudApi {+ /** main → hud: subscribe to row/geometry pushes. Returns an unsubscribe. */+ onRows(cb: (push: HudPush) => void): () => void+ /** hud → main: toggle window click-through (true = pass clicks through). */+ setIgnoreMouse(ignore: boolean): void+ /** hud → main: a row was clicked — focus that node in nodeterm. */+ focusNode(nodeId: string): void+ /** hud → main: the panel expanded (true) / collapsed (false). */+ setExpanded(expanded: boolean): void+}++const api: HudApi = {+ onRows(cb) {+ const handler = (_e: unknown, push: HudPush): void => cb(push)+ ipcRenderer.on(IPC.hudRows, handler)+ return () => ipcRenderer.removeListener(IPC.hudRows, handler)+ },+ setIgnoreMouse: (ignore) => ipcRenderer.send(IPC.hudSetIgnoreMouse, ignore),+ focusNode: (nodeId) => ipcRenderer.send(IPC.hudFocusNode, nodeId),+ setExpanded: (expanded) => ipcRenderer.send(IPC.hudExpanded, expanded)+}++contextBridge.exposeInMainWorld('hud', api)diff --git a/src/renderer/components/settings/sections/AppearanceSection.tsx b/src/renderer/components/settings/sections/AppearanceSection.tsxindex 2b6898dfc..7517631b2 100644--- a/src/renderer/components/settings/sections/AppearanceSection.tsx+++ b/src/renderer/components/settings/sections/AppearanceSection.tsx@@ -2,15 +2,24 @@ import { useSettings } from '../../../state/settings'import { NODE_COLORS } from '../../../state/workspace'import { SettingsSection } from '../SettingsSection'import { SearchableRow } from '../SearchableRow'+import { FieldRow } from '../FieldRow'+import { Switch } from '@renderer/ui/Switch'import { cn } from '@renderer/ui/cn'+const isMac = /Mac/i.test(navigator.platform || navigator.userAgent)+const ROWS = {- accent: { title: 'Accent', keywords: ['accent', 'color', 'theme', 'appearance'] }+ accent: { title: 'Accent', keywords: ['accent', 'color', 'theme', 'appearance'] },+ notchHud: {+ title: 'Notch HUD',+ keywords: ['notch', 'hud', 'mascot', 'menu bar', 'overlay', 'agent', 'status', 'macos']+ }}const ENTRIES = Object.values(ROWS)export function AppearanceSection({ isActive }: { isActive: boolean }): React.JSX.Element {const accent = useSettings((s) => s.settings.accent)+ const notchHud = useSettings((s) => s.settings.notchHud)const update = useSettings((s) => s.update)return (<SettingsSection@@ -39,6 +48,21 @@ export function AppearanceSection({ isActive }: { isActive: boolean }): React.JS</div></div></SearchableRow>+ {isMac && (+ <SearchableRow {...ROWS.notchHud}>+ <FieldRow+ label="Notch HUD"+ description="Show walking agent mascots by the notch while agents work; click to expand a mini session panel. macOS only."+ control={+ <Switch+ checked={notchHud}+ ariaLabel="macOS Notch HUD"+ onChange={(on) => update({ notchHud: on })}+ />+ }+ />+ </SearchableRow>+ )}</SettingsSection>)}diff --git a/src/renderer/hud.html b/src/renderer/hud.htmlnew file mode 100644index 000000000..4bab84757--- /dev/null+++ b/src/renderer/hud.html@@ -0,0 +1,16 @@+<!doctype html>+<html lang="en">+ <head>+ <meta charset="UTF-8" />+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />+ <meta+ http-equiv="Content-Security-Policy"+ content="default-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' data:; script-src 'self'; font-src 'self' data:"+ />+ <title>nodeterm HUD</title>+ </head>+ <body>+ <div id="hud"></div>+ <script type="module" src="./hud/main.ts"></script>+ </body>+</html>diff --git a/src/renderer/hud/hud.css b/src/renderer/hud/hud.cssnew file mode 100644index 000000000..0ce8a0997--- /dev/null+++ b/src/renderer/hud/hud.css@@ -0,0 +1,285 @@+/* Notch HUD (docs/notch-hud.md) — transparent overlay; only the indicator + panel paint. */++* {+ box-sizing: border-box;+}+html,+body {+ margin: 0;+ padding: 0;+ width: 100%;+ height: 100%;+ background: transparent;+ overflow: hidden;+ font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', sans-serif;+ -webkit-user-select: none;+ user-select: none;+ cursor: default;+}++#hud {+ position: relative;+ width: 100%;+ height: 100%;+}++/* The interactive hotspot: the indicator + (when expanded) the panel. Anchored at the notch+ center (left:50%) and pulled left so the mascots walk just LEFT of the notch. */+.hud-hotspot {+ position: absolute;+ left: 50%;+ top: 0;+ transform: translateX(-50%);+ display: flex;+ flex-direction: column;+ align-items: center;+}++/* --- Collapsed indicator --- */+.hud-indicator {+ display: flex;+ align-items: center;+ gap: 8px;+ height: var(--bar, 32px);+ padding: 0 10px;+}+.hud-indicator:empty {+ display: none;+}++/* --- Walking mascots (copied from styles.css .term-node__mascot*) --- */+.mascot {+ display: inline-block;+ flex-shrink: 0;+ background-repeat: no-repeat;+ image-rendering: pixelated;+ will-change: background-position, transform;+}+.mascot--claude {+ width: var(--mascot-w);+ height: var(--mascot-h);+ background-size: calc(var(--mascot-w) * 2) var(--mascot-h);+ animation: mascot-walk-claude 0.8s steps(1) infinite;+}+@keyframes mascot-walk-claude {+ 0% {+ background-position-x: 0;+ transform: translateY(0);+ }+ 50% {+ background-position-x: calc(var(--mascot-w) * -1);+ transform: translateY(-1.5px);+ }+ 100% {+ background-position-x: calc(var(--mascot-w) * -2);+ transform: translateY(0);+ }+}+.mascot--codex {+ width: var(--cmascot-w);+ height: var(--cmascot-h);+ background-position: 0 0;+ background-size: var(--cmascot-sheet-w) var(--cmascot-sheet-h);+ animation: mascot-walk-codex 0.96s steps(8) infinite;+}+@keyframes mascot-walk-codex {+ to {+ background-position-x: calc(var(--cmascot-w) * -8);+ }+}++/* A generic (gemini/custom) working slot: a pulsing coral dot. */+.mascot--dot {+ width: 9px;+ height: 9px;+ border-radius: 50%;+ background: rgb(217, 120, 87);+ animation: hud-pulse 1.1s ease-in-out infinite;+}+@keyframes hud-pulse {+ 0%,+ 100% {+ opacity: 1;+ transform: scale(1);+ }+ 50% {+ opacity: 0.45;+ transform: scale(0.82);+ }+}++/* Green "done, unseen" blob. */+.done-blob {+ width: 10px;+ height: 10px;+ border-radius: 50%;+ background: #30d158;+ box-shadow: 0 0 6px 1px rgba(48, 209, 88, 0.7);+ animation: hud-shimmer 1.4s ease-in-out infinite;+}+@keyframes hud-shimmer {+ 0%,+ 100% {+ opacity: 1;+ }+ 50% {+ opacity: 0.5;+ }+}++/* --- Expanded panel --- */+.hud-panel {+ margin-top: 2px;+ width: 380px;+ max-height: 420px;+ overflow-y: auto;+ padding: 6px;+ border-radius: 14px;+ background: rgba(28, 28, 30, 0.92);+ border: 1px solid rgba(255, 255, 255, 0.1);+ box-shadow: 0 10px 40px rgba(0, 0, 0, 0.55);+ backdrop-filter: blur(22px) saturate(1.4);+ -webkit-backdrop-filter: blur(22px) saturate(1.4);+ color: #f2f2f7;+ /* Collapsed by default: scaled to nothing from the top center. */+ transform-origin: top center;+ transform: scaleY(0.06) scaleX(0.25);+ opacity: 0;+ pointer-events: none;+ transition:+ transform 0.2s cubic-bezier(0.22, 1, 0.36, 1),+ opacity 0.18s ease;+}+.hud-hotspot.expanded .hud-panel {+ transform: scale(1);+ opacity: 1;+ pointer-events: auto;+}++.hud-row {+ display: grid;+ grid-template-columns: 22px 1fr auto;+ grid-template-rows: auto auto;+ column-gap: 8px;+ align-items: center;+ padding: 7px 8px;+ border-radius: 9px;+ cursor: pointer;+}+.hud-row:hover {+ background: rgba(255, 255, 255, 0.06);+}+.hud-row__icon {+ grid-row: 1 / span 2;+ display: flex;+ align-items: center;+ justify-content: center;+ width: 22px;+}+.hud-row__title {+ font-size: 13px;+ font-weight: 590;+ white-space: nowrap;+ overflow: hidden;+ text-overflow: ellipsis;+}+.hud-row__tag {+ grid-column: 3;+ grid-row: 1;+ font-size: 11px;+ font-variant-numeric: tabular-nums;+ white-space: nowrap;+ opacity: 0.85;+}+.hud-row__tag--working {+ color: #0a84ff;+}+.hud-row__tag--needsYou {+ color: #ff453a;+}+.hud-row__tag--done {+ color: #30d158;+}+.hud-row__tag--idle {+ color: #8e8e93;+}+.hud-row__sub {+ grid-column: 2 / span 2;+ grid-row: 2;+ font-size: 11.5px;+ color: #aeaeb2;+ white-space: nowrap;+ overflow: hidden;+ text-overflow: ellipsis;+}+.hud-row__sub b {+ color: #d1d1d6;+ font-weight: 600;+}++/* Subagent disclosure */+.hud-subs {+ grid-column: 2 / span 2;+ grid-row: 3;+ margin-top: 4px;+}+.hud-subs__toggle {+ font-size: 11px;+ color: #8e8e93;+ cursor: pointer;+}+.hud-subs__list {+ margin: 3px 0 0;+ padding: 0;+ list-style: none;+}+.hud-subs__list li {+ display: flex;+ align-items: center;+ gap: 6px;+ font-size: 11px;+ color: #c7c7cc;+ padding: 1px 0;+}+.hud-subs__dot {+ width: 6px;+ height: 6px;+ border-radius: 50%;+ flex-shrink: 0;+}+.hud-subs__dot--working {+ background: #0a84ff;+}+.hud-subs__dot--done {+ background: #30d158;+}++.hud-row__go {+ grid-column: 3;+ grid-row: 2;+ justify-self: end;+ font-size: 11px;+ font-weight: 600;+ color: #0a84ff;+ background: rgba(10, 132, 255, 0.15);+ border-radius: 6px;+ padding: 2px 8px;+ border: none;+ cursor: pointer;+}+.hud-row__go:hover {+ background: rgba(10, 132, 255, 0.28);+}++.check {+ color: #30d158;+ font-size: 15px;+ line-height: 1;+}+.needs-dot {+ width: 9px;+ height: 9px;+ border-radius: 50%;+ background: #ff453a;+ animation: hud-pulse 1.1s ease-in-out infinite;+}diff --git a/src/renderer/hud/main.ts b/src/renderer/hud/main.tsnew file mode 100644index 000000000..c08962701--- /dev/null+++ b/src/renderer/hud/main.ts@@ -0,0 +1,283 @@+// Notch HUD renderer (docs/notch-hud.md). Plain TS/DOM — no React. Draws the collapsed indicator+// (walking mascots beside the notch) and the expanded mini session panel, reusing lib/mascot.ts art+// + the walk-cycle CSS. Reports pointer enter/leave of the hotspot to main to toggle click-through,+// and row clicks to focus the node in nodeterm.++import './hud.css'+import { CLAUDE_MASCOT, CODEX_MASCOT } from '../lib/mascot'+import codexPet from '../assets/pet-codex.webp'++// Local mirror of the preload's HUD contract (src/preload/hud.ts) — kept self-contained so this+// renderer entry has no cross-project (main/preload) type dependency.+interface HudSubagentRow {+ id: string+ label?: string+ state: 'working' | 'done'+}+interface HudRow {+ nodeId: string+ agentId?: string+ title: string+ model?: string+ state: 'working' | 'needsYou' | 'done' | 'idle'+ prompt?: string+ activity?: string+ contextPercent?: number+ subagents: HudSubagentRow[]+ updatedAt: number+}+interface HudPush {+ rows: HudRow[]+ bar: number+ width: number+}+interface HudApi {+ onRows(cb: (push: HudPush) => void): () => void+ setIgnoreMouse(ignore: boolean): void+ focusNode(nodeId: string): void+ setExpanded(expanded: boolean): void+}++declare global {+ interface Window {+ hud: HudApi+ }+}++const root = document.getElementById('hud') as HTMLDivElement++// The single interactive hotspot (indicator + panel).+const hotspot = document.createElement('div')+hotspot.className = 'hud-hotspot'+const indicator = document.createElement('div')+indicator.className = 'hud-indicator'+const panel = document.createElement('div')+panel.className = 'hud-panel'+hotspot.append(indicator, panel)+root.append(hotspot)++let expanded = false+let latestRows: HudRow[] = []+// Which subagent disclosures the user has opened (by nodeId), preserved across re-renders.+const openSubs = new Set<string>()++// ---- Interaction: click-through hotspot + expand/collapse ----------------------------------++// While the window is click-through (setIgnoreMouse(true,{forward:true})), the OS still forwards+// MOVE events, so pointerenter fires and we can flip click-through OFF to accept clicks. Leaving+// the hotspot re-enables click-through and collapses the panel (the click-away).+hotspot.addEventListener('pointerenter', () => {+ window.hud.setIgnoreMouse(false)+})+hotspot.addEventListener('pointerleave', () => {+ window.hud.setIgnoreMouse(true)+ if (expanded) setExpanded(false)+})+indicator.addEventListener('click', () => setExpanded(!expanded))++function setExpanded(next: boolean): void {+ if (expanded === next) return+ expanded = next+ hotspot.classList.toggle('expanded', expanded)+ window.hud.setExpanded(expanded)+}++// ---- Relative time -------------------------------------------------------------------------++function reltime(ts: number): string {+ const s = Math.max(0, Math.round((Date.now() - ts) / 1000))+ if (s < 5) return 'now'+ if (s < 60) return `${s}s`+ const m = Math.round(s / 60)+ if (m < 60) return `${m}m`+ const h = Math.round(m / 60)+ return `${h}h`+}++// ---- Mascot / icon builders ----------------------------------------------------------------++function claudeMascot(): HTMLElement {+ const el = document.createElement('span')+ el.className = 'mascot mascot--claude'+ el.style.setProperty('--mascot-w', `${CLAUDE_MASCOT.frameWidth}px`)+ el.style.setProperty('--mascot-h', `${CLAUDE_MASCOT.frameHeight}px`)+ el.style.backgroundImage = `url(${CLAUDE_MASCOT.src})`+ return el+}+function codexMascot(): HTMLElement {+ const el = document.createElement('span')+ el.className = 'mascot mascot--codex'+ el.style.setProperty('--cmascot-w', `${CODEX_MASCOT.frameWidth}px`)+ el.style.setProperty('--cmascot-h', `${CODEX_MASCOT.frameHeight}px`)+ el.style.setProperty('--cmascot-sheet-w', `${CODEX_MASCOT.frameWidth * CODEX_MASCOT.cols}px`)+ el.style.setProperty('--cmascot-sheet-h', `${CODEX_MASCOT.frameHeight * CODEX_MASCOT.rows}px`)+ el.style.backgroundImage = `url(${codexPet})`+ return el+}+function workingMascot(agentId?: string): HTMLElement {+ if (agentId === 'claude' && CLAUDE_MASCOT.src) return claudeMascot()+ if (agentId === 'codex') return codexMascot()+ const dot = document.createElement('span')+ dot.className = 'mascot mascot--dot'+ return dot+}+function rowIcon(row: HudRow): HTMLElement {+ if (row.state === 'working') return workingMascot(row.agentId)+ if (row.state === 'done') {+ const c = document.createElement('span')+ c.className = 'check'+ c.textContent = '✓'+ return c+ }+ // needsYou / idle+ const d = document.createElement('span')+ d.className = 'needs-dot'+ return d+}++// ---- Collapsed indicator -------------------------------------------------------------------++function renderIndicator(rows: HudRow[]): void {+ indicator.replaceChildren()+ 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+ }+ }+ for (const agentId of workingAgents) indicator.append(workingMascot(agentId))+ if (doneUnseen) {+ const blob = document.createElement('span')+ blob.className = 'done-blob'+ indicator.append(blob)+ }+}++// ---- Expanded panel ------------------------------------------------------------------------++function renderPanel(rows: HudRow[]): void {+ panel.replaceChildren()+ const shown = rows.slice(0, 6)+ for (const row of shown) panel.append(buildRow(row))+}++function buildRow(row: HudRow): HTMLElement {+ const el = document.createElement('div')+ el.className = 'hud-row'+ el.addEventListener('click', (e) => {+ // Don't hijack the disclosure toggle click.+ if ((e.target as HTMLElement).closest('.hud-subs__toggle')) return+ window.hud.focusNode(row.nodeId)+ setExpanded(false)+ })++ const icon = document.createElement('div')+ icon.className = 'hud-row__icon'+ icon.append(rowIcon(row))++ const title = document.createElement('div')+ title.className = 'hud-row__title'+ title.textContent = row.title++ const tag = document.createElement('div')+ tag.className = `hud-row__tag hud-row__tag--${row.state}`+ const parts: string[] = []+ if (row.model) parts.push(row.model)+ parts.push(reltime(row.updatedAt))+ if (typeof row.contextPercent === 'number') parts.push(`${Math.round(row.contextPercent)}%`)+ tag.textContent = parts.join(' · ')++ const sub = document.createElement('div')+ sub.className = 'hud-row__sub'+ if (row.prompt) {+ const b = document.createElement('b')+ b.textContent = 'You: '+ sub.append(b, document.createTextNode(row.prompt))+ } else if (row.activity) {+ sub.textContent = row.activity+ } else {+ sub.textContent = stateLabel(row.state)+ }++ el.append(icon, title, tag, sub)++ if (row.subagents.length > 0) el.append(buildSubs(row))++ const go = document.createElement('button')+ go.className = 'hud-row__go'+ go.textContent = 'Go'+ go.addEventListener('click', (e) => {+ e.stopPropagation()+ window.hud.focusNode(row.nodeId)+ setExpanded(false)+ })+ el.append(go)++ return el+}++function stateLabel(state: HudRow['state']): string {+ if (state === 'working') return 'Working…'+ if (state === 'needsYou') return 'Needs you'+ if (state === 'done') return 'Finished'+ return 'Idle'+}++function buildSubs(row: HudRow): HTMLElement {+ const wrap = document.createElement('div')+ wrap.className = 'hud-subs'+ const isOpen = openSubs.has(row.nodeId)+ const toggle = document.createElement('div')+ toggle.className = 'hud-subs__toggle'+ toggle.textContent = `${isOpen ? '▾' : '▸'} ${row.subagents.length} subagent${row.subagents.length === 1 ? '' : 's'}`+ toggle.addEventListener('click', (e) => {+ e.stopPropagation()+ if (openSubs.has(row.nodeId)) openSubs.delete(row.nodeId)+ else openSubs.add(row.nodeId)+ render(latestRows)+ })+ wrap.append(toggle)+ if (isOpen) {+ const list = document.createElement('ul')+ list.className = 'hud-subs__list'+ for (const s of row.subagents) list.append(buildSubItem(s))+ wrap.append(list)+ }+ return wrap+}++function buildSubItem(s: HudSubagentRow): HTMLElement {+ const li = document.createElement('li')+ const dot = document.createElement('span')+ dot.className = `hud-subs__dot hud-subs__dot--${s.state}`+ li.append(dot, document.createTextNode(s.label || s.state))+ return li+}++// ---- Render + geometry ---------------------------------------------------------------------++function render(rows: HudRow[]): void {+ latestRows = rows+ renderIndicator(rows)+ renderPanel(rows)+ // Auto-collapse if there is nothing to show.+ if (rows.length === 0 && expanded) setExpanded(false)+}++function applyGeometry(push: HudPush): void {+ document.documentElement.style.setProperty('--bar', `${push.bar}px`)+}++window.hud.onRows((push: HudPush) => {+ applyGeometry(push)+ render(push.rows ?? [])+})++// Refresh reltimes every 20s even without a push.+setInterval(() => {+ if (latestRows.length > 0) renderPanel(latestRows)+}, 20_000)diff --git a/src/shared/ipc.ts b/src/shared/ipc.tsindex 35141fd4a..9fd23b458 100644--- a/src/shared/ipc.ts+++ b/src/shared/ipc.ts@@ -49,6 +49,15 @@ export const IPC = {* `external` opt). See core/ack-sweep.ts. */agentUnreadClear: 'agent:unread-clear',agentSubagentActivity: 'agent:subagent-activity',+ /** macOS Notch HUD (docs/notch-hud.md). main → hud: push the current row array. */+ hudRows: 'hud:rows',+ /** hud → main: toggle window click-through on hotspot enter/leave. Arg: `ignore: boolean`. */+ hudSetIgnoreMouse: 'hud:set-ignore-mouse',+ /** 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). */+ hudExpanded: 'hud:expanded',agentControl: 'agent:control',agentControlResult: 'agent:control-result',/** Canvas sync: a client casts its local node mutations here; the core reflectordiff --git a/src/shared/types.ts b/src/shared/types.tsindex d49d34e70..bb5ed4c07 100644--- a/src/shared/types.ts+++ b/src/shared/types.ts@@ -688,6 +688,10 @@ export interface Settings {* hook holds briefly for a phone/canvas Approve/Deny before falling through to the normal* interactive prompt. Off ⇒ the env var is absent ⇒ exact legacy behavior. Claude-only. */hookReplyApprovals: boolean+ /** macOS Notch HUD (docs/notch-hud.md): a transparent always-on-top strip by the notch showing+ * walking agent mascots while agents work, expanding into a mini session panel. Default on;+ * macOS + desktop only (ignored on other platforms / Server Edition). */+ notchHud: boolean/** Dictation (desktop/server). Written as a whole object by the renderer. */speech: SpeechSettings}@@ -741,6 +745,8 @@ export const DEFAULT_SETTINGS: Settings = {// Deterministic hook-reply approvals default ON (existing users pick it up on hydrate). Only// affects Claude terminal sessions; off reproduces the pre-feature launch bit-for-bit.hookReplyApprovals: true,+ // macOS Notch HUD default ON (guarded to darwin at runtime; a no-op elsewhere).+ notchHud: true,speech: { engine: 'whisper', model: 'tiny', language: 'auto', shortcut: 'Cmd+Alt' },}