Skip to content

Node-based terminal manager for AI coding agents — tmux-backed terminals and parallel agent sessions as draggable nodes on an infinite pan/zoom canvas. macOS, Linux, and a browser Server Edition.

feat(notch): newest state edge first inside a tier, and a hover grow on the capsule

reviewe10a51faab75
diff --git a/docs/notch-hud.md b/docs/notch-hud.md
index a6716705a..7713f2209 100644
--- a/docs/notch-hud.md
+++ b/docs/notch-hud.md
@@ -96,16 +96,23 @@ Row shape sent to the HUD:
prompt?, activity?, contextPercent?, unread,
subagents: [{ id, label?, state: 'working'|'done' }], updatedAt }
```
-- **row order = STATE PRIORITY, not recency** (`hudRowRank`): `needsYou` → unread `done` →
- `working` → `idle`, the sessions sidebar's own section order (`STATUS_GROUP_ORDER`,
- renderer/lib/sessionList.ts) — the owner asked the notch to follow the sidebar's model. Ties
- inside a tier break on **first appearance** (the accum Map's insertion order), a fact no feed
- event can change. The rows used to sort on `updatedAt` DESC, and `updatedAt` is bumped by every
- event including the `onNodeNowChange` activity/context ticks, so a busy session climbed to the
- top every few seconds and — because the panel draws only the first `HUD_ROW_CAP` rows — each
- climb also evicted the last row and handed it back: the reported "keeps reshuffling, things
- disappear and come back". `updatedAt` still drives the row's reltime tag and the staleness
- watchdog; it is simply no longer doing double duty as the row's position.
+- **row order = STATE PRIORITY, then the newest STATE EDGE** (`hudRowRank`, then `stateAt` DESC):
+ `needsYou` → unread `done` → `working` → `idle`, the sessions sidebar's own section order
+ (`STATUS_GROUP_ORDER`, renderer/lib/sessionList.ts), so needs-you stays pinned on top. Inside a
+ tier the session whose state moved most recently comes first — the turn that just finished (the
+ chime you just heard) heads the unread rows (owner: "en son biten en yukarı"). An exact tie falls
+ back to first appearance (the accum Map's insertion order). `stateAt` is set only when the
+ state VALUE changes (a live edge, or a mirror flush that moves the bucket), never by a tick. That
+ split is load-bearing: the rows once sorted on `updatedAt` DESC, and `updatedAt` is bumped by
+ every event including the `onNodeNowChange` activity/context ticks, so a busy session climbed to
+ the top every few seconds and — because the panel draws only the first `HUD_ROW_CAP` rows — each
+ climb also evicted the last row and handed it back ("keeps reshuffling, things disappear and
+ come back"). `updatedAt` still drives the row's reltime tag and the staleness watchdog only.
+- **hover grow**: the collapsed capsule swells `--capsule-hover-grow` (4 px) sideways and down
+ while the pointer is on it (`.hovering`, toggled on pointerenter/leave in main.ts — not `:hover`,
+ the window is click-through until that event). Fused, it grows LEFT only (right edge pinned to the
+ notch). It is the feedback before the hover dwell opens the panel, and the only one when
+ hover-expand is off.
- **`unread`** is the done latch said out loud (`state === 'done' && !doneSeen`) — the same mark
the sidebar carries. It was previously readable only as "the row exists at all", which is
invisible beside five other rows and looks like a glitch when a phone-side read-ack retires the
diff --git a/src/main/notch-hud-model.test.ts b/src/main/notch-hud-model.test.ts
index 719044b21..a3df91010 100644
--- a/src/main/notch-hud-model.test.ts
+++ b/src/main/notch-hud-model.test.ts
@@ -268,7 +268,7 @@ describe('6h drop', () => {
// 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 — state priority, never recency', () => {
+describe('row ordering — state priority, then newest state edge', () => {
it('ranks needsYou → unread done → working → idle (the sidebar’s section order)', () => {
expect(hudRowRank({ state: 'needsYou', unread: false })).toBeLessThan(
hudRowRank({ state: 'done', unread: true })
@@ -284,16 +284,16 @@ describe('row ordering — state priority, never recency', () => {
expect(hudRowRank({ state: 'done', unread: false })).toBe(hudRowRank({ state: 'idle', unread: false }))
})
- it('orders the built rows by tier, regardless of how recently each moved', () => {
+ it('orders the built rows by tier before recency', () => {
const m = createHudModel()
- // Deliberately created oldest-tier-first and with recency running the OTHER way: under the old
- // `updatedAt` sort this came out exactly reversed.
+ // Created oldest-tier-first with recency running the OTHER way: the tier still wins, and only
+ // the two working rows (same tier) come out newest-first.
m.applyStateChange(stateChange({ nodeId: 'w1', state: 'working', agentId: 'claude', ts: T0 + 1 }))
m.applyStateChange(stateChange({ nodeId: 'd1', state: 'done', agentId: 'gemini', ts: T0 + 2 }))
m.applyStateChange(stateChange({ nodeId: 'w2', state: 'working', agentId: 'codex', ts: T0 + 3 }))
m.applyStateChange(stateChange({ nodeId: 'n1', state: 'needsYou', agentId: 'claude', ts: T0 + 4 }))
const rows = m.buildRows(T0 + 10, titleOf)
- expect(rows.map((r) => r.nodeId)).toEqual(['n1', 'd1', 'w1', 'w2'])
+ expect(rows.map((r) => r.nodeId)).toEqual(['n1', 'd1', 'w2', 'w1'])
expect(rows.map((r) => r.state)).toEqual(['needsYou', 'done', 'working', 'working'])
})
@@ -312,20 +312,38 @@ describe('row ordering — state priority, never recency', () => {
expect(rowFor(m.buildRows(T0 + 10_000, titleOf), 'c')?.updatedAt).toBe(T0 + 5_000)
})
- it('breaks ties by first appearance, which no feed event can change', () => {
+ it('puts the newest state edge first inside a tier (the turn that just finished on top)', () => {
+ const m = createHudModel()
+ m.applyStateChange(stateChange({ nodeId: 'old', state: 'done', ts: T0 + 100 }))
+ m.applyStateChange(stateChange({ nodeId: 'new', state: 'done', ts: T0 + 300 }))
+ m.applyStateChange(stateChange({ nodeId: 'mid', state: 'done', ts: T0 + 200 }))
+ m.applyStateChange(stateChange({ nodeId: 'q1', state: 'needsYou', ts: T0 + 50 }))
+ m.applyStateChange(stateChange({ nodeId: 'q2', state: 'needsYou', ts: T0 + 60 }))
+ // needs-you stays pinned above every finished turn, however old it is; newest first inside both.
+ expect(m.buildRows(T0 + 400, titleOf).map((r) => r.nodeId)).toEqual(['q2', 'q1', 'new', 'mid', 'old'])
+ // A session that finishes AGAIN (working → done) jumps back to the top of the unread rows.
+ m.applyStateChange(stateChange({ nodeId: 'old', state: 'working', ts: T0 + 500 }))
+ m.applyStateChange(stateChange({ nodeId: 'old', state: 'done', ts: T0 + 600 }))
+ expect(m.buildRows(T0 + 700, titleOf).map((r) => r.nodeId)).toEqual(['q2', 'q1', 'old', 'new', 'mid'])
+ })
+
+ it('only a STATE move reorders: ticks, subagents and a same-state update do not', () => {
const m = createHudModel()
m.applyStateChange(stateChange({ nodeId: 'first', state: 'working', ts: T0 + 100 }))
- m.applyStateChange(stateChange({ nodeId: 'second', state: 'working', ts: T0 + 50 }))
- m.applyStateChange(stateChange({ nodeId: 'third', state: 'working', ts: T0 + 75 }))
- // Timestamps are shuffled; appearance order is not.
- expect(m.buildRows(T0 + 200, titleOf).map((r) => r.nodeId)).toEqual(['first', 'second', 'third'])
- // A subagent burst + a new turn on the youngest row still doesn't hoist it.
- m.applyAgentEvent({ nodeId: 'third', agentId: 'claude', kind: 'subagent-start', toolUseId: 't1' } as never)
- m.applyAgentEvent({ nodeId: 'third', agentId: 'claude', kind: 'state', newTurn: true, task: 'go' } as never)
- expect(m.buildRows(T0 + 300, titleOf).map((r) => r.nodeId)).toEqual(['first', 'second', 'third'])
- // Only a real STATE move relocates a row — and then only to its new tier.
- m.applyStateChange(stateChange({ nodeId: 'third', state: 'needsYou', ts: T0 + 400 }))
- expect(m.buildRows(T0 + 400, titleOf).map((r) => r.nodeId)).toEqual(['third', 'first', 'second'])
+ m.applyStateChange(stateChange({ nodeId: 'second', state: 'working', ts: T0 + 200 }))
+ expect(m.buildRows(T0 + 300, titleOf).map((r) => r.nodeId)).toEqual(['second', 'first'])
+ m.applyAgentEvent({ nodeId: 'first', agentId: 'claude', kind: 'subagent-start', toolUseId: 't1' } as never)
+ m.applyAgentEvent({ nodeId: 'first', agentId: 'claude', kind: 'state', newTurn: true, task: 'go' } as never)
+ m.applyNowChange(nowChange({ nodeId: 'first', ts: T0 + 400, activity: 'Editing a.ts' }))
+ // A repeated `working` edge for a node already working is not news either.
+ m.applyStateChange(stateChange({ nodeId: 'first', state: 'working', ts: T0 + 450 }))
+ expect(m.buildRows(T0 + 500, titleOf).map((r) => r.nodeId)).toEqual(['second', 'first'])
+ })
+
+ it('breaks an exact tie on first appearance', () => {
+ const m = createHudModel()
+ for (const id of ['a', 'b', 'c']) m.applyStateChange(stateChange({ nodeId: id, state: 'done', ts: T0 }))
+ expect(m.buildRows(T0 + 10, titleOf).map((r) => r.nodeId)).toEqual(['a', 'b', 'c'])
})
it('keeps the panel’s first 6 rows STABLE across ticks (what the cap used to churn)', () => {
diff --git a/src/main/notch-hud-model.ts b/src/main/notch-hud-model.ts
index 81752b302..a146c4108 100644
--- a/src/main/notch-hud-model.ts
+++ b/src/main/notch-hud-model.ts
@@ -60,19 +60,21 @@ export interface HudRow {
}
/**
- * Row order tiers, and the ONE reason the HUD does not sort by recency.
+ * Row order: tiers first, then the newest STATE EDGE first inside a tier.
*
- * `needsYou` → unread `done` → `working` → `idle`: what must be acted on, then what is new for
- * you, then what is merely live, then what has settled. This is the sessions sidebar's own section
- * order (`STATUS_GROUP_ORDER` in renderer/lib/sessionList.ts) — the model the owner asked the notch
- * to follow — so the two surfaces rank a session the same way and can share its vocabulary.
+ * `needsYou` → unread `done` → `working` → `idle`: what must be acted on stays pinned on top, then
+ * what is new for you, then what is merely live, then what has settled. Inside a tier the session
+ * whose state moved most recently comes first, so the turn that just finished (the one whose chime
+ * you just heard) is at the top of the unread rows, and the newest question is at the top of the
+ * needs-you rows. The owner asked for exactly this ("en son biten en yukarı").
*
- * The rows used to be sorted `updatedAt` descending, and `updatedAt` is bumped by EVERY feed event
- * including `applyNowChange` — the activity/context ticks a working session emits per tool call. So
- * a busy session climbed to the top every few seconds, and since the panel draws only the first
- * `HUD_ROW_CAP` rows, each climb also changed MEMBERSHIP: the last row dropped off and came back.
- * That was the reported bug ("keeps reshuffling — things disappear and come back"). A tick says
- * nothing about a session's importance, so it must not move the row.
+ * The recency is `stateAt`, NOT `updatedAt`, and that split is the whole point. `updatedAt` is bumped
+ * by EVERY feed event including `applyNowChange`, the activity/context ticks a working session
+ * emits per tool call. The rows used to sort on it, so a busy session climbed to the top every few
+ * seconds, and since the panel draws only the first `HUD_ROW_CAP` rows, each climb also changed
+ * MEMBERSHIP: the last row dropped off and came back ("keeps reshuffling — things disappear and
+ * come back"). `stateAt` moves only when the session's state itself changes, which is an event the
+ * user is told about anyway, so a row moves exactly when there is news.
*/
const ROW_RANK: Record<HudRowState, number> = { needsYou: 0, done: 1, working: 2, idle: 3 }
@@ -100,8 +102,11 @@ interface NodeAccum {
activity?: string
contextPercent?: number
subagents: Map<string, HudSubagentRow>
- /** Last time anything about this node changed — orders rows + gates the stale drop. */
+ /** Last time anything about this node changed — the reltime tag + the stale drop. Ticks bump
+ * it, so it must never order rows (see `hudRowRank`). */
updatedAt: number
+ /** When `state` last took its current value — the within-tier row order (newest first). */
+ stateAt: 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. */
@@ -189,6 +194,7 @@ export function createHudModel(): HudModel {
state: 'idle',
subagents: new Map(),
updatedAt: ts,
+ stateAt: ts,
presentInMirror: false,
doneSeen: false
}
@@ -201,6 +207,7 @@ export function createHudModel(): HudModel {
const a = ensure(c.nodeId, c.ts)
if (c.agentId) a.agentId = c.agentId
if (c.sessionId) a.sessionId = c.sessionId
+ if (a.state !== c.state) a.stateAt = c.ts
a.state = c.state
a.updatedAt = c.ts
if (c.state === 'working') {
@@ -245,13 +252,17 @@ export function createHudModel(): HudModel {
if (n.state) {
const bucket = bucketState(n.state)
if (bucket === 'done') {
- if (a.state !== 'done') a.state = 'done'
+ if (a.state !== 'done') {
+ a.state = 'done'
+ a.stateAt = n.updatedAt
+ }
// A `done` we learn about from the mirror on FIRST sight is pre-seen: it finished before
// this HUD existed. Otherwise every app launch (and every re-enable of the setting)
// resurrected up to 6 h of already-read "finished" sessions as fresh green blobs. Only a
// live done EDGE — a turn that ends while we're watching — earns the highlight.
if (firstSighting) a.doneSeen = true
} else {
+ if (a.state !== bucket) a.stateAt = n.updatedAt
a.state = bucket
if (bucket === 'working') a.doneSeen = false
}
@@ -355,11 +366,10 @@ export function createHudModel(): HudModel {
function buildRows(now: number, getTitle: (nodeId: string) => string | undefined): HudRow[] {
// Collected in `nodes` iteration order — a Map iterates in INSERTION order, and an accum is
// inserted exactly once (`ensure` sets only when the key is absent; nothing re-sets a live
- // key), so this index is "the order these sessions first appeared to the HUD". That is the
- // tiebreak below: it is a fact no feed event can change, which is precisely what `updatedAt`
- // was not. A pruned node that later returns re-enters at the end of its tier — the only way a
- // row moves within a tier, and it is a genuinely new session as far as the HUD is concerned.
- const rows: { row: HudRow; seen: number }[] = []
+ // key), so this index is "the order these sessions first appeared to the HUD". It is the LAST
+ // tiebreak below, for two rows whose state moved in the same millisecond (a mirror flush seeds
+ // many at once): a fact no feed event can change, so equal rows never swap places on a rebuild.
+ const rows: { row: HudRow; seen: number; stateAt: number }[] = []
for (const [nodeId, a] of nodes) {
const state = displayState(a, now)
// The HUD shows active sessions only — nothing when a node is idle/seen.
@@ -388,13 +398,16 @@ export function createHudModel(): HudModel {
unread: state === 'done' && !a.doneSeen,
updatedAt: a.updatedAt
},
- seen: rows.length
+ seen: rows.length,
+ stateAt: a.stateAt
})
}
- // Tier first, first-appearance second. Deliberately NOT `updatedAt` on either axis (see
- // `hudRowRank`): a row moves only when the SESSION's state moves, so an activity tick can
- // neither reorder the panel nor push the last row out of the cap and back in.
- rows.sort((x, y) => hudRowRank(x.row) - hudRowRank(y.row) || x.seen - y.seen)
+ // Tier first, newest state edge second, first appearance last. Deliberately NOT `updatedAt` on
+ // any axis (see `hudRowRank`): a row moves only when the SESSION's state moves, so an activity
+ // tick can neither reorder the panel nor push the last row out of the cap and back in.
+ rows.sort(
+ (x, y) => hudRowRank(x.row) - hudRowRank(y.row) || y.stateAt - x.stateAt || x.seen - y.seen
+ )
return rows.map((r) => r.row)
}
diff --git a/src/renderer/hud/hud.css b/src/renderer/hud/hud.css
index 780a498fe..5b26a57b1 100644
--- a/src/renderer/hud/hud.css
+++ b/src/renderer/hud/hud.css
@@ -22,6 +22,8 @@
--capsule-bg: #000; /* opaque black — fuses with the physical notch (no seam) */
--capsule-ease: cubic-bezier(0.22, 1, 0.36, 1); /* spring-ish grow */
--capsule-dur: 0.22s;
+ /* How much the COLLAPSED capsule grows under the pointer, on each side and downward. */
+ --capsule-hover-grow: 4px;
/* Placement (from main's hudPlacement — see .hud-capsule below); the defaults only cover the
instant before the first push. */
--capsule-x: 50%;
@@ -174,6 +176,36 @@ body {
padding-top: 0; /* no notch to clear — center in the pill */
}
+/* HOVER GROW (collapsed only): the capsule swells a few px sideways and down under the pointer, a
+ Dynamic-Island-style "I heard you" before the dwell opens the panel (main.ts toggles `.hovering`).
+ The indicator carries the size, so the capsule's max-height has to make room for it too. The
+ fused capsule is anchored by its RIGHT edge against the notch, so its sideways grow goes left and
+ never creeps over the menu-bar items on the right. */
+.hud-indicator {
+ transition:
+ height var(--capsule-dur) var(--capsule-ease),
+ padding var(--capsule-dur) var(--capsule-ease);
+}
+.hud-capsule.hovering:not(.expanded) {
+ max-height: calc(var(--bar) + var(--capsule-hover-grow));
+}
+.hud-capsule.hovering:not(.expanded) .hud-indicator {
+ height: calc(var(--bar) + var(--capsule-hover-grow));
+ padding-left: calc(10px + var(--capsule-hover-grow));
+ padding-right: calc(8px + var(--capsule-hover-grow));
+}
+.pill .hud-capsule.hovering:not(.expanded) {
+ max-height: calc(var(--pill-height) + var(--capsule-hover-grow));
+}
+.pill .hud-capsule.hovering:not(.expanded) .hud-indicator {
+ height: calc(var(--pill-height) + var(--capsule-hover-grow));
+}
+@media (prefers-reduced-motion: reduce) {
+ .hud-indicator {
+ transition: none;
+ }
+}
+
/* --- Walking mascots (copied from styles.css .term-node__mascot*) --- */
.mascot {
display: inline-block;
diff --git a/src/renderer/hud/main.ts b/src/renderer/hud/main.ts
index 0aefc2430..28e415ea4 100644
--- a/src/renderer/hud/main.ts
+++ b/src/renderer/hud/main.ts
@@ -110,12 +110,18 @@ let showAllRows = false
const HOVER_OPEN_MS = 180
let hoverTimer: number | undefined
+// A small grow under the pointer (owner: "üzerine gelince biraz daha genişlesin"), so the capsule
+// answers the hover before the dwell opens the panel — and is the only feedback when hover-expand
+// is off. A class, not `:hover`: the window is click-through until this very event, and forwarded
+// moves are what we can rely on, not the CSS hover state. Drawn by `.hud-capsule.hovering`.
capsule.addEventListener('pointerenter', () => {
+ capsule.classList.add('hovering')
window.hud.setIgnoreMouse(false)
window.clearTimeout(hoverTimer)
if (hoverExpand) hoverTimer = window.setTimeout(() => setExpanded(true), HOVER_OPEN_MS)
})
capsule.addEventListener('pointerleave', () => {
+ capsule.classList.remove('hovering')
window.clearTimeout(hoverTimer)
window.hud.setIgnoreMouse(true)
if (expanded) setExpanded(false)