The ultimate harness for coding agents and beyond. All your agents. All your machines. One command center. Start with code, then follow your curiosity and build across disciplines: CAD, circuits, robots, games and music.
TypeScript 3d-modelingagent-frameworkagent-harnessai-agentscadclaude-codecodexcoding-agentsdeveloper-toolsesp32game-developmentmcp-servermulti-agentopen-hardwareopencodeopenharnesspcbroboticsterminaltmux
Dial: hold the active tab, not the fleet
0xdiego25a1108786375f
diff --git a/cli/src/cable/cableHost.spec.ts b/cli/src/cable/cableHost.spec.tsindex efd1c8310..1c97d5442 100644--- a/cli/src/cable/cableHost.spec.ts+++ b/cli/src/cable/cableHost.spec.ts@@ -46,6 +46,12 @@ function fleetOf(machines: FleetMachine[]): MachineFleet {const REMOTE: FleetMachine = { machineId: 'other', name: 'office-imac', state: 'ready', authMode: 'remote' }+/** The window, open on one tab that holds these panes in this order. */+function onTab(host: DaemonCableHost, agentIds: string[], id = 't1'): void {+ host.setSwarms({ active: id, swarms: [{ id, name: 'Tab', agentIds }] })+ host.setDesk(agentIds)+}+describe('DaemonCableHost.listMachines', () => {it('names the local row after the machine, and marks it local', async () => {// The row carries the machine's name; what identifies it as the cabled one is the `local` flag, which@@ -91,7 +97,7 @@ describe('DaemonCableHost.listMachines', () => {})})-describe('DaemonCableHost.listAgents', () => {+describe('DaemonCableHost.listAgentsFlat', () => {const set = (rows: Array<{ agentId: string; registeredAt: number; active?: boolean; terminalAvailable?: boolean }>): void => {AGENTS.length = 0for (const r of rows) AGENTS.push({ engine: 'claude', active: true, terminalAvailable: true, ...r })@@ -106,13 +112,13 @@ describe('DaemonCableHost.listAgents', () => {{ agentId: 'stale', registeredAt: 3, terminalAvailable: false },])const host = new DaemonCableHost(wiring())- expect((await host.listAgents()).map((a) => a.id)).toEqual(['a', 'b'])+ expect((await host.listAgentsFlat()).map((a) => a.id)).toEqual(['a', 'b'])})it('orders oldest first', async () => {set([{ agentId: 'new', registeredAt: 30 }, { agentId: 'old', registeredAt: 10 }, { agentId: 'mid', registeredAt: 20 }])const host = new DaemonCableHost(wiring())- expect((await host.listAgents()).map((a) => a.id)).toEqual(['old', 'mid', 'new'])+ expect((await host.listAgentsFlat()).map((a) => a.id)).toEqual(['old', 'mid', 'new'])})it('breaks a tie by id, so the order never falls through to insertion order', async () => {@@ -120,10 +126,10 @@ describe('DaemonCableHost.listAgents', () => {// daemon runs, so the web, the app and the dial would each show a different order for one registry.set([{ agentId: 'zz', registeredAt: 5 }, { agentId: 'aa', registeredAt: 5 }])const host = new DaemonCableHost(wiring())- expect((await host.listAgents()).map((a) => a.id)).toEqual(['aa', 'zz'])+ expect((await host.listAgentsFlat()).map((a) => a.id)).toEqual(['aa', 'zz'])set([{ agentId: 'aa', registeredAt: 5 }, { agentId: 'zz', registeredAt: 5 }])- expect((await new DaemonCableHost(wiring()).listAgents()).map((a) => a.id)).toEqual(['aa', 'zz'])+ expect((await new DaemonCableHost(wiring()).listAgentsFlat()).map((a) => a.id)).toEqual(['aa', 'zz'])})})@@ -206,7 +212,7 @@ describe('the cloud lane follows the CABLE, not the selection', () => {})})-describe('DaemonCableHost.listAgents across machines', () => {+describe('DaemonCableHost.listAgentsFlat across machines, and the tab the dial gets', () => {/** A fleet whose remote agent lists are scripted per machine. */function crossFleet(byMachine: Record<string, Array<{ id: string; name: string }>>, machines = [REMOTE]): MachineFleet {const fleet = fleetOf(machines)@@ -218,10 +224,10 @@ describe('DaemonCableHost.listAgents across machines', () => {}/** Two ticks: the first kicks the background refresh off, the second reads what it wrote. */- async function settled(host: DaemonCableHost): Promise<Awaited<ReturnType<DaemonCableHost['listAgents']>>> {- await host.listAgents()+ async function settled(host: DaemonCableHost): Promise<Awaited<ReturnType<DaemonCableHost['listAgentsFlat']>>> {+ await host.listAgentsFlat()await new Promise((r) => setTimeout(r, 0))- return host.listAgents()+ return host.listAgentsFlat()}it('puts this computer first and every other machine after it, in wheel order', async () => {@@ -277,58 +283,73 @@ describe('DaemonCableHost.listAgents across machines', () => {const machines: FleetMachine[] = [{ ...REMOTE }]const host = new DaemonCableHost(wiring(), crossFleet({ other: [{ id: 'r1', name: 'api' }] }, machines))await settled(host)- host.setDesk(['r1'])+ onTab(host, ['r1'])machines[0].state = 'offline'const agents = await settled(host)expect(agents.map((a) => a.id)).toEqual(['r1'])- // Under the name and machine it was last seen with, not a placeholder.+ // Under the name and machine it was last seen with, not a placeholder — and still on the dial's tab.expect(agents[0]).toMatchObject({ name: 'api', machineId: 'other', machine: 'office-imac' })+ expect((await host.listAgents()).map((a) => a.id)).toEqual(['r1'])expect(host.knows('r1')).toBe(true)})- it('answers the RAIL\'s order flat, and the dial\'s ring separately, from one snapshot', async () => {- // Two questions, two right answers, and they must not be confused for each other. The dial walks a- // ring cut around the window's open tiles; ⌘K weighs "the first fifteen agents" against a list the- // person is reading top to bottom in their rail. Serving the ring to ⌘K makes the fifteen it picks- // impossible to predict from the screen — the tile someone happened to open last silently reorders- // what a typed task is even compared against.+ it('answers the RAIL\'s order flat, and the dial\'s tab separately, from one snapshot', async () => {+ // Two questions, two right answers, and they must not be confused for each other. The dial holds the+ // window's open tab, in tile order; ⌘K weighs "the first fifteen agents" against a list the person is+ // reading top to bottom in their rail. Serving the tab to ⌘K makes the fifteen it picks impossible to+ // predict from the screen — the tile someone happened to open last silently reorders what a typed+ // task is even compared against.AGENTS.length = 0AGENTS.push({ agentId: 'local-1', registeredAt: 1, active: true, terminalAvailable: true, engine: 'claude' })AGENTS.push({ agentId: 'local-2', registeredAt: 2, active: true, terminalAvailable: true, engine: 'claude' })const host = new DaemonCableHost(wiring(), crossFleet({ other: [{ id: 'r1', name: 'api' }] }))await settled(host)- // Two tiles, in an order the rail does not have: the remote agent first. ONE tile would not show the- // difference — a single-tile desk cuts the ring into head + tile + tail, which reassembles into the- // flat order exactly, so a test built on it would pass against either implementation.- host.setDesk(['r1', 'local-1'])+ // Two tiles, in an order the rail does not have: the remote agent first.+ onTab(host, ['r1', 'local-1'])// The rail: this computer's agents in their own order, then the other machine's.expect((await host.listAgentsFlat()).map((a) => a.id)).toEqual(['local-1', 'local-2', 'r1'])- // The ring: the same three, re-cut around the desk — the tiles in tile order, the rest off its edges.- const ring = await host.listAgents()- expect([...ring].map((a) => a.id).sort()).toEqual(['local-1', 'local-2', 'r1'])- expect(ring.map((a) => a.id)).toEqual(['r1', 'local-1', 'local-2'])+ // The dial: the tab's two tiles in tile order, and local-2 — open nowhere — not at all.+ expect((await host.listAgents()).map((a) => a.id)).toEqual(['r1', 'local-1'])+ expect(host.agentTotal()).toBe(3)})- it('lists every agent, marking the ones the carousel does not walk', async () => {- // Ring first, then the rest — the session sends the count of the first- // group, so the ORDER is the split. Every agent is still listed, because- // the dial's own count and its switcher read this list.+ it('sends the dial nothing with no window, and says so in the tab id', async () => {+ // A shut app is not an empty tab. Both send zero rows; the dial draws "Run OpenHarness" for one and+ // "Nothing on this tab" for the other, and `activeSwarm` is the only thing that tells them apart.AGENTS.length = 0- for (const agentId of ['a1', 'a2', 'a3', 'a4']) {+ for (const agentId of ['a1', 'a2']) {AGENTS.push({ agentId, registeredAt: 1, active: true, terminalAvailable: true, engine: 'claude' })}const host = new DaemonCableHost(wiring())await settled(host)- // Tiles at both ends of the list: a2 and a3 are between them, so neither is- // reached by stepping off an edge.- host.setDesk(['a1', 'a4'])- const agents = await host.listAgents()- expect(agents.map((a) => a.id)).toEqual(['a1', 'a4', 'a2', 'a3'])- expect(agents.filter((a) => !a.offRing).map((a) => a.id)).toEqual(['a1', 'a4'])- expect(agents.filter((a) => a.offRing).map((a) => a.id)).toEqual(['a2', 'a3'])+ expect(await host.listAgents()).toEqual([])+ expect(host.activeSwarm()).toBe('')+ // The count still travels: the overview prints it without holding a row per agent.+ expect(host.agentTotal()).toBe(2)++ onTab(host, [], 'fresh')+ expect(await host.listAgents()).toEqual([])+ expect(host.activeSwarm()).toBe('fresh')++ host.setSwarms(null)+ host.setDesk([])+ expect(host.activeSwarm()).toBe('')+ })++ it('describes an agent it has listed, for a card about one the dial does not hold', async () => {+ AGENTS.length = 0+ AGENTS.push({ agentId: 'a1', registeredAt: 1, active: true, terminalAvailable: true, engine: 'codex' })+ const host = new DaemonCableHost(wiring(), crossFleet({ other: [{ id: 'r1', name: 'api' }] }))+ await settled(host)+ onTab(host, ['a1'])++ // r1 is off the tab — the dial has no row for it — and the frame has to carry who it is.+ expect(host.describe('r1')).toEqual({ name: 'api', engine: '', machine: 'office-imac' })+ expect(host.describe('a1')).toMatchObject({ name: 'a1', engine: 'codex', machine: 'MacbookPro.local' })+ expect(host.describe('ghost')).toBeUndefined()})it('does not resurrect an agent that has no tile', async () => {@@ -371,7 +392,7 @@ describe('DaemonCableHost.listAgents across machines', () => {expect(focused).toHaveBeenCalledWith('other', 'r1')})- it('steps focus along the ring, wrapping at both ends, with the same forward the dial uses', async () => {+ it('steps focus along the tab, wrapping at both ends, with the same forward the dial uses', async () => {AGENTS.length = 0for (const agentId of ['a1', 'a2', 'a3']) {AGENTS.push({ agentId, registeredAt: 1, active: true, terminalAvailable: true, engine: 'claude' })@@ -380,12 +401,12 @@ describe('DaemonCableHost.listAgents across machines', () => {const host = new DaemonCableHost(wiring({ focused }))await settled(host)// Tiles in the window's order, not registration order; a3 has no tile and is never stepped onto.- host.setDesk(['a2', 'a1'])+ onTab(host, ['a2', 'a1'])expect(await host.stepFocus('next', 'a2')).toEqual({ machineId: 'mine', agentId: 'a1' })expect(await host.stepFocus('next', 'a1')).toEqual({ machineId: 'mine', agentId: 'a2' })expect(await host.stepFocus('previous', 'a2')).toEqual({ machineId: 'mine', agentId: 'a1' })- // Off the ring, or nothing focused: the walk starts at the first (next) or last (previous) tile.+ // Off the tab, or nothing focused: the walk starts at the first (next) or last (previous) tile.expect(await host.stepFocus('next', 'a3')).toMatchObject({ agentId: 'a2' })expect(await host.stepFocus('previous', undefined)).toMatchObject({ agentId: 'a1' })expect(focused.mock.calls.map((c) => c[1])).toEqual(['a1', 'a2', 'a1', 'a2', 'a1'])@@ -397,7 +418,7 @@ describe('DaemonCableHost.listAgents across machines', () => {const focused = vi.fn()const host = new DaemonCableHost(wiring({ focused }), crossFleet({ other: [{ id: 'r1', name: 'api' }] }))await settled(host)- host.setDesk(['a1', 'r1'])+ onTab(host, ['a1', 'r1'])expect(await host.stepFocus('next', 'a1')).toEqual({ machineId: 'other', agentId: 'r1' })expect(focused).toHaveBeenLastCalledWith('other', 'r1')@@ -419,18 +440,18 @@ describe('DaemonCableHost.listAgents across machines', () => {const host = new DaemonCableHost(wiring({ focused }))await settled(host)- host.setDesk(['a2'])+ onTab(host, ['a2'])await host.listAgents()host.focus('a2')expect(focused).toHaveBeenLastCalledWith(expect.any(String), 'a2')- // Even for one the carousel does not walk — the switcher can still name it, and the window opening- // it is what puts it on the desk.+ // Even for one the dial does not hold — a notification can still name it, and the window opening it+ // is what puts it on the tab.host.focus('a3')expect(focused).toHaveBeenLastCalledWith(expect.any(String), 'a3')})- it('walks the desk and nothing else', async () => {+ it('holds the tab in tile order and nothing else', async () => {AGENTS.length = 0for (const agentId of ['a1', 'a2', 'a3', 'a4']) {AGENTS.push({ agentId, registeredAt: 1, active: true, terminalAvailable: true, engine: 'claude' })@@ -438,31 +459,18 @@ describe('DaemonCableHost.listAgents across machines', () => {const host = new DaemonCableHost(wiring())await settled(host)- host.setDesk(['a3', 'a1'])+ onTab(host, ['a3', 'a1'])const listed = await host.listAgents()- // Tile order first — that is what the dial walks — then everything else, marked so the session can- // count the split. The old ring wrapped the desk in two arcs of off-desk agents; a thumb can no- // longer step onto one at all.- expect(listed.map((a) => a.id)).toEqual(['a3', 'a1', 'a2', 'a4'])- expect(listed.filter((a) => !a.offRing).map((a) => a.id)).toEqual(['a3', 'a1'])- })-- it('pushes the agents in ring order, tiles first', async () => {- AGENTS.length = 0- for (const agentId of ['a1', 'a2', 'a3', 'a4']) {- AGENTS.push({ agentId, registeredAt: 1, active: true, terminalAvailable: true, engine: 'claude' })- }- const host = new DaemonCableHost(wiring({}))- await settled(host)+ // Tile order — that is what the dial walks — and the two agents with no tile are not sent at all.+ // They used to ride along as "off-ring" for the overview's count and the switcher; the count is a+ // number now and the switcher is gone.+ expect(listed.map((a) => a.id)).toEqual(['a3', 'a1'])+ expect(host.agentTotal()).toBe(4)- host.setDesk(['a3', 'a1'])- const ids = (await host.listAgents()).map((a) => a.id)- // Tiles in TILE order in the middle; a2 is nearer a1's end walking back,- // a4 nearer a3's end walking forward.- expect(ids.slice(ids.indexOf('a3'), ids.indexOf('a3') + 2)).toEqual(['a3', 'a1'])- expect(ids).toHaveLength(4)- expect(new Set(ids).size).toBe(4)+ // A tile naming an id this daemon has never listed is skipped, not invented.+ onTab(host, ['a3', 'ghost'])+ expect((await host.listAgents()).map((a) => a.id)).toEqual(['a3'])})it('does not guess a machine for an unknown dial focus', async () => {diff --git a/cli/src/cable/cableHost.ts b/cli/src/cable/cableHost.tsindex aa184112c..c61ed2e50 100644--- a/cli/src/cable/cableHost.ts+++ b/cli/src/cable/cableHost.ts@@ -8,7 +8,6 @@// read, the router is the one the backend already calls for remote machines, and the turn events arrive// as the very `commander_event` cards the WiFi device receives — teed at the socket rather than emitted// again here, so the two device surfaces cannot drift.-import { deskRing } from './deskRing.js'import { join } from 'node:path'import { AuthSessionManager, readAuthSession } from '../lib/authSession.js'@@ -308,8 +307,7 @@ export class DaemonCableHost implements CableHost {* `refreshRemotes()` does the asking, off to the side, on its own slower clock.*//**- * The window's tiles, in tile order. Empty until the app says otherwise, and- * empty is meaningful: with no tiles the ring is just the flat list.+ * The window's tiles on its active tab, in tile order. This IS the dial's list — see listAgents.*/private desk: string[] = []@@ -324,12 +322,15 @@ export class DaemonCableHost implements CableHost {*/private knownAgents = new Map<string, CableAgent>()- /** Tiles currently held on the ring from that memory, so it is logged once and not every tick. */+ /** Tiles currently held on the list from that memory, so it is logged once and not every tick. */private deskHeld = new Set<string>()- /** Last logged shape of the ring, so the line above prints on change only. */+ /** Last logged shape of the tab's list, so the line prints on change only. */private deskShape = ''+ /** Size of the last flat list — see agentTotal. */+ private flatCount = 0+/*** The window changed which agents have a tile, or what order they are in.*@@ -346,9 +347,8 @@ export class DaemonCableHost implements CableHost {/*** The window described its swarms (or, with null, went away).*- * Also what makes the desk STRICT: a window that is present and says its desk is empty means it —- * a fresh swarm has no panes — and the carousel walks nothing rather than everything. A window that- * is gone said nothing, and the old fallback applies.+ * Null is what tells the dial the window is SHUT: an empty desk with a window behind it is an empty+ * tab, an empty desk with none is a closed app, and the two draw different screens — see listAgents.*/setSwarms(swarms: AppSwarms | null): void {this.swarms = swarms@@ -372,41 +372,65 @@ export class DaemonCableHost implements CableHost {this.wiring.swarmSelected?.(swarmId)}+ /**+ * THE DIAL HOLDS THE ACTIVE TAB'S PANES AND NOTHING ELSE.+ *+ * It used to get every agent on every machine — the window's tiles first as the ring, the rest tagged+ * "off-ring, still sent" for the overview count and the pull-down switcher. That is what let a+ * reconnect refill 78 agents into a screen that shows one: ten seconds under one display lock, the task+ * watchdog, a reboot (PR #79 painted it once; this stops sending it). The count now travels as a number+ * (`agentTotal`), the switcher is gone, and a notification for an agent the dial does not hold carries+ * its own name.+ *+ * Three answers, and each is a state the dial draws:+ * - no window (`swarms === null`) → `[]`; the dial shows "Run OpenHarness on your computer".+ * - a window with an empty tab → `[]`; the dial shows "Nothing on this tab".+ * - a window with panes → those agents, in tile order; a tile whose machine dropped out+ * is held from `knownAgents` (see listAgentsFlat).+ */async listAgents(): Promise<CableAgent[]> {- const out = await this.listAgentsFlat()-- const ring = deskRing(out.map((a) => a.id), this.desk, this.swarms !== null)- // Walked agents first, then the ones the dial knows but does not walk to —- // the session sends the count of the first group, so the order is the split.- const listed = [...ring.order, ...ring.offRing]- // One line per CHANGE. The failure this catches is silent by nature: tiles- // whose ids this daemon does not know leave the ring flat and every agent- // edgeless, which looks exactly like the feature not being installed.- const onDesk = new Set(this.desk)- const short = (id: string) => `${onDesk.has(id) ? '*' : ''}${id.slice(0, 4)}`- // Both halves: what the thumb walks, and what the dial merely knows. Reading- // only the first half is how "the dial says 5 agents" looked like a counting- // bug rather than a list that had been cut in two.- const shape = ring.order.map(short).join(' ')- + (ring.offRing.length ? ` · off-ring ${ring.offRing.map(short).join(' ')}` : '')+ const flat = await this.listAgentsFlat()+ const byId = new Map(flat.map((a) => [a.id, a]))+ const out = this.swarms === null+ ? []+ : this.desk.map((id) => byId.get(id)).filter((a): a is CableAgent => !!a)+ // One line per CHANGE. The failure this catches is silent by nature: tiles whose ids this daemon does+ // not know drop out of the list, which looks exactly like the window never having opened them.+ const shape = this.swarms === null+ ? '(no window)'+ : out.length ? out.map((a) => a.id.slice(0, 4)).join(' ') : '(empty tab)'if (shape !== this.deskShape) {this.deskShape = shape- // The WHOLE ring, marked: `*` is a tile. Short of this the shape has to be- // guessed from behaviour, and every guess so far has been wrong about- // which end the agents nobody stepped onto ended up at.- this.wiring.log(`cable: ring ${shape}`)+ this.wiring.log(`cable: tab ${shape} · ${flat.length} in all`)}- const offRing = new Set(ring.offRing)- const byId = new Map(out.map((a) => [a.id, a]))- return listed- .map((id) => byId.get(id))- .filter((a): a is CableAgent => !!a)- .map((a) => (offRing.has(a.id) ? { ...a, offRing: true } : a))+ return out+ }++ /** How many agents the account has across every machine — the overview's number, sent beside the+ * tab's list rather than as 70 rows the dial would hold for a digit. Read from the last flat list. */+ agentTotal(): number {+ return this.flatCount+ }++ /** The active tab's id, or '' with no window. Travels on `agents.end` so the dial can tell an empty+ * tab from a shut window — the two draw different screens. */+ activeSwarm(): string {+ return this.swarms?.active ?? ''+ }++ /**+ * Name, engine and machine of an agent this daemon has ever listed — for a `summary` or `question`+ * about one the dial no longer holds. The dial used to look these up in its own copy of the fleet;+ * with that copy gone, the frame has to say who it is about.+ */+ describe(agentId: string): { name: string; engine: string; machine: string } | undefined {+ const a = this.knownAgents.get(agentId)+ return a ? { name: a.name, engine: a.engine ?? '', machine: a.machine ?? '' } : undefined}/**- * The same agents in LIST order — this computer first, then each machine in wheel order — with no ring- * laid over them.+ * EVERY agent in LIST order — this computer first, then each machine in wheel order — the fleet the+ * dial no longer holds.** It is the order the desktop app's rail draws, and the two must not drift: ⌘K reads this to decide* which agents a typed task is weighed against, and a person looking at their rail while they type has@@ -429,12 +453,6 @@ export class DaemonCableHost implements CableHost {for (const a of out) if (a.machineId) next.set(a.id, a.machineId)this.agentMachine = next- // The order the dial actually walks: the window's tiles in the middle, and- // the rest arranged around them so one step off either edge is one step- // along the list from the tile you left. Computed HERE, on the same- // snapshot, because this is the only place that holds every machine's- // agents in one list — the window knows its tiles, not the wheel order they- // sit in.const byId = new Map(out.map((a) => [a.id, a]))for (const a of out) this.knownAgents.set(a.id, a)@@ -448,19 +466,20 @@ export class DaemonCableHost implements CableHost {const remembered = this.knownAgents.get(id)if (!remembered) continue// Appended, not slotted back where it was. When a machine drops out none of its agents are left- // to sit beside, so the end of the list is the only honest place; and the ring is built around- // the DESK, so where a tile sits in the flat list only shifts which agents the arcs reach.- // Never routed by position either — `agentMachine` below is what sends a turn home.+ // to sit beside, so the end of the list is the only honest place; the tab's list is drawn in TILE+ // order by listAgents, so where it sits here does not matter. Never routed by position either —+ // `agentMachine` below is what sends a turn home.out.push(remembered)byId.set(id, remembered)if (remembered.machineId) this.agentMachine.set(id, remembered.machineId)if (!this.deskHeld.has(id)) {this.deskHeld.add(id)- this.wiring.log(`cable: holding ${id.slice(0, 8)} on the ring — the window has a tile for it`)+ this.wiring.log(`cable: holding ${id.slice(0, 8)} on the tab — the window has a tile for it`)}}for (const id of [...this.deskHeld]) if (!missing.includes(id)) this.deskHeld.delete(id)+ this.flatCount = out.lengthreturn out}@@ -649,11 +668,12 @@ export class DaemonCableHost implements CableHost {/*** One tick of the carousel, for a device that has no ring of its own: the paired Autonomous device* asks for "next"/"previous" and this picks the neighbour the USB dial's thumb would land on — the same- * walk (`listAgents()` ring order), the same wrap at either end, and the same `focus()` forward to the- * app. With no current agent on the ring the walk starts at its first (next) or last (previous) tile.+ * walk (`listAgents()`, the tab in tile order), the same wrap at either end, and the same `focus()`+ * forward to the app. With no current agent on the tab the walk starts at its first (next) or last+ * (previous) tile.*/async stepFocus(direction: 'next' | 'previous', currentAgentId?: string): Promise<{ machineId: string; agentId: string } | 'no_agents'> {- const walk = (await this.listAgents()).filter((a) => !a.offRing).map((a) => a.id)+ const walk = (await this.listAgents()).map((a) => a.id)if (walk.length === 0) return 'no_agents'const at = currentAgentId ? walk.indexOf(currentAgentId) : -1const agentId = at < 0diff --git a/cli/src/cable/cableSession.spec.ts b/cli/src/cable/cableSession.spec.tsindex e34ec254a..b959e5f61 100644--- a/cli/src/cable/cableSession.spec.ts+++ b/cli/src/cable/cableSession.spec.ts@@ -87,6 +87,9 @@ function makeHost(over: Partial<CableHost> = {}) {appName: () => 'harness',voiceLang: () => 'en',listAgents: async () => AGENTS,+ agentTotal: () => AGENTS.length,+ activeSwarm: () => 't1',+ describe: (id) => { const a = AGENTS.find((x) => x.id === id); return a ? { name: a.name, engine: a.engine ?? '', machine: a.machine ?? '' } : undefined },sendTurn: vi.fn(),stopTurn: vi.fn(),scrolled: vi.fn(),@@ -875,18 +878,50 @@ describe('cable session', () => {await session.stop()})- it('says how many of the agents it just sent are on the carousel', async () => {- // The dial walks the first N and merely knows the rest. A firmware that- // predates the field ignores it and walks them all, exactly as before.- const agents: CableAgent[] = [- { id: 'a1', name: 'one' },- { id: 'a2', name: 'two', offRing: true },- ]- const { session, port } = await connect(makeHost({ listAgents: async () => agents }))+ it('sends the account-wide count and the tab beside the list, not the rows behind them', async () => {+ // The dial draws one number on the overview; the seventy rows behind it stay here. And `tab` is what+ // tells a shut window from an empty tab when both send zero agents.+ const { session, port } = await connect(makeHost({ agentTotal: () => 71, activeSwarm: () => 'tab-9' }))port.say({ t: 'hello', product: 'harness', mac: 'aa:bb' })await session.pushAgents()- expect(port.sent.filter((m) => m.t === 'agents.end').at(-1)).toMatchObject({ ring: 1 })+ expect(port.sent.filter((m) => m.t === 'agents.end').at(-1)).toMatchObject({ total: 71, tab: 'tab-9' })+ expect(port.sent.filter((m) => m.t === 'agents.end').at(-1)).not.toHaveProperty('ring')+ await session.stop()+ })++ it('pushes the same zero rows again when the window shuts, and not when only the tab changes', async () => {+ // Empty tab → shut app is a change the dial draws ("Nothing on this tab" → "Run OpenHarness"); empty+ // tab A → empty tab B is not — the `swarms` frame carries the tab's name — and pushing on it made+ // every tab switch cost two list pushes.+ let tab = 'a'+ const { session, port } = await connect(makeHost({ listAgents: async () => [], activeSwarm: () => tab }))+ port.say({ t: 'hello', product: 'harness', mac: 'aa:bb' })+ await vi.waitFor(() => expect(port.types()).toContain('agents.end'))+ port.sent.length = 0++ tab = 'b'+ await session.syncAgents()+ expect(port.types().filter((t) => t === 'agents.end')).toEqual([])+ tab = ''+ await session.syncAgents()+ expect(port.sent.filter((m) => m.t === 'agents.end').at(-1)).toMatchObject({ tab: '' })+ await session.stop()+ })++ it('names the agent on every summary and question, for one the dial does not hold', async () => {+ const { session, port } = await connect(makeHost({}))+ port.say({ t: 'hello', product: 'harness', mac: 'aa:bb' })++ await session.summary('a2', 'recap', 'body')+ await session.question('a1', 'q1', [{ key: 'k' }])+ // An id this daemon never listed: the fields travel empty rather than the frame being withheld.+ await session.summary('ghost', 'recap', 'body')++ expect(port.sent.find((m) => m.t === 'summary' && m.agentId === 'a2'))+ .toMatchObject({ name: 'Device firmware voice', engine: 'codex', machine: '' })+ expect(port.sent.find((m) => m.t === 'question')).toMatchObject({ name: 'Fix login screen', engine: 'claude', id: 'q1' })+ expect(port.sent.find((m) => m.t === 'summary' && m.agentId === 'ghost')).toMatchObject({ name: '', engine: '' })await session.stop()})diff --git a/cli/src/cable/cableSession.ts b/cli/src/cable/cableSession.tsindex caadb0161..79b73d657 100644--- a/cli/src/cable/cableSession.ts+++ b/cli/src/cable/cableSession.ts@@ -128,24 +128,12 @@ export interface CableAgent {engine?: stringmodel?: stringeffort?: string- /**- * An agent the dial KNOWS but does not walk to.- *- * The carousel is built around the window's tiles, and an agent sitting- * between them in list order is off neither edge — see `deskRing`. It is- * still sent: the dial counts its agents on the overview and lists them in- * the pull-down switcher, and a dial that says "5 agents" to someone who has- * eleven is simply wrong. What it is left out of is the walk.- */- offRing?: boolean/*** The machine this agent lives on, and that machine's name.*- * THE CAROUSEL IS NO LONGER ONE MACHINE'S. Every agent on every machine is on it at once, so an agent- * that does not say where it lives cannot be driven: the daemon routes each turn, stop and answer by- * this id, and the dial prints the name on the switcher's second line where the engine used to be.- *- * Optional because the WIRE is: a firmware that predates the field simply does not draw it.+ * A tab can hold panes from several machines at once, so an agent that does not say where it lives+ * cannot be driven: the daemon routes each turn, stop and answer by this id, and the dial prints the+ * name under the agent's.*/machineId?: stringmachine?: string@@ -221,7 +209,14 @@ export interface CableHost {selectSwarm(swarmId: string): voidappName(): stringvoiceLang(): string+ /** The active tab's agents, in tile order — and nothing else. Empty with no window or an empty tab. */listAgents(): Promise<CableAgent[]>+ /** Every agent across the account — the overview's number. The dial gets the count, never the rows. */+ agentTotal(): number+ /** The active tab's id, or '' with no window: what lets the dial tell an empty tab from a shut app. */+ activeSwarm(): string+ /** Who an agent is, for a card about one the dial does not hold. Undefined for an id never listed. */+ describe(agentId: string): { name: string; engine: string; machine: string } | undefinedsendTurn(agentId: string, text: string): voidstopTurn(agentId: string): void/**@@ -1099,12 +1094,16 @@ export class CableSession {private async syncAgentsNow(force: boolean): Promise<void> {const agents = await this.host.listAgents()- const key = CableSession.agentsKey(agents)+ // WHETHER there is a window is in the key, not WHICH tab: an empty tab after the window shut sends the+ // same zero rows and draws a different screen, so that flip has to push. The tab's id does not — the+ // dial names the tab from the `swarms` frame — and keying on it made every tab switch push twice,+ // once when `app_swarms` named the new tab over the old panes and again when `app_panes` arrived.+ const key = `${this.host.activeSwarm() ? 'window' : ''}|${CableSession.agentsKey(agents)}`if (!force && key === this.lastAgentsKey) returnthis.lastAgentsKey = key// Every push, and only pushes. The dial showing a different number from the daemon is a question this// line answers in one look: either the daemon never said it, or it said it and the dial disagreed.- this.log(`cable: agents → ${agents.length}${force ? ' (attach)' : ''}`)+ this.log(`cable: agents → ${agents.length} of ${this.host.agentTotal()}${force ? ' (attach)' : ''}`)await this.send({ t: 'agents.begin' })for (const a of agents) {@@ -1116,16 +1115,16 @@ export class CableSession {model: a.model ?? '',effort: a.effort ?? '',// Where it lives. The id is what the dial sends back for every action, the name is what it draws- // on the switcher's second line, and the id is also how a machine row finds its first agent.+ // under the agent's, and the id is also how a machine row finds its first agent.machineId: a.machineId ?? '',machine: a.machine ?? '',})}- // How many of the agents just sent are on the CAROUSEL. They come first, so- // a count is enough, and a firmware that predates the field walks all of- // them exactly as it did before.- await this.send({ t: 'agents.end', ring: agents.filter((a) => !a.offRing).length })+ // Every agent sent is walked. What travels beside them: `total`, the account-wide count the overview+ // prints (the rows behind it stay here), and `tab`, the active tab's id — '' with no window, which is+ // how the dial tells "the app is shut" from "this tab is empty" when both send zero agents.+ await this.send({ t: 'agents.end', total: this.host.agentTotal(), tab: this.host.activeSwarm() })// The list just changed shape under the dial, so say again which agent both screens are on.//@@ -1133,7 +1132,11 @@ export class CableSession {// memory of it — see desiredFocus. A re-anchor after a push is silent by design (the dial reports// nothing it did not do itself), so without this a dial that landed on the wrong tile would sit there// with nobody to notice.- if (this.desiredFocus) {+ //+ // Only for an agent the list just sent. The record can name one on another tab — the window focused+ // it there, then switched — and a focus the dial cannot land is a frame it holds for five seconds and+ // a warning per push; the tab switch is what un-focused it, and the next click sets a new record.+ if (this.desiredFocus && agents.some((a) => a.id === this.desiredFocus)) {this.expectedAppFocusEcho = this.desiredFocusthis.expectedAppFocusEchoUntil = Date.now() + APP_FOCUS_SETTLE_MSawait this.focusAgent(this.desiredFocus)@@ -1355,13 +1358,26 @@ export class CableSession {* did instead of losing the recap.*/async summary(agentId: string, recap: string, text: string, quiet = false): Promise<void> {- await this.send(quiet ? { t: 'summary', agentId, recap, text, quiet: true } : { t: 'summary', agentId, recap, text })+ const who = this.whoIs(agentId)+ await this.send(quiet ? { t: 'summary', agentId, ...who, recap, text, quiet: true } : { t: 'summary', agentId, ...who, recap, text })+ }++ /**+ * The name, engine and machine that ride on every `summary` and `question`.+ *+ * The dial holds ONE TAB's agents, and a turn can finish on any of them — the drawer row and the+ * question card for an agent off this tab have nobody to ask but the frame. Sent on every card rather+ * than only the off-tab ones: the dial then has one path, and a tab switch mid-flight cannot strand a+ * card with an id and no name.+ */+ private whoIs(agentId: string): { name: string; engine: string; machine: string } {+ return this.host.describe(agentId) ?? { name: '', engine: '', machine: '' }}async turnError(agentId: string, message: string): Promise<void> {await this.send({ t: 'turn.error', agentId, message })}async question(agentId: string, id: string, questions: unknown): Promise<void> {- await this.send({ t: 'question', agentId, id, questions })+ await this.send({ t: 'question', agentId, ...this.whoIs(agentId), id, questions })}/**diff --git a/cli/src/cable/deskRing.spec.ts b/cli/src/cable/deskRing.spec.tsdeleted file mode 100644index 7a2932d98..000000000--- a/cli/src/cable/deskRing.spec.ts+++ /dev/null@@ -1,69 +0,0 @@-import { describe, expect, it } from 'vitest'-import { deskRing } from './deskRing.js'--/** Every agent the daemon knows, in the order the dial reads them. */-const FLAT = ['a1', 'a2', 'a3', 'a4', 'a5']--describe('deskRing', () => {- it('walks the window\'s tiles, in tile order', () => {- const ring = deskRing(FLAT, ['a3', 'a1'])- // TILE ORDER, not list order. The point of the ring is that a thumb walks the same grid the eyes- // are looking at, so the window's arrangement wins over the daemon's.- expect(ring.order).toEqual(['a3', 'a1'])- })-- it('leaves every other agent off the walk, but does not drop it', () => {- const ring = deskRing(FLAT, ['a2'])- expect(ring.order).toEqual(['a2'])- // Still sent, still counted on the overview, still in the pull-down switcher. Leaving them out of- // the LIST is what once made a dial announce "5 agents" to someone who had eleven.- expect(ring.offRing).toEqual(['a1', 'a3', 'a4', 'a5'])- })-- it('walks everything when there are no tiles at all', () => {- // A window that is shut, or a daemon nobody has opened one against. A ring built strictly from an- // empty desk would be empty — eight agents on the machine and a carousel showing none of them,- // which reads as a broken dial rather than as a closed window.- const ring = deskRing(FLAT, [])- expect(ring.order).toEqual(FLAT)- expect(ring.offRing).toEqual([])- })-- it('walks NOTHING when a present window says its desk is empty', () => {- // A fresh swarm has no panes. The window is there and describing it, so an empty carousel is the- // truth — the agents stay counted and listed, they are simply not what was chosen to look at.- const ring = deskRing(FLAT, [], true)- expect(ring.order).toEqual([])- expect(ring.offRing).toEqual(FLAT)- })-- it('ignores tiles this daemon has never heard of', () => {- // A tile can name an agent on a machine that has gone quiet. The ring is no place to learn that,- // and a walk that stepped onto an id nothing can be looked up by lands on a blank tile.- const ring = deskRing(FLAT, ['a2', 'ghost', 'a4'])- expect(ring.order).toEqual(['a2', 'a4'])- expect(ring.offRing).toEqual(['a1', 'a3', 'a5'])- })-- it('falls back to the whole list when the desk names nothing real', () => {- // Same as an empty desk, and it has to be: a window whose tiles are all on a machine that stopped- // answering is a window with no usable desk.- const ring = deskRing(FLAT, ['ghost', 'phantom'])- expect(ring.order).toEqual(FLAT)- expect(ring.offRing).toEqual([])- })-- it('puts every agent in exactly one of the two groups', () => {- // The session sends the count of the first group and the dial splits the pushed list on it, so an- // id in both — or in neither — is a tile the dial either walks twice or cannot see.- const ring = deskRing(FLAT, ['a4', 'a2'])- expect([...ring.order, ...ring.offRing].sort()).toEqual([...FLAT].sort())- expect(new Set(ring.order).size + new Set(ring.offRing).size).toBe(FLAT.length)- })-- it('walks the whole list when every agent has a tile', () => {- const ring = deskRing(FLAT, ['a5', 'a4', 'a3', 'a2', 'a1'])- expect(ring.order).toEqual(['a5', 'a4', 'a3', 'a2', 'a1'])- expect(ring.offRing).toEqual([])- })-})diff --git a/cli/src/cable/deskRing.ts b/cli/src/cable/deskRing.tsdeleted file mode 100644index fb1877bed..000000000--- a/cli/src/cable/deskRing.ts+++ /dev/null@@ -1,56 +0,0 @@-/**- * The order the dial's carousel walks, given what the window has on screen.- *- * ONE RULE: the carousel walks the window's tiles, in tile order, and nothing else. Swipe is "the next- * pane", which is what a person watching four terminals already thinks it is.- *- * It used to be three: an arc of off-desk agents, then the desk, then another arc — a non-wrapping- * shape that let a thumb walk past the end of the desk and pull an unopened agent onto it, with the arc- * an agent sat in encoding WHICH tile it replaced so the dial never had to report which way the thumb- * went. It worked, and it cost a concept (`DeskEdge`) that had to be understood in three repositories- * to change anything here. Discovery by swiping is gone with it; the pull-down switcher still lists- * every agent, and picking one there tells the window, which opens it — putting it on the desk, and so- * on the ring, by the ordinary route.- *- * Agents with no tile are still SENT to the dial. They are counted on the overview and listed in that- * switcher; leaving them out is what once made a dial announce "5 agents" to someone who had eleven.- * What they are left out of is the walk.- */-export interface DeskRing {- /** Ids in carousel order: the desk, as the window has it. */- order: string[]- /** Agents the carousel does not walk. Still sent, still counted, simply not stepped onto. */- offRing: string[]-}--/**- * @param flat every agent id, in the order the dial reads them today (this- * computer first, then each machine in wheel order).- * @param desk the window's tiles, in tile order. Ids the flat list does not- * know are ignored: a tile can name an agent on a machine that has- * gone quiet, and a ring is no place to learn that.- */-/**- * @param strict the window is open and this desk is what it really shows, even when that is nothing.- * A swarm with no panes yet is an empty desk on purpose, and the carousel says so rather- * than walking every agent the window is deliberately not showing.- */-export function deskRing(flat: string[], desk: string[], strict = false): DeskRing {- const known = new Set(flat)- const onDesk = desk.filter((id) => known.has(id))-- // NO TILES, NO RESTRICTION — and this fallback is not a nicety.- //- // A dial plugged into a computer whose window is shut has an empty desk, and a ring built strictly- // from that desk would be empty: eight agents on the machine and a carousel showing none of them,- // which reads as a broken dial rather than as a closed window. So with nothing to narrow to, the- // walk is the whole list, exactly as it was before any of this existed.- //- // UNLESS the window said so. `strict` is the window being present and describing an empty desk —- // a fresh swarm — and there the honest carousel is an empty one: the agents are still counted and- // still listed, they are simply not what the person chose to look at.- if (onDesk.length === 0) return strict ? { order: [], offRing: [...flat] } : { order: [...flat], offRing: [] }-- const deskSet = new Set(onDesk)- return { order: onDesk, offRing: flat.filter((id) => !deskSet.has(id)) }-}diff --git a/devices/harness-device/firmware/main/app_main.c b/devices/harness-device/firmware/main/app_main.cindex 737d47eb6..2ebaaf03b 100644--- a/devices/harness-device/firmware/main/app_main.c+++ b/devices/harness-device/firmware/main/app_main.c@@ -63,8 +63,8 @@ static bool boot_button_held(void)// ── the agent list ──────────────────────────────────────────────────────────────────────────────────-// A hundred agents is too much for a task stack, and this is only ever touched by refresh_task, so one-// lazily-allocated PSRAM block is both cheaper and safer than a stack array.+// Only ever touched by refresh_task, so one lazily-allocated PSRAM block rather than a stack array — a+// project_t is not small, and sixteen of them have no business on a task stack.static project_t *proj_scratch(void){static project_t *s_scratch;@@ -88,7 +88,14 @@ static int refresh_projects(void)// Apply the WHOLE reconcile atomically. With the huge-range circular carousel each add/remove// re-anchors the scroll to keep the viewed agent centred; locking per ui_* call (as they do// internally) lets the LVGL task render between them and the viewed tile visibly wobbles.+ //+ // ...and the bulk bracket is why holding the lock that long is affordable. A cable reconnect empties+ // the list and refills it, so this function runs the add and remove paths once per agent; painting in+ // each of them cost ~130ms, which on a 78-agent dial held the display lock for about ten seconds and+ // tripped the task watchdog into a reboot. Inside the bracket the loops below move the MODEL only and+ // the view catches up once, at bulk_end, on the page the person was already looking at.display_lock();+ ui_projects_bulk_begin();for (int i = 0; i < n; i++) {ui_project_set_name(pr[i].id, pr[i].name);@@ -117,12 +124,13 @@ static int refresh_projects(void)static const char *ids[MAX_PROJECTS];for (int i = 0; i < n; i++) ids[i] = pr[i].id;+ ui_projects_bulk_end(); // one re-anchor and one window rebuild for the whole reconciledisplay_unlock();if (n > 1) ui_project_apply_order(ids, n);- // AFTER the order: the count names a PREFIX of the list, so it means nothing until the list is in- // the order the daemon sent.- ui_project_set_ring_count(cable_client_ring_count());+ // The fleet behind the list: the overview's count, and whether the empty page means "no window" or+ // "empty tab".+ ui_fleet_set(cable_client_agent_total(), cable_client_has_window());// The list is built. If a landing is pending, LAND: drop the loading spinner and focus agent 1 (or the// No-agents page). No-op otherwise, so a periodic refresh never yanks the view.diff --git a/devices/harness-device/firmware/main/cable_client.c b/devices/harness-device/firmware/main/cable_client.cindex 1d2389f22..8e00ba255 100644--- a/devices/harness-device/firmware/main/cable_client.c+++ b/devices/harness-device/firmware/main/cable_client.c@@ -45,7 +45,7 @@ typedef struct {char model[24];char effort[16];char machine_id[ID_MAX]; // which machine this agent lives on ("" from a daemon that predates it)- char machine[NAME_MAX]; // that machine's name, drawn on the switcher's second line+ char machine[NAME_MAX]; // that machine's name, drawn under the agent's} cable_agent_t;@@ -342,18 +342,28 @@ void cable_client_fw_error(const char *message)const char *cable_client_machine_name(void) { return s_machine_name; }-// Set by `agents.end`, read by the refresh that applies the list. See ui_project_set_ring_count.-static int s_ring_agents;+// Set by `agents.end`, read by the refresh that applies the list — see ui_fleet_set.+static int s_agents_total;+static bool s_has_window;-int cable_client_ring_count(void)+int cable_client_agent_total(void){if (!s_agents_lock) return 0;xSemaphoreTake(s_agents_lock, portMAX_DELAY);- const int n = s_ring_agents;+ const int n = s_agents_total;xSemaphoreGive(s_agents_lock);return n;}+bool cable_client_has_window(void)+{+ if (!s_agents_lock) return false;+ xSemaphoreTake(s_agents_lock, portMAX_DELAY);+ const bool w = s_has_window;+ xSemaphoreGive(s_agents_lock);+ return w;+}+int cable_client_list_agents(project_t *out, int max){if (!out || max <= 0 || !s_agents_lock || !s_agents) return 0;@@ -526,12 +536,15 @@ static void handle_agents_end(const cJSON *p)xSemaphoreTake(s_agents_lock, portMAX_DELAY);s_agents_building = false;const int n = s_agent_count;- // How many of them the carousel walks. The daemon puts those first, so one number splits the list;- // absent (or from an older daemon) means all of them, which is what the dial did before this existed.- const cJSON *ring = p ? cJSON_GetObjectItemCaseSensitive(p, "ring") : NULL;- s_ring_agents = cJSON_IsNumber(ring) ? (int)ring->valuedouble : 0;+ // The list is the window's active tab. Beside it: how many agents the account has in all (the+ // overview prints that, never the rows), and which tab this is — "" means no window, which is how an+ // empty list reads as "the app is shut" rather than "this tab is empty".+ const cJSON *total = p ? cJSON_GetObjectItemCaseSensitive(p, "total") : NULL;+ const char *tab = p ? str_of(p, "tab") : NULL;+ s_agents_total = cJSON_IsNumber(total) ? (int)total->valuedouble : n;+ s_has_window = tab && tab[0];xSemaphoreGive(s_agents_lock);- ESP_LOGI(TAG, "agents: %d", n);+ ESP_LOGI(TAG, "agents: %d of %d%s", n, s_agents_total, s_has_window ? "" : " (no window)");// app_main's refresh reads the list and rebuilds the tiles. Going through the same request the// backend path used means the carousel's landing, naming and removal logic has one implementation.ui_request_agent_reload();@@ -685,8 +698,11 @@ static void handle_message(const cJSON *root)// own work when the dial is awake, on the carousel, and centred on this very agent.//// Absent field = false, so a daemon that predates this notifies exactly as it always did.+ //+ // WHO IT IS ABOUT rides on the frame. The dial holds one tab's agents, and this turn may have+ // finished on any of them; the drawer row for one off this tab has nobody else to ask.if (!bool_of(p, "quiet")) {- ui_notify_task_done(agent_id); // wake the screen (if off) + record the notification+ ui_notify_task_done(agent_id, str_of(p, "name"), str_of(p, "machine"), str_of(p, "recap"));}return;}@@ -697,7 +713,8 @@ static void handle_message(const cJSON *root)}if (strcmp(t, "question") == 0) {const cJSON *questions = cJSON_GetObjectItemCaseSensitive(p, "questions");- if (agent_id && questions) ui_question_show(agent_id, "", str_of(p, "id"), questions);+ // The name rides on the frame for the same reason as on `summary`: the asker may be off this tab.+ if (agent_id && questions) ui_question_show(agent_id, str_of(p, "name"), str_of(p, "id"), questions);return;}// Somebody else answered it. A question is a dialog in a tmux pane, not a shared object, so this isdiff --git a/devices/harness-device/firmware/main/cable_client.h b/devices/harness-device/firmware/main/cable_client.hindex 61df8245a..0d9c117ab 100644--- a/devices/harness-device/firmware/main/cable_client.h+++ b/devices/harness-device/firmware/main/cable_client.h@@ -73,10 +73,15 @@ const char *cable_fw_version(void);#define CABLE_PROTO_VERSION 3 // 3: + question.close (a question answered on another client)-// Most agents the dial tracks at once — the size of the list this file hands the UI. The UI keeps only a-// thin shell per agent and materialises the heavy content for the active tile ± a window, so a hundred-// costs little more than a dozen.-#define CABLE_MAX_AGENTS 100+// Most agents the dial holds at once — the size of the list this file hands the UI.+//+// THE LIST IS ONE TAB. The daemon sends the window's active tab and nothing else (cableHost.listAgents):+// a tab is at most nine panes, and the rest of the fleet reaches the dial as a count (`agents.end.total`)+// and as the name on a notification. It used to be a hundred, back when every agent on every machine was+// sent so the overview could count them and a pull-down switcher could list them — which is what let a+// reconnect refill 78 tiles into a screen that shows one and trip the task watchdog. Sixteen leaves room+// for a tile the window holds on a machine that dropped out.+#define CABLE_MAX_AGENTS 16// The UI's own ceiling, kept as one name so the layer that receives the list and the layer that renders it// cannot disagree about how many there can be.@@ -108,8 +113,13 @@ const char *cable_client_machine_name(void);// to read the backend's RPC answer.int cable_client_list_agents(project_t *out, int max);-// How many of the agents above the CAROUSEL walks; the rest are known but never swiped to. 0 = all.-int cable_client_ring_count(void);+// How many agents the account has across every machine (`agents.end.total`) — the overview's number. The+// list above is the active tab; this is the fleet it was cut from.+int cable_client_agent_total(void);++// Whether a window is open at the far end: `agents.end.tab` names the active tab, and is "" when the app+// is shut. An empty list with a window is an empty tab; without one it is a closed app — different screens.+bool cable_client_has_window(void);// ── WHAT THE DIAL SAYS ──────────────────────────────────────────────────────────────────────────────// Message CONSTRUCTION stays in cable_client.c even for messages whose logic lives elsewhere: voice.cdiff --git a/devices/harness-device/firmware/main/ui/touch.c b/devices/harness-device/firmware/main/ui/touch.cindex c69668a4c..adacc1795 100644--- a/devices/harness-device/firmware/main/ui/touch.c+++ b/devices/harness-device/firmware/main/ui/touch.c@@ -423,7 +423,7 @@ static void touch_read(lv_indev_t *indev, lv_indev_data_t *data)if (pressed && !nprev) {// Not on the reader: notifications aren't openable there, and swallowing the top band would break// scrolling from the top of the text. The reader owns its whole surface for vertical scroll.- // Not under the switcher either: it covers the whole face, and its top rows are inside this+ // Not under the TABS picker either: it covers the whole face, and its top rows are inside this// band — captured, they would be untappable in exactly the list you opened to tap.//// A chooser wheel is the same shape of thing and was the same bug: its close X sits at the@@ -441,14 +441,14 @@ static void touch_read(lv_indev_t *indev, lv_indev_data_t *data)int d = ndyl - ndy0;ESP_LOGI(TAG, "band: released d=%+d → %s", d,ui_notif_is_open() ? (d < -SWIPE_MIN_PX ? "close drawer" : "nothing")- : (d > SWIPE_MIN_PX ? "agent list" : "nothing"));+ : (d > SWIPE_MIN_PX ? "open drawer" : "nothing"));if (ui_notif_is_open()) { if (d < -SWIPE_MIN_PX) ui_notif_swipe_up(); } // up → close (only if list at top)- // Pull down from the top → the AGENT LIST (owner, 2026-09-15: "vuốt xuống hiển thị danh- // sách agent như cũ"). The notifications are the bell's alone now: the bell is a button,- // and a press that starts ON it is handed to LVGL rather than captured by this band — see- // the capture test above — so a tap on the bell opens the drawer and a tap anywhere else- // in the band does nothing.- else if (d > SWIPE_MIN_PX) ui_switch_open();+ // Pull down from the top → the NOTIFICATION DRAWER. It had this gesture first; the agent+ // switcher took it on 2026-09-15 and went away on 2026-09-17 with the fleet-wide list it+ // listed (owner: "bỏ luôn cái vụ pull down hiển thị danh sách agent … pull down => show+ // notification list"). The bell keeps its tap: a press that starts ON it is handed to LVGL+ // rather than captured by this band — see the capture test above — so both roads lead here.+ else if (d > SWIPE_MIN_PX) ui_notif_open();s_band_drag = false; ncap = true;}nprev = pressed;@@ -461,7 +461,7 @@ static void touch_read(lv_indev_t *indev, lv_indev_data_t *data)// Swipes + tap-to-stop-voice. Skip while swallowing a consumed gesture (the wake tap) so the// release of that gesture isn't misread as a fresh tap.- // ...and not under the agent picker, whose rows are LVGL's to dispatch: swipe_track would read a row+ // ...and not under the TABS picker, whose rows are LVGL's to dispatch: swipe_track would read a row// tap as the tap that opens the detail reader, and a scroll of the list as a carousel swipe, both// happening to the tile UNDERNEATH the overlay.if (!display_is_asleep() && !s_swallow_until_release && !ui_switch_is_open())diff --git a/devices/harness-device/firmware/main/ui/ui_screens.c b/devices/harness-device/firmware/main/ui/ui_screens.cindex 03a03e843..3e9d46655 100644--- a/devices/harness-device/firmware/main/ui/ui_screens.c+++ b/devices/harness-device/firmware/main/ui/ui_screens.c@@ -270,8 +270,6 @@ static lv_obj_t *s_ov_loop_ico; // the repeat-arrows image (recoloured, nstatic lv_obj_t *s_ov_goal_lbl, *s_ov_loop_lbl;static bool s_ov_ready; // last value overview_actions_apply() computed, for overview_mod_apply()static bool s_overview_loading; // true = agents not loaded yet → show s_overview_spin, hide the count-// Agent to focus once a machine switched from a notification tap finishes loading ("" = land on Overview).-static char s_notif_focus[48];static volatile bool s_machine_landing_pending; // a machine was just selected → land (drop spinner + focus agent 1) once its NEW list is built// Which guide the Overview is standing in for, if any. One enum rather than a bool per state: they are// mutually exclusive, and a second bool is how a screen ends up claiming to be two things at once.@@ -425,7 +423,7 @@ static void update_content_window(void); // (re)materialize the active-tile±winstatic void carousel_scroll_apply(void); // let the strip scroll, or not on a ring of one (defined below)static void rebuild_settings_tile(void); // (re)build the trailing settings tile at the last columnstatic void rebuild_machines_tile(void); // (re)build the Machines carousel tile (ring 1)-static void no_agents_apply(void); // the empty state's two sentences: not connected, or no harnesses yet+static void no_agents_apply(void); // the empty state's three sentences: no app, no harnesses, empty tabstatic const lv_image_dsc_t *engine_mark(const char *engine, bool *recolor); // the engine's product mark (defined with the tiles)static void clear_removed_project_transients_locked(const char *project_id, bool voice_aborted);static void settings_vlang_tap(lv_event_t *e); // toggle voice language (defined below)@@ -476,37 +474,24 @@ static void reader_close(lv_event_t *e); // swipe-down at top → back to projecstatic void reader_close_tap(lv_event_t *e); // the reader's X pill (defined below)static void voice_overlay_set(bool on); // voice: dark overlay + free/restore tile content (RAM headroom)static void notif_pill_tap(lv_event_t *e); // the bell → open the drawer (defined below)-static void switch_close(void); // close the picker without picking (defined below)-// ---- agent switcher -----// A picker over the MOST RECENT agents, opened by PULLING DOWN from the top. Swiping the carousel is the-// only other way across, and it is one tile at a time: with a few dozen agents, reaching the one you want-// means passing every one you don't.+// ---- agent switcher: gone ----+// There used to be a picker over EVERY agent on every machine, opened by pulling down from the top. It+// existed because the carousel was a walk of one tile at a time through a few dozen agents, and it was+// the reason the dial had to hold the whole fleet — "the only place a distant agent can be reached+// without swiping past everything in between". The dial now holds the window's active tab and nothing+// else (≤ 9 tiles: every agent is at most four swipes away) and the TABS picker below reaches the rest.+// The pull-down went back to the notification drawer, which had it first (owner, 2026-09-17).//-// It TOOK the pull-down from the notification drawer, and the drawer moved to a tap on the bell. The two-// had been fighting for the same band at the top of the face: whichever control sat there was inside the-// drawer's gesture, and a bell that only needs a tap has no business owning a whole edge of a round screen-// while the thing you reach for constantly needs a button.-// THE WHOLE LIST, not a recent-N slice. It was ten while the carousel held one machine's agents and ten-// was most of them; now that it holds every machine's, a fixed slice would hide whole machines behind-// whichever one happened to sort first — and the picker is the only place a distant agent can be reached-// without swiping past everything in between.-#define SWITCH_LIST_MAX MAX_PROJECTS-static lv_obj_t *s_switch_screen; // full-screen overlay on the top layer, hidden by default// The window's swarms, as the daemon last relayed them, and the swarm picker that lists them. The list// arrives whole (`swarms`), so this is a straight copy; the selected id is what every tile's swarm line// draws. Count 0 = no window, and the line is hidden.static EXT_RAM_BSS_ATTR cable_swarm_t s_swarms[SWARMS_MAX];static int s_swarm_count;static char s_swarm_selected[SWARM_ID_MAX];-static lv_obj_t *s_swarm_screen, *s_swarm_list; // the picker: same shape as the agent switcher+static lv_obj_t *s_swarm_screen, *s_swarm_list; // the picker: a full-screen list over the facestatic void swarm_picker_close(void);static void swarm_picker_rebuild(void);-static lv_obj_t *s_switch_list; // the scrollable column of rows inside it-// The ids currently drawn, indexed by the row's user_data. Fixed storage rather than a strdup per row:-// the array's life IS the picker's, and rows are rebuilt on every open. In PSRAM: at the full list size-// this is several KB that has no business sitting in internal .bss.-static EXT_RAM_BSS_ATTR char s_switch_ids[SWITCH_LIST_MAX][48];typedef struct {@@ -516,7 +501,7 @@ typedef struct {char engine[12]; // MODEL: claude|codex|cursor|opencode|pi|hermes|commandcode|devin; empty hides the mark// WHICH MACHINE THIS AGENT LIVES ON. The carousel is no longer one machine's: it holds every agent on// every machine at once, in the same order the desktop app's rail reads them. `machine_id` is what a- // machine row uses to find its first agent to land on; `machine` is the name the switcher draws.+ // machine row uses to find its first agent to land on; `machine` is the name the tile draws.char machine_id[48];char machine[NAME_MAX];char mode[8]; // MODEL: per-agent autonomy for voice turns — "plan" | "" (empty = auto/bypass)@@ -640,23 +625,14 @@ static int s_ring; // which ring the strip is on#define MACHINES_TILE 0static void resize_spacer(void) { if (s_carousel_spacer) lv_obj_set_width(s_carousel_spacer, CAROUSEL_M * carousel_w()); }-// How many agents the CAROUSEL walks, which is not how many the dial knows.-//-// The daemon builds the ring around the window's open tiles; an agent sitting between two of them in-// list order is off neither edge, so a thumb never reaches it. It is still sent, and still counted on-// the overview and listed in the pull-down switcher — leaving it out entirely is what made the dial-// announce "5 agents" to someone who had eleven. Those agents come LAST in the pushed list, so a single-// count splits it.-//-// 0 means "all of them": the daemon that predates the field says nothing, and so does one with nothing-// to leave out.-static int s_ring_agents;-static int ring_agents(void)-{- if (s_ring_agents <= 0 || s_ring_agents > s_proj_count) return s_proj_count;- return s_ring_agents;-}-static bool agent_on_ring(int i) { return i >= 0 && i < ring_agents(); }+// How many agents the carousel walks: every one the dial holds. The daemon sends the window's active tab+// and nothing else, so there is no longer a "known but not walked" tail — the fleet reaches this screen as+// a number (`s_fleet_total`, the overview's) and as the name on a notification.+static int ring_agents(void) { return s_proj_count; }+static bool agent_listed(int i) { return i >= 0 && i < s_proj_count; }+// The fleet the list was cut from — `agents.end.total` and whether `agents.end.tab` named a tab.+static int s_fleet_total;+static bool s_has_window;static int ring_len(void) { return s_ring == RING_AGENTS ? (ring_agents() > 0 ? ring_agents() : 1) : 1; }static int ring_agents_end(void) { return s_ring == RING_AGENTS ? ring_len() : 0; } // first ring AFTER the agents (0 elsewhere: none)// The one-page rings. Naming one switches the strip to it — see the note above.@@ -739,7 +715,7 @@ static void apply_active_from_col(void)* Say where the dial is looking, on purpose.** The muted path above is for the carousel settling on its own; this is for the moves a person MAKES- * through something other than a swipe — picking from the switcher, tapping a notification. Those go+ * through something other than a swipe — tapping a notification. Those go* through code, so they are muted like any rebuild, and they have to say so explicitly. Nothing else may* call this: the whole fix is that a report means "a person did this".*@@ -842,7 +818,7 @@ static lv_obj_t *make_spinner(lv_obj_t *parent, int size)* The close control every full-face screen wears: a 60x32 pill, white at 10%, with a white x.** ONE definition on purpose. It started as the notification drawer's header and is now also on the- * chooser wheels and the agent switcher — four screens that cover everything else and are left the same+ * chooser wheels and the TABS picker — four screens that cover everything else and are left the same* way. Four copies of the same eight style calls is how the shape drifts on one of them.** `y` is the offset from the parent's TOP, and callers pass it because it is not always 16 on screen: a@@ -2363,9 +2339,9 @@ void ui_init(void)s_notif_pill = lv_obj_create(lv_layer_top());lv_obj_remove_style_all(s_notif_pill);lv_obj_clear_flag(s_notif_pill, LV_OBJ_FLAG_SCROLLABLE);- // THE BELL IS A BUTTON NOW. It used to be a read-only badge and the drawer opened by pulling down from- // the top; the pull-down became the agent switcher, which is reached far more often than a list of- // finished turns, so the drawer moved onto the badge that was already announcing it.+ // THE BELL IS A BUTTON. It used to be a read-only badge with the drawer on the pull-down alone; while+ // the pull-down belonged to the agent switcher (2026-09-15 → 09-17) the drawer moved onto the badge,+ // and now that the pull-down is the drawer's again both stay: a tap here, a pull anywhere in the band.lv_obj_add_flag(s_notif_pill, LV_OBJ_FLAG_CLICKABLE);lv_obj_add_event_cb(s_notif_pill, notif_pill_tap, LV_EVENT_CLICKED, NULL);lv_obj_set_size(s_notif_pill, LV_SIZE_CONTENT, LV_SIZE_CONTENT);@@ -2374,7 +2350,7 @@ void ui_init(void)lv_obj_set_style_radius(s_notif_pill, LV_RADIUS_CIRCLE, 0);lv_obj_set_style_pad_hor(s_notif_pill, 13, 0);lv_obj_set_style_pad_ver(s_notif_pill, 4, 0);- lv_obj_align(s_notif_pill, LV_ALIGN_TOP_MID, 0, 22); // clear of the pull-down band it no longer owns+ lv_obj_align(s_notif_pill, LV_ALIGN_TOP_MID, 0, 22);lv_obj_set_style_bg_opa(s_notif_pill, LV_OPA_80, LV_STATE_PRESSED); // it presses now, so it says solv_obj_set_flex_flow(s_notif_pill, LV_FLEX_FLOW_ROW);lv_obj_set_flex_align(s_notif_pill, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER);@@ -2703,7 +2679,6 @@ void ui_land_after_reload(void)s_overview_loading = false; // list arrived → overview shows the real count (drops the spinner)rebuild_overview_tile();if (!land) {- s_notif_focus[0] = '\0';update_content_window();rebuild_page_dots();display_unlock();@@ -2711,30 +2686,13 @@ void ui_land_after_reload(void)}// ui_enter_machine_loading / ui_enter_boot_loading already centered the carousel at ~CAROUSEL_M/2, so this// slides (staying centered) to the Overview tile (ring 0) — the machine's home (name + agent count + Voice/Goal).- // Exception: a notification tap that switched machines is asking for ONE agent — land on that tile instead- // (falling back to the Overview if it's gone from the new list).- int target = ring_overview();- char detail[48] = "";- if (s_notif_focus[0]) {- int ni = find_proj(s_notif_focus);- snprintf(detail, sizeof detail, "%s", s_notif_focus);- s_notif_focus[0] = '\0';- if (ni >= 0) { target = ring_of_agent(ni); s_active_idx = ni; }- }- carousel_goto(col_for_ring_near(carousel_col(), target), LV_ANIM_ON);+ // A notification tap no longer lands here: it sends `open` and holds its focus for the list the window+ // pushes back (ui_apply_pending_focus), whichever machine the agent is on.+ carousel_goto(col_for_ring_near(carousel_col(), ring_overview()), LV_ANIM_ON);apply_active_from_col();update_content_window();rebuild_page_dots();display_unlock();- // A notification whose agent lives on ANOTHER machine lands here instead, once that machine's list has- // arrived. Finish the same way the direct tap does — otherwise the same gesture would take you to two- // different places depending on which machine the notification came from. Called outside the lock.- if (detail[0]) {- open_agent_detail(detail);- // Same tap, finished late. Without this the notification that had to wait for another machine's- // list would open nothing in the window, while the one that did not would.- if (s_notif_open_pending) ui_report_active_agent();- }}// Boot landing: the agent list hasn't loaded yet, so DON'T flash the "No agents" empty tile. Park on the@@ -2862,11 +2820,13 @@ static void rebuild_overview_tile(void)lv_obj_clear_flag(s_overview_spin, LV_OBJ_FLAG_HIDDEN);} else {if (s_overview_spin) { lv_obj_del(s_overview_spin); s_overview_spin = NULL; } // stop its timer+ // THE FLEET'S count, not the list's. The dial holds one tab; the number is how many agents the+ // account has across every machine, which is what "N agents" always meant here.char t[24];- snprintf(t, sizeof t, "%d", s_proj_count);+ snprintf(t, sizeof t, "%d", s_fleet_total);lv_label_set_text(s_overview_count_lbl, t);lv_obj_clear_flag(s_overview_count_lbl, LV_OBJ_FLAG_HIDDEN);- if (s_overview_agents_lbl) { lv_label_set_text(s_overview_agents_lbl, s_proj_count == 1 ? "agent" : "agents"); lv_obj_clear_flag(s_overview_agents_lbl, LV_OBJ_FLAG_HIDDEN); }+ if (s_overview_agents_lbl) { lv_label_set_text(s_overview_agents_lbl, s_fleet_total == 1 ? "agent" : "agents"); lv_obj_clear_flag(s_overview_agents_lbl, LV_OBJ_FLAG_HIDDEN); }}if (!s_remote_offline_view) {if (s_overview_offline_hint_lbl) lv_obj_add_flag(s_overview_offline_hint_lbl, LV_OBJ_FLAG_HIDDEN);@@ -4715,7 +4675,7 @@ static void apply_engine_label(proj_t *p)}// THE MACHINE LINE IS GONE from the agent tile (mockup/recap-done.html): the same fact is already on the-// Overview eyebrow and on the switcher's second line. THE HEADER'S HEIGHT IS THE TILE'S LAYOUT: it is a+// Overview eyebrow and in the drawer's rows. THE HEADER'S HEIGHT IS THE TILE'S LAYOUT: it is a// flex child of the tile, so its height is exactly what the "Done" block below it is pushed down by.//// THE TAB LINE (owner, 2026-09-16: the swarm-day layout again, with the concept renamed — the window@@ -5017,6 +4977,92 @@ static void voice_overlay_set(bool on)// Remove a project's tile (its session ended and the tmux pane is gone). Deletes the tile's LVGL// subtree, shifts the model over the hole, re-columns the remaining tiles so the swipe stays// gap-free, rebuilds the trailing settings tile, and re-focuses a valid tile. Safe if id is unknown.++// ── ONE RE-ANCHOR PER RECONCILE, NOT ONE PER AGENT ──────────────────────────────────────────────────+//+// add_proj and ui_project_remove each end with the same tail: re-assert the scroll range, rebuild the+// trailing tiles, re-anchor the carousel under the new ring length, and re-materialise the content+// window. For a single agent arriving or leaving that is right, and it is what keeps the tile under the+// thumb from sliding when N changes.+//+// It is wrong for a WHOLE-LIST rebuild. A cable reconnect empties the list and refills it, so a dial+// holding 78 agents runs that tail 156 times, and each run frees and re-materialises the window because+// growing the ring by one remaps every column. Measured on the dial: ~130ms apiece, ~10s for the+// reconcile, inside the single display_lock that refresh_projects takes. CONFIG_ESP_TASK_WDT_TIMEOUT_S+// is 10 and CONFIG_ESP_TASK_WDT_PANIC is on, so the device did not merely stutter — it rebooted+// mid-reconcile with `reset reason: TASK WATCHDOG` (owner, 2026-09-17).+//+// So a bulk edit sets a flag, the per-agent tails become bookkeeping only, and the tail runs ONCE at the+// end. Capturing the centred page at BEGIN is also more honest than re-capturing it 156 times through+// intermediate ring lengths that were never on screen: the person was looking at one agent the whole+// time, and that is the agent to come back to.+//+// Nested because a caller may reconcile inside a reconcile; the depth counter means only the outermost+// pair paints. Outside a batch every path below behaves exactly as it did before.+static int s_bulk_depth;+static bool s_bulk_dirty; // did anything in this batch actually change the list?+static char s_bulk_keep_id[ID_MAX]; // the agent centred when the batch opened ("" = none)+static bool s_bulk_keep_settings, s_bulk_keep_machines;++// True while a bulk edit is open: the per-agent tails skip their paint and mark the batch dirty instead.+static bool bulk_defer_paint(void)+{+ if (s_bulk_depth <= 0) return false;+ s_bulk_dirty = true;+ return true;+}++// The shared tail. Caller holds the lock. `keep_*` name the page to come back to, captured under the+// ring length that was on screen before the edit.+static void projects_reanchor_locked(bool keep_settings, bool keep_machines, const char *keep_id)+{+ resize_spacer(); // the scroll range follows the agent count+ rebuild_settings_tile();+ rebuild_overview_tile();+ rebuild_page_dots();+ int target_ring;+ if (keep_settings) target_ring = ring_settings();+ else if (keep_machines) target_ring = ring_machines_home();+ else if (s_proj_count == 0) target_ring = ring_of_agent(0); // the "No agents" page+ else {+ // The agent by id, under its NEW index. One that left the list during the batch has no column of+ // its own any more, and the first tile is the only answer that is always valid.+ int ni = (keep_id && keep_id[0]) ? find_proj(keep_id) : -1;+ target_ring = ring_of_agent(agent_listed(ni) ? ni : 0);+ }+ carousel_goto(col_for_ring_near(carousel_col(), target_ring), LV_ANIM_OFF);+ apply_active_from_col();+ update_content_window();+}++void ui_projects_bulk_begin(void)+{+ display_lock();+ if (s_bulk_depth++ == 0) {+ s_bulk_dirty = false;+ s_bulk_keep_id[0] = '\0';+ s_bulk_keep_settings = s_bulk_keep_machines = false;+ if (s_proj_count > 0) {+ int cc_ring = ring_of_col(carousel_col());+ s_bulk_keep_settings = is_settings_ring(cc_ring);+ s_bulk_keep_machines = is_machines_ring(cc_ring);+ if (!s_bulk_keep_settings && !s_bulk_keep_machines && agent_of_ring(cc_ring) >= 0)+ snprintf(s_bulk_keep_id, sizeof s_bulk_keep_id, "%s", s_proj[agent_of_ring(cc_ring)].id);+ }+ }+ display_unlock();+}++void ui_projects_bulk_end(void)+{+ display_lock();+ if (s_bulk_depth > 0 && --s_bulk_depth == 0 && s_bulk_dirty) {+ s_bulk_dirty = false;+ projects_reanchor_locked(s_bulk_keep_settings, s_bulk_keep_machines, s_bulk_keep_id);+ }+ display_unlock();+}+/*** Put the tiles in the order the daemon sent them.*@@ -5033,45 +5079,14 @@ static void voice_overlay_set(bool on)* `ids` may omit agents the dial holds (a caller reconciles removals separately) — those keep their* relative order and follow the ones named here.*/-void ui_project_set_ring_count(int n)+void ui_fleet_set(int total, bool has_window){display_lock();- if (n != s_ring_agents) {- // CAPTURE BY ID FIRST, under the OLD ring length.- //- // `ring_of_col` divides by ring_len(), which this count changes — so reading the centred column- // after the assignment decodes an old position with a new modulo and names a different agent.- // Measured on the dial: a swipe pulled `fa69` into a tile, the window showed `fa69`, and the dial- // sat on `Worldcup` — the first agent, which is where the "kept" lookup fell through to. The two- // screens then disagreed silently, because a re-anchor no longer reports itself (carousel_goto).- //- // ui_project_apply_order has always done it this way; this function was written without noticing- // why.- char keep_id[ID_MAX] = "";- bool keep_settings = false, keep_machines = false;- if (s_proj_count > 0) {- int cc_ring = ring_of_col(carousel_col());- keep_settings = is_settings_ring(cc_ring);- keep_machines = is_machines_ring(cc_ring);- if (!keep_settings && !keep_machines && agent_of_ring(cc_ring) >= 0)- snprintf(keep_id, sizeof keep_id, "%s", s_proj[agent_of_ring(cc_ring)].id);- }-- s_ring_agents = n;-- if (s_proj_count > 0) {- // Back to the SAME agent under the new length. One that has left the ring — it is on neither- // side of the desk now — has no column to sit at, and the first tile is the only answer that- // is always valid.- int kept = keep_id[0] ? find_proj(keep_id) : -1;- int target = keep_settings ? ring_settings()- : keep_machines ? ring_machines_home()- : ring_of_agent(agent_on_ring(kept) ? kept : 0);- carousel_goto(col_for_ring_near(carousel_col(), target), LV_ANIM_OFF);- apply_active_from_col();- update_content_window();- rebuild_page_dots();- }+ if (total != s_fleet_total || has_window != s_has_window) {+ s_fleet_total = total;+ s_has_window = has_window;+ rebuild_overview_tile(); // the number+ no_agents_apply(); // which of the three empty sentences}display_unlock();}@@ -5161,6 +5176,11 @@ void ui_project_remove(const char *project_id)s_proj_count--;memset(&s_proj[s_proj_count], 0, sizeof(proj_t));+ // In a bulk reconcile the paint belongs to ui_projects_bulk_end — see the note above it. The model is+ // already correct here; everything below is the view catching up, and doing that once per removed+ // agent is what walked the display lock past the task watchdog.+ if (bulk_defer_paint()) { display_unlock(); return; }+resize_spacer(); // scroll range shrank by one columnrebuild_settings_tile();rebuild_overview_tile();@@ -5244,10 +5264,18 @@ static int add_proj(const char *id)// this agent is inside the active window, and the whole tile is deleted when it leaves. A far-off agent// therefore holds ZERO LVGL objects; the spacer (resize_spacer) reserves its scroll column so scroll// positions stay absolute. The 64KB pool is bounded at ANY agent count → truly unlimited.- resize_spacer(); // (re)assert the huge fixed scroll range- rebuild_settings_tile();- rebuild_overview_tile();- rebuild_page_dots();++ // Bulk reconcile: hold the paint for ui_projects_bulk_end. The first-agent jump below still runs — it+ // is one carousel_goto with no tile work, and it is what puts the strip in the middle of the huge+ // range rather than at column zero.+ const bool deferred = bulk_defer_paint();++ if (!deferred) {+ resize_spacer(); // (re)assert the huge fixed scroll range+ rebuild_settings_tile();+ rebuild_overview_tile();+ rebuild_page_dots();+ }// First agent → jump scroll to the MIDDLE of the huge range (on agent0) BEFORE windowing, so the window// materializes around where we actually are (not around column 0). During an offline→online reload,// preserve Machine/Settings (or the Overview behind the E2EE screen) when the user left Overview before@@ -5257,10 +5285,11 @@ static int add_proj(const char *id)? (reload_on_settings ? ring_settings() : reload_on_machines ? ring_machines_home() : ring_overview()): ring_of_agent(0);carousel_goto(col_for_ring_near(CAROUSEL_M / 2, tr), LV_ANIM_OFF);- } else {+ } else if (!deferred) {int tr = on_settings ? ring_settings() : on_machines ? ring_machines_home() : (on_agent >= 0 ? ring_of_agent(on_agent) : ring_settings());carousel_goto(col_for_ring_near(carousel_col(), tr), LV_ANIM_OFF);}+ if (deferred) return i;apply_active_from_col();update_content_window(); // materialize the window at the current scroll columnreturn i;@@ -5518,20 +5547,18 @@ void ui_focus_project(const char *project_id)if (!project_id) return;display_lock();int i = find_proj(project_id);- // An agent the carousel does not walk has no column to centre. Picking one from the switcher still- // reports the focus upward, and the window opening it is what puts it on the desk — and the next- // list push then puts it on the ring, where the dial can land on it.+ // An agent the dial does not hold has no column to centre. The window opening it is what puts it on+ // the tab — and the list push that follows is what puts it here, where the dial can land on it.//// SAID OUT LOUD. This drop is the whole of "the window moved and the dial did not", and for as long// as it was silent the only way to tell it from a focus that never arrived was to guess. The daemon- // now pushes the ring before the focus that needs it (cableSession.followApp), so a line here means- // that ordering broke — not that the feature is missing.- if (!agent_on_ring(i)) {+ // pushes the list before the focus that needs it (cableSession.followApp), so a line here means that+ // ordering broke — not that the feature is missing.+ if (!agent_listed(i)) {// Not "ignored" any more: HELD. The list that makes this landable is on its way — it is what put- // the agent on the desk in the first place — and ui_apply_pending_focus() runs the moment it lands.+ // the agent on the tab in the first place — and ui_apply_pending_focus() runs the moment it lands.pending_focus_set(project_id);- ESP_LOGW(TAG, "focus %s: %s yet — held for the next list", project_id,- i < 0 ? "not in the list" : "not on the ring");+ ESP_LOGW(TAG, "focus %s: not in the list yet — held for the next one", project_id);display_unlock();return;}@@ -5683,8 +5710,8 @@ static void notif_badge_apply(void)}}static void notif_ud_free(lv_event_t *e) { free(lv_obj_get_user_data(lv_event_get_target(e))); }-// What a drawer row needs on tap: which agent, and which machine it belongs to (may not be the selected one).-typedef struct { char proj[48]; char machine_id[40]; } notif_ref_t;+// What a drawer row needs on tap: which agent. The daemon routes the `open` to its machine.+typedef struct { char proj[48]; } notif_ref_t;// Remove ONE project's notification from the queue (compact the tail up). Caller holds the lock.static void notif_remove(const char *proj_id){@@ -5696,9 +5723,8 @@ static void notif_remove(const char *proj_id)}}}-// Tap a row → remove ONLY that notification (Model B: the rest are kept), then go to that agent. A-// notification from a machine the device ISN'T rendering (multi-attach background badge) switches machines-// first — its tiles don't exist yet, so the jump is deferred to ui_land_after_reload via s_notif_focus.+// Tap a row → remove ONLY that notification (Model B: the rest are kept), then ask the window to open that+// agent — see notif_row_tap.// Focus an agent AND open its detail reader — where a notification tap should land. Same text source as// the swipe-up gesture (m_full, falling back to m_preview) so the two routes can never disagree about what// "detail" means. Keeps the one exception swipe-up already makes: while the agent is WORKING its tile shows@@ -5727,49 +5753,23 @@ static void notif_row_tap(lv_event_t *e)// report is `open` rather than `focus` — see apply_active_from_col.s_notif_open_pending = true;const notif_ref_t *ref = (const notif_ref_t *)lv_obj_get_user_data(lv_event_get_target(e));- char id[48], machine[40]; // copy before close frees the rows+ char id[48]; // copy before close frees the rowssnprintf(id, sizeof id, "%s", ref ? ref->proj : "");- snprintf(machine, sizeof machine, "%s", ref ? ref->machine_id : "");if (id[0]) notif_remove(id);ui_notif_close();- // EVERY machine's agents share one carousel, so the notified tile is almost always already on it —- // whichever machine sent the notification. Go straight there: switching machines first would land on- // that machine's FIRST agent, which is rarely the one the notification is about.- //- // THE OPEN NAMES THE NOTIFICATION'S AGENT, NOT THE TILE. It used to land the carousel first and then- // report whatever was active. The ring is the window's CURRENT TAB, so an agent open in another tab- // is known but not on the ring: the landing was held for a list that never came, and the report- // named the tile the dial happened to be on — the window then opened the wrong agent (owner,- // 2026-09-15: "bấm noti vào agent Kinh Te, nó không focus qua tab chứa Kinh Te"). Now the id goes- // up as-is; the window finds the tab that holds it (or opens one), pushes the ring, and the held- // landing below lands then.- if (id[0] && ui_project_known(id)) {+ // THE OPEN NAMES THE NOTIFICATION'S AGENT, whether or not the dial holds it. The dial has the window's+ // CURRENT TAB, and the agent that just finished is as likely as not on another one: the window finds+ // the tab that holds it (or opens one), pushes that tab's list, and the landing held below lands then+ // (owner, 2026-09-15: "bấm noti vào agent Kinh Te, nó không focus qua tab chứa Kinh Te"). It used to+ // switch MACHINES first for an agent it did not hold, which landed on that machine's first agent —+ // rarely the one the notification was about.+ if (id[0]) {s_notif_open_pending = false;cable_client_send_open(id);- open_agent_detail(id);+ open_agent_detail(id); // held until the list arrives when the agent is off this tabreturn;}-- // It is not on the carousel yet — a notification that arrived ahead of the list it belongs to. Select- // its machine and defer the focus to ui_land_after_reload, which is the one path that runs once the- // list is rebuilt. The landing flag is set HERE rather than by machine_switch_to: choosing a machine- // no longer waits for anything, and this is the only case left that does.- if (machine[0] && strcmp(machine, s_selected_machine) != 0) {- display_lock();- int fi = -1;- for (int k = 0; k < s_machine_count; k++) if (strcmp(s_machines[k].id, machine) == 0) { fi = k; break; }- if (fi >= 0) {- snprintf(s_notif_focus, sizeof s_notif_focus, "%s", id); // focus this agent once its list arrives- s_machine_landing_pending = true;- machine_switch_to(fi);- display_unlock();- return;- }- display_unlock(); // machine no longer in the picker (deleted/unbound) → best-effort local focus below- }-- if (id[0]) open_agent_detail(id); // straight to the detail screen, not just the tileui_report_active_agent();}static void notif_bg_tap(lv_event_t *e) { (void)e; ui_notif_close(); } // tap empty area → close@@ -5787,7 +5787,6 @@ static void notif_rebuild(void)notif_ref_t *ref = ram_psram_alloc(sizeof(notif_ref_t), "notif_row_ref");if (!ref) continue;snprintf(ref->proj, sizeof ref->proj, "%s", n->proj_id);- snprintf(ref->machine_id, sizeof ref->machine_id, "%s", n->machine_id);shown++;// Card (new Figma): a glassy dark rounded rect, COLUMN of [name row] over [recap]. The name row is// a green dot + the green agent name (grows) + a small muted time on the right (iOS-style — the@@ -5874,173 +5873,17 @@ static void notif_rebuild(void)}if (s_notif_empty) set_hidden(s_notif_empty, shown > 0);}-// ---- the agent switcher's picker -----+// ---- the swarm picker's gate ----bool ui_switch_is_open(void){- // Either picker over the face. touch.c asks this to keep the pull-down band and the tap-to-open from- // acting under an open list, and the swarm picker wants exactly that treatment.- return (s_switch_screen && !lv_obj_has_flag(s_switch_screen, LV_OBJ_FLAG_HIDDEN))- || (s_swarm_screen && !lv_obj_has_flag(s_swarm_screen, LV_OBJ_FLAG_HIDDEN));-}--static void switch_close(void)-{- if (s_switch_screen) lv_obj_add_flag(s_switch_screen, LV_OBJ_FLAG_HIDDEN);-}--static void switch_bg_tap(lv_event_t *e) { (void)e; switch_close(); }--// Picking is the same move a swipe makes, and it has to stay that way: ui_focus_project centres the tile,-// and apply_active_from_col is what SENDS the focus down the cable so the desktop window follows. Skipping-// the second would leave the dial looking at one agent and the window at another — the two are one desk.-static void switch_row_tap(lv_event_t *e)-{- // current_target, not target: the row is what carries the index, and a click that landed on one of its- // labels bubbles up with target still pointing at the label.- int idx = (int)(intptr_t)lv_obj_get_user_data(lv_event_get_current_target(e));- if (idx < 0 || idx >= SWITCH_LIST_MAX) return;- char id[48];- snprintf(id, sizeof id, "%s", s_switch_ids[idx]); // copy: closing rebuilds nothing, but a pick might- switch_close();- if (!id[0]) return;- // A PERSON picked this row, so the window is told — as an OPEN, the same as a notification tap (owner,- // 2026-09-15: "chọn agent từ list … cùng rule với noti"): the window lands on the tab that holds the- // agent, the current one first, or opens a tab for it. The id goes up as-is, before the local- // centring below: an agent in another tab is known but not on the ring, so that centring is held- // for the list the window pushes back — and reporting the tile afterwards would name the wrong one.- cable_client_send_open(id);- ui_focus_project(id);- display_lock();- apply_active_from_col();- display_unlock();+ // The TABS picker over the face. touch.c asks this to keep the pull-down band and the tap-to-open from+ // acting under an open list. The name is from the agent switcher this once also covered; that picker+ // is gone (see the note under "agent switcher" above) and this is the one list overlay left.+ return s_swarm_screen && !lv_obj_has_flag(s_swarm_screen, LV_OBJ_FLAG_HIDDEN);}-// Fill the picker from the FIRST tiles in the list.-//-// That is already the order the daemon sends and not an approximation of it. Sorting here would invent a-// second opinion about recency out of data this device does not have, and it would disagree with the list-// the window shows the moment either side reordered. Caller holds the lock.-static void switch_rebuild(void)-{- if (!s_switch_list) return;- lv_obj_clean(s_switch_list);- memset(s_switch_ids, 0, sizeof(s_switch_ids));- int n = s_proj_count < SWITCH_LIST_MAX ? s_proj_count : SWITCH_LIST_MAX;- for (int i = 0; i < n; i++) {- proj_t *p = &s_proj[i];- snprintf(s_switch_ids[i], sizeof(s_switch_ids[i]), "%s", p->id);- // ...and nothing is "here" when the page behind the picker is the Overview or Settings, which name- // no agent. Marking one anyway would point at whichever tile was last centred.- bool here = (i == s_active_idx) && !s_overview_active && !s_settings_active;-- lv_obj_t *row = lv_button_create(s_switch_list);- lv_obj_set_width(row, lv_pct(100));- lv_obj_set_height(row, LV_SIZE_CONTENT);- lv_obj_set_style_bg_color(row, COL_CARD, 0);- lv_obj_set_style_bg_opa(row, here ? LV_OPA_COVER : LV_OPA_60, 0);- lv_obj_set_style_radius(row, 16, 0);- lv_obj_set_style_border_width(row, here ? 1 : 0, 0);- lv_obj_set_style_border_color(row, COL_ACCENT, 0);- lv_obj_set_style_shadow_width(row, 0, 0);- lv_obj_set_style_pad_hor(row, 16, 0);- lv_obj_set_style_pad_ver(row, 10, 0);- lv_obj_set_flex_flow(row, LV_FLEX_FLOW_COLUMN);- lv_obj_set_flex_align(row, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER);- lv_obj_set_style_pad_row(row, 2, 0);- lv_obj_clear_flag(row, LV_OBJ_FLAG_SCROLLABLE);- lv_obj_set_user_data(row, (void *)(intptr_t)i);- lv_obj_add_event_cb(row, switch_row_tap, LV_EVENT_CLICKED, NULL);-- // The agent's name, then the MACHINE it runs on under it. The engine used to be here and no longer- // earns the line: the list now spans every machine, so "which computer is this on" is the one- // question two identically-named agents raise and the engine cannot answer. The engine is still on- // the tile itself, as a product mark. Falls back to the engine for an agent whose machine the- // daemon did not name (an older daemon), so the line is never blank. An agent mid-turn says so in green.-- lv_obj_t *nm = lv_label_create(row);- lv_obj_set_style_text_font(nm, &geist_med_28, 0);- lv_obj_set_style_text_color(nm, p->busy_model ? COL_VOICE : COL_FG, 0);- lv_obj_set_width(nm, lv_pct(100));- lv_obj_set_style_text_align(nm, LV_TEXT_ALIGN_CENTER, 0);- lv_label_set_long_mode(nm, LV_LABEL_LONG_DOT);- lv_label_set_text(nm, p->name[0] ? p->name : "Untitled");- const char *sub = p->machine[0] ? p->machine : p->engine;- if (sub[0]) {- lv_obj_t *en = lv_label_create(row);- lv_obj_set_style_text_font(en, &geist_reg_25, 0);- lv_obj_set_style_text_color(en, COL_MUTED, 0);- lv_obj_set_width(en, lv_pct(100));- lv_obj_set_style_text_align(en, LV_TEXT_ALIGN_CENTER, 0);- lv_label_set_long_mode(en, LV_LABEL_LONG_DOT);- lv_label_set_text(en, sub);- }-- }- if (n == 0) make_label(s_switch_list, "No agents yet", COL_MUTED, &geist_med_28);-}--static void switch_build(void)-{- if (s_switch_screen) return;- s_switch_screen = lv_obj_create(lv_layer_top());- lv_obj_remove_style_all(s_switch_screen);- lv_obj_set_size(s_switch_screen, lv_pct(100), lv_pct(100));- lv_obj_set_pos(s_switch_screen, 0, 0);- lv_obj_set_style_bg_color(s_switch_screen, COL_BG, 0);- lv_obj_set_style_bg_opa(s_switch_screen, LV_OPA_COVER, 0);- lv_obj_add_flag(s_switch_screen, LV_OBJ_FLAG_CLICKABLE); // empty-area tap closes it- lv_obj_add_event_cb(s_switch_screen, switch_bg_tap, LV_EVENT_CLICKED, NULL);- lv_obj_add_flag(s_switch_screen, LV_OBJ_FLAG_HIDDEN);-- // The same close pill the other full-face screens wear. Tapping the empty backdrop still closes it —- // that was once the ONLY way out, on the reasoning that a 466px circle always leaves ~40px of- // backdrop down each side. True, but it is a target you have to know about; every other screen that- // covers the face is left by an X, and guessing which one this is costs more than the pixels.- //- // The rows stay CENTRED rather than pinned below it: the pill is FLOATING, so it takes no space in- // the layout and a short list still sits in the middle of the face. Height is content-driven with a- // ceiling, so a full list clamps and scrolls.- make_close_pill(s_switch_screen, switch_bg_tap, 16);- s_switch_list = lv_obj_create(s_switch_screen);- lv_obj_remove_style_all(s_switch_list);- lv_obj_set_width(s_switch_list, SAFE_CONTENT_W);- lv_obj_set_height(s_switch_list, LV_SIZE_CONTENT);- lv_obj_set_style_max_height(s_switch_list, 360, 0); // 360 keeps the end rows inside the round face- lv_obj_center(s_switch_list);- lv_obj_set_flex_flow(s_switch_list, LV_FLEX_FLOW_COLUMN);- lv_obj_set_flex_align(s_switch_list, LV_FLEX_ALIGN_START, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER);- lv_obj_set_style_pad_row(s_switch_list, 8, 0);- lv_obj_set_scroll_dir(s_switch_list, LV_DIR_VER);- lv_obj_set_scrollbar_mode(s_switch_list, LV_SCROLLBAR_MODE_OFF);-}--// The bell's tap. A plain wrapper so the pill can stay a bare object rather than growing a second meaning:-// everything about WHEN the drawer may open already lives in ui_notif_open.static void notif_pill_tap(lv_event_t *e) { (void)e; ui_notif_open(); }-void ui_switch_open(void)-{- // From ANY carousel page, not only an agent tile: the gesture it inherited opened the drawer on the- // Overview and on Settings too, and a list of recent agents is if anything more useful from the home- // page than from one of the agents themselves.- if (ui_voice_is_active() || display_is_asleep() || lv_screen_active() != scr_projects) return;- display_lock();- switch_build();- switch_rebuild();- lv_obj_clear_flag(s_switch_screen, LV_OBJ_FLAG_HIDDEN);- // NOT lv_obj_move_foreground: the dim is a black overlay on this same layer, so raising the switcher- // past it renders the picker at full brightness on a screen the user dimmed right down — it looked- // like the one screen someone forgot to dim. `switch_build()` lands here after s_dim exists, so this- // is also what puts it below the dim in the first place, not just what keeps it there.- overlay_raise(s_switch_screen);-- lv_obj_scroll_to_y(s_switch_list, 0, LV_ANIM_OFF);- display_unlock();- ESP_LOGI(TAG, "agent switcher: %d agents", s_proj_count < SWITCH_LIST_MAX ? s_proj_count : SWITCH_LIST_MAX);--}-// ---- Swarms ----------------------------------------------------------------------------------------//// A swarm is one of the window's tabs: a named group of agents on one grid. The carousel already walks@@ -6075,6 +5918,7 @@ void ui_swarms_replace(const cable_swarm_t *rows, int count, const char *selectes_swarm_count = count;snprintf(s_swarm_selected, sizeof(s_swarm_selected), "%s", selected ? selected : "");swarm_lines_repaint();+ no_agents_apply(); // the empty tab's eyebrow is the tab's nameif (s_swarm_screen && !lv_obj_has_flag(s_swarm_screen, LV_OBJ_FLAG_HIDDEN)) swarm_picker_rebuild();display_unlock();ESP_LOGI(TAG, "swarms: %d (on %s)", count, s_swarm_selected[0] ? s_swarm_selected : "-");@@ -6100,7 +5944,7 @@ static void swarm_row_tap(lv_event_t *e)}// The rows: the swarm's name, and how many agents it holds under it. The selected one is outlined the-// way the agent switcher outlines "here". Caller holds the lock.+// way a tile outlines "here". Caller holds the lock.static void swarm_picker_rebuild(void){if (!s_swarm_list) return;@@ -6192,7 +6036,9 @@ static void swarm_line_tap(lv_event_t *e)swarm_picker_build();swarm_picker_rebuild();lv_obj_clear_flag(s_swarm_screen, LV_OBJ_FLAG_HIDDEN);- overlay_raise(s_swarm_screen); // below the dim, like the switcher — see ui_switch_open+ // NOT lv_obj_move_foreground: the dim is a black overlay on this same layer, so raising the picker+ // past it renders the list at full brightness on a screen the user dimmed right down.+ overlay_raise(s_swarm_screen);lv_obj_scroll_to_y(s_swarm_list, 0, LV_ANIM_OFF);display_unlock();cable_client_list_swarms(); // and ask for a fresh list while it is open@@ -6209,7 +6055,9 @@ bool ui_notif_pill_hit(uint16_t x, uint16_t y)void ui_notif_open(void){if (!s_notif_drawer || s_notif_open) return;- if (lv_screen_active() != scr_projects || s_settings_active || s_machines_active) return; // from a project tile OR the Overview home (badge shows on both)+ // From ANY carousel page — a tile, the Overview, Settings: the pull-down is the same gesture on all+ // of them, and a list of what finished is no less useful from the home page.+ if (lv_screen_active() != scr_projects || ui_voice_is_active()) return;display_lock();notif_rebuild(); // notifications stay green (unread) until tapped away — viewing does NOT dim thems_notif_open = true;@@ -6246,22 +6094,23 @@ void ui_notif_swipe_up(void)}// Push a done notification for project i (dedupe by id → refresh + move to top). Caller holds the lock.-static void notif_push(const char *proj_id, int i)+// `i` is the agent's tile, or -1 when the dial does not hold it — then the frame's `name`, `machine` and+// `recap` are all the row has, and they are enough.+static void notif_push(const char *proj_id, int i, const char *name, const char *machine, const char *recap){notif_t rec = {0};snprintf(rec.proj_id, sizeof rec.proj_id, "%s", proj_id);- const char *nm = s_proj[i].name[0] ? s_proj[i].name : proj_id; // MODEL, not the widget- snprintf(rec.name, sizeof rec.name, "%s", nm ? nm : proj_id);- const char *sm = s_proj[i].m_preview ? s_proj[i].m_preview : "";+ const char *nm = (i >= 0 && s_proj[i].name[0]) ? s_proj[i].name : (name && name[0]) ? name : proj_id; // MODEL, not the widget+ snprintf(rec.name, sizeof rec.name, "%s", nm);+ const char *sm = (i >= 0 && s_proj[i].m_preview) ? s_proj[i].m_preview : (recap ? recap : "");snprintf(rec.summary, sizeof rec.summary, "%s", sm);- // Tag which machine this notification belongs to (the machine selected right now). Store the NAME so the- // notif keeps it even if the machine is later renamed/removed.- if (s_selected_machine[0]) {- const char *fn = s_selected_machine;- for (int k = 0; k < s_machine_count; k++)- if (strcmp(s_machines[k].id, s_selected_machine) == 0) { fn = s_machines[k].name[0] ? s_machines[k].name : s_machines[k].id; break; }- snprintf(rec.machine, sizeof rec.machine, "%s", fn);- snprintf(rec.machine_id, sizeof rec.machine_id, "%s", s_selected_machine);+ // Which machine it lives on — the tile's own, else the frame's name. Stored as a NAME so the row keeps+ // it if the machine is later renamed or removed.+ if (i >= 0 && s_proj[i].machine[0]) {+ snprintf(rec.machine, sizeof rec.machine, "%s", s_proj[i].machine);+ snprintf(rec.machine_id, sizeof rec.machine_id, "%s", s_proj[i].machine_id);+ } else if (machine && machine[0]) {+ snprintf(rec.machine, sizeof rec.machine, "%s", machine);}rec.ms = lv_tick_get();rec.unread = true; rec.used = true;@@ -6281,26 +6130,26 @@ static void notif_push(const char *proj_id, int i)// on what finished.// Runs on the WS task under display_lock (like ui_project_emit); display_lock is recursive, so calling// ui_notif_open (which locks) from here is safe.-void ui_notify_task_done(const char *project_id)+void ui_notify_task_done(const char *project_id, const char *name, const char *machine, const char *recap){if (!project_id || !project_id[0]) return;display_lock();+ // -1 is a normal answer now, not a miss: the dial holds one tab, and a turn can finish on any of them.+ // An agent off this tab is never "being viewed", so it always gets its row.int i = find_proj(project_id);- if (i >= 0) {- bool viewing = !display_is_asleep() && !s_settings_active && !s_machines_active && !s_overview_active && !s_notif_open && s_active_idx == i;- if (!viewing) {- bool was_asleep = display_is_asleep();- notif_push(project_id, i); // record it so the drawer/badge has the entry- if (was_asleep) {- // Woke from an off screen → open the notification list directly. ui_notif_open only opens- // over the projects carousel (not settings), so land there first.- display_wake();- if (lv_screen_active() != scr_projects) lv_screen_load(scr_projects);- ui_notif_open();- } else {- // Awake on a different agent → just badge, don't yank the user off what they're viewing.- notif_badge_apply();- }+ bool viewing = i >= 0 && !display_is_asleep() && !s_settings_active && !s_machines_active && !s_overview_active && !s_notif_open && s_active_idx == i;+ if (!viewing) {+ bool was_asleep = display_is_asleep();+ notif_push(project_id, i, name, machine, recap); // record it so the drawer/badge has the entry+ if (was_asleep) {+ // Woke from an off screen → open the notification list directly. ui_notif_open only opens+ // over the projects carousel, so land there first.+ display_wake();+ if (lv_screen_active() != scr_projects) lv_screen_load(scr_projects);+ ui_notif_open();+ } else {+ // Awake on a different agent → just badge, don't yank the user off what they're viewing.+ notif_badge_apply();}}display_unlock();@@ -6977,7 +6826,7 @@ typedef struct {static EXT_RAM_BSS_ATTR struct {bool active;char request_id[80];- char session_id[64];+ char who[64]; // the asker's name, from the frame — it may be on a tab the dial does not holdchar project[48];qitem_t q[Q_MAX];char answer[Q_MAX][256]; // chosen label(s) or transcript, per question@@ -7097,11 +6946,14 @@ static void q_render(void)// để user có thêm context ra quyết định"). The same question — "switch to the cheaper model?" —// means different things from a scratch agent and from the one mid-deploy. Muted, small, one line:// an eyebrow, not a second title.+ //+ // From the FRAME, not from the tile: the dial holds one tab, and the question may come from an agent+ // on another. The tile's name is the fallback for a daemon that sent none.{- int ai = find_proj(s_q.project);- if (ai >= 0 && s_proj[ai].name[0]) {+ int ai = s_q.who[0] ? -1 : find_proj(s_q.project);+ if (s_q.who[0] || (ai >= 0 && s_proj[ai].name[0])) {static char who[64];- utf8_filter(s_proj[ai].name, who, sizeof(who));+ utf8_filter(s_q.who[0] ? s_q.who : s_proj[ai].name, who, sizeof(who));lv_obj_t *l = lv_label_create(scr_question);lv_label_set_long_mode(l, LV_LABEL_LONG_DOT);lv_obj_set_width(l, lv_pct(100));@@ -7248,7 +7100,7 @@ static void q_done_tap(lv_event_t *e)display_unlock();}-void ui_question_show(const char *project_id, const char *session_id, const char *request_id, const struct cJSON *questions)+void ui_question_show(const char *project_id, const char *agent_name, const char *request_id, const struct cJSON *questions){if (!request_id || !questions) return;display_lock();@@ -7257,7 +7109,7 @@ void ui_question_show(const char *project_id, const char *session_id, const charmemset(&s_q, 0, sizeof(s_q));snprintf(s_q.request_id, sizeof(s_q.request_id), "%s", request_id);snprintf(s_q.project, sizeof(s_q.project), "%s", project_id ? project_id : "");- snprintf(s_q.session_id, sizeof(s_q.session_id), "%s", session_id ? session_id : "");+ snprintf(s_q.who, sizeof(s_q.who), "%s", agent_name ? agent_name : "");int qi = 0;const cJSON *qn;@@ -7595,27 +7447,42 @@ static void no_agents_apply(void)name = s_machines[i].name[0] ? s_machines[i].name : s_machines[i].id;break;}- // ONE empty state, because on this firmware there is one way to get an agent: start it on the computer- // at the other end of the cable. This used to fork on a `remote` flag and tell a LOCAL machine- // "Long-press to create one" — a gesture whose handler left with app_main's polling loop. touch.c still- // detected the hold and set its flag, nothing ever drained it, and the line sat on screen promising- // something no code did. The fork itself was already unreachable: the only writer of `remote` that- // still runs sets it to false, since both backend snapshot paths lost their callers with the socket.- // TWO HONEST STATES, one screen each (mockup/empty-state.html, A and B′). The daemon is either on the- // cable or it is not; when it is not, the machine's name, the action and the marks are all about a- // computer that is not talking to us yet, and the one thing to do is open the app there. When it is,- // the tile names the machine and the action.+ // THREE HONEST STATES, one screen each (mockup/empty-state.html, A and B′, plus the tab case). The+ // daemon is on the cable or it is not; when it is, the window is open or it is not; when it is, this+ // tab has panes or it does not. Each is a different thing to do next, and the screen says that one+ // thing in the app's own words.+ //+ // A: not connected — nothing is talking to us; the only move is to run the app on the computer.+ // Also the shape for "connected, no window": the daemon is up but the app is shut, and the one+ // thing to do is the same. The badge at the top says which of the two it is.+ // B′: connected, window open, no agents ANYWHERE — name the machine, offer Cmd N.+ // T: connected, window open, agents elsewhere, this tab empty — the tab's name, Cmd N, and a nudge+ // that the other tabs are a tap away (the eyebrow opens the TABS picker on the tiles; here it is+ // the hint's job).lv_obj_t *pill = s_na_cmd_lbl ? lv_obj_get_parent(s_na_cmd_lbl) : NULL; // the words' label → the pill- if (!s_connected) {+ if (!s_connected || !s_has_window) {set_hidden(s_na_eyebrow, true); // absent, not "Machine": the row is for a nameif (pill) set_hidden(pill, true);if (s_na_marks) set_hidden(s_na_marks, true);lv_label_set_text(s_na_title, "Run OpenHarness\non your computer");- lv_label_set_text(s_no_agents_hint_lbl, "The dial follows the app.\nIt connects on its own.");+ lv_label_set_text(s_no_agents_hint_lbl, s_connected+ ? "The dial follows the app.\nIt shows what the app shows."+ : "The dial follows the app.\nIt connects on its own.");return;}set_hidden(s_na_eyebrow, false);if (pill) set_hidden(pill, false);+ if (s_fleet_total > 0) {+ // Agents exist, none on this tab. The eyebrow names the tab the way a tile's line does.+ if (s_na_marks) set_hidden(s_na_marks, true);+ const char *tab = NULL;+ for (int i = 0; i < s_swarm_count; i++)+ if (strcmp(s_swarms[i].id, s_swarm_selected) == 0) { tab = s_swarms[i].name[0] ? s_swarms[i].name : NULL; break; }+ lv_label_set_text(s_na_eyebrow, tab ? tab : "This tab");+ lv_label_set_text(s_na_title, "Nothing on this tab");+ lv_label_set_text(s_no_agents_hint_lbl, "Create one in OpenHarness,\nor pick another tab in the app.");+ return;+ }if (s_na_marks) set_hidden(s_na_marks, false);// Name as-is, exactly like the Overview eyebrow: the device never upper-cases anything.lv_label_set_text(s_na_eyebrow, name ? name : "");@@ -8074,7 +7941,7 @@ void ui_apply_pending_focus(void)snprintf(want, sizeof(want), "%s", s_pending_focus);const bool expired = want[0] && lv_tick_elaps(s_pending_focus_ms) > PENDING_FOCUS_MS;if (expired) {- ESP_LOGW(TAG, "focus %s: still not on the ring after %dms — dropped", want, (int)PENDING_FOCUS_MS);+ ESP_LOGW(TAG, "focus %s: still not in the list after %dms — dropped", want, (int)PENDING_FOCUS_MS);pending_focus_clear();}display_unlock();@@ -8419,7 +8286,7 @@ void ui_voice_stop(void)// ── what covers the face, as one line whenever it changes ───────────────────────────────────────────// A press eaten by an invisible clickable layer is indistinguishable from dead touch, and the dial has// half a dozen things that can be over a tile: the voice overlay, the dim, the notification drawer, the-// agent switcher, the picker screen, the lock. Rather than a line at every show and hide site (there are+// TABS picker, the picker screen, the lock. Rather than a line at every show and hide site (there are// dozens, on several tasks), this is ONE snapshot, taken on the LVGL task every loop and printed only// when it differs from the last one. Read beside touch.c's press/release lines, it says what the press// landed on.@@ -8451,7 +8318,7 @@ void ui_log_state_if_changed(void)voice_ov ? " +voice-overlay" : "",ui_voice_is_active() ? " +voice-active" : "",s_notif_open ? " +drawer" : "",- ui_switch_is_open() ? " +switcher" : "",+ ui_switch_is_open() ? " +tabs" : "",ui_lock_active() ? " +lock" : "",display_is_asleep() ? " asleep" : "",dimmed ? " dimmed" : "");diff --git a/devices/harness-device/firmware/main/ui/ui_screens.h b/devices/harness-device/firmware/main/ui/ui_screens.hindex 770e3d820..79917a09f 100644--- a/devices/harness-device/firmware/main/ui/ui_screens.h+++ b/devices/harness-device/firmware/main/ui/ui_screens.h@@ -82,7 +82,7 @@ void ui_project_set_name(const char *project_id, const char *name);// Set the engine shown below an agent name. Invalid/empty values leave the label blank.void ui_project_set_engine(const char *project_id, const char *engine);-// Which machine an agent lives on. The carousel spans machines, so this is what the switcher's second+// Which machine an agent lives on. A tab spans machines, so this is what the tile's machine line and// line shows and what a machine row uses to find the first agent to land on.void ui_project_set_machine(const char *project_id, const char *machine_id, const char *machine);@@ -99,6 +99,18 @@ void ui_service_model_picker(void);// Remove a project's tile (session ended / tmux pane gone). No-op if the id isn't shown.void ui_project_remove(const char *project_id);++// Bracket a WHOLE-LIST rebuild (a cable reconnect drops every tile and adds them all back).+//+// Between these two calls the add/remove paths touch the model only: no re-anchor, no window rebuild, no+// trailing-tile rebuild. The view catches up once, at bulk_end, and comes back to whichever page was+// centred when bulk_begin ran. Nested calls are counted, so only the outermost pair paints.+//+// This is not an optimisation to be dropped when convenient. Painting per agent held the display lock for+// about ten seconds on a 78-agent reconcile, which is the task watchdog's timeout with panic enabled, and+// the dial rebooted in the middle of the refresh. See the block comment above the implementation.+void ui_projects_bulk_begin(void);+void ui_projects_bulk_end(void);// Copy the id of the project tile at index i into buf; false if out of range (poll reconcile).bool ui_project_id_at(int i, char *buf, size_t n);// Number of project tiles currently shown (for naming "Project N").@@ -151,18 +163,20 @@ bool ui_action_hit(uint16_t x, uint16_t y);// A resolved single tap, at its PRESS coordinates in screen space. The point decides what it opens:// only a tap landing on the "Done" block opens the detail reader.void ui_tap(int32_t x, int32_t y);-// Notification centre (touch.c drives open/close): open = pull-down from the top edge; close = swipe-up /-// tap. is_open lets the gesture layer route input to the drawer instead of voice/detail.+// Notification centre (touch.c drives open/close): open = pull-down from the top edge, or a tap on the+// bell; close = swipe-up / tap. is_open lets the gesture layer route input to the drawer instead of+// voice/detail. Opens over any carousel page (a tile, the Overview, Settings).void ui_notif_open(void);-// The agent switcher: a picker over the most recent agents, opened by pulling down from the top. It took-// that gesture from the notification drawer, which now opens on a tap of the bell — see ui_screens.c.+// True while the TABS picker covers the face. touch.c keeps the pull-down band and the tap-to-open from+// acting under it. (Named for the agent switcher it once also gated — that picker is gone; see+// ui_screens.c "agent switcher: gone".)bool ui_switch_is_open(void);-void ui_switch_open(void);void ui_notif_close(void);bool ui_notif_is_open(void);// True when a press lands on the bell pill. touch.c asks before capturing the top band, so the one-// button that lives inside that band can be pressed — the drawer opens from the bell and nowhere else.+// button that lives inside that band can be pressed — a tap on the bell reaches LVGL and opens the+// drawer; a pull that starts anywhere else in the band opens it too.bool ui_notif_pill_hit(uint16_t x, uint16_t y);// A swipe-up inside the open drawer → close it, but only if the list is already scrolled to the top// (otherwise the gesture is just scrolling the list).@@ -250,12 +264,13 @@ bool ui_take_agent_reload_req(void);bool ui_peek_agent_reload_req(void); // non-consuming check (a slow per-agent restore bails on a new machine select)// Put the tiles in the order `ids` gives. Without this the carousel keeps the order it FIRST saw agents// in — ui_project_set_name appends — and once that disagrees with the list there is no path back.-// How many of the agents just pushed the CAROUSEL walks; the rest are known but not swiped to (they-// still count on the overview and list in the switcher). 0 = all of them. See ui_screens.c's ring_agents.-void ui_project_set_ring_count(int n);+// What the list just pushed was cut from: how many agents the account has in all (the overview's number —+// the dial holds one tab, never the fleet) and whether a window is open at the far end (an empty list+// with one is an empty tab; without one it is a shut app — see no_agents_apply).+void ui_fleet_set(int total, bool has_window);// Tell the window where the dial is looking, on purpose. ONLY for a move a person made through something-// other than a swipe (the switcher, a notification): those go through code, and code-driven moves are+// other than a swipe (a notification): those go through code, and code-driven moves are// deliberately silent — see carousel_goto in ui_screens.c.void ui_report_active_agent(void);@@ -280,9 +295,10 @@ void ui_cable_toast(const char *msg);// stops capture, restores the previous screen and shows a short non-fatal toast.void ui_voice_quota_status(int remaining_seconds);void ui_voice_quota_exceeded(void);-// A turn finished for this project → wake the screen (if off) and jump to that project's tile. Called-// on the completion beep so the user always lands on the finished project.-void ui_notify_task_done(const char *project_id);+// A turn finished for this agent → record it in the drawer, badge, and wake the screen if it was off.+// `name`, `machine` and `recap` come from the frame: the dial holds one tab, and the agent may be on+// another — the row has nobody else to ask. Any may be NULL; a held tile's own model wins when present.+void ui_notify_task_done(const char *project_id, const char *name, const char *machine, const char *recap);// Append a commander event to a project's tile as a readable text card (keeps the last 2).// kind: "say" | "act" | "ask" | "done" | "error". session_id is the dbSessionId for voice resume.// `recap` (optional, may be NULL): a short headline shown on the tile at a glance; `text` is the@@ -315,7 +331,7 @@ void ui_project_set_agents(const char *project_id, const struct cJSON *agents);// Show the question screen: tap an option row to answer (single/multi-select). Tap-only — there is no// voice answer. `questions` is the cJSON array from the `commander_question` frame; copied out// synchronously, so the caller may free the JSON right after this returns.-void ui_question_show(const char *project_id, const char *session_id, const char *request_id, const struct cJSON *questions);+void ui_question_show(const char *project_id, const char *agent_name, const char *request_id, const struct cJSON *questions);// That question was answered somewhere else (the app, or the pane by hand) — leave the screen instead of// waiting for an answer that can no longer be delivered. No-op unless THIS request is the one on screen.void ui_question_close(const char *project_id, const char *request_id);