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.
Round Dial: Recap at Once, the App's Project Order, and Threads Implementation Plan
How this is worked: by the project's instructions, task by task, each failing test committed before its code.
Goal: The round dial's recap answers at once on a side switch, its projects swipe in the app's A to Z order, and its chat recap skips thread replies while a thread open on Desktop is shown and answered on the dial.
Architecture: All three live in SwarmCards (cli/src/superTabs/cards.ts). (1) The dial's own recap read gets a lane of its own, one at a time, apart from the two background reads (notices, pushes); a recap held for the same chat, or a notice from it, is answered first and refreshed after, and the dial's daemon logs an empty or failed recap once per Lead and reason. (2) leadsOf ranks projects by name, case-insensitively A to Z, ties in server order, and order is that rank. (3) lastAgentMessage takes where to look (the chat's main stream, or one thread); Desktop names the open thread on the Swarm row (threadRoot), which rides the focus to the cards; a face with a thread reads and answers in it.
Tech Stack: TypeScript, Vitest (CLI); Dart, Flutter 3.47.2 (Desktop).
Spec: Task #2300 (Diego's three dial proposals), its brief in conversation 1ef9eace7e5c207a545f1a22.
Global Constraints
- The PR body starts with:
Requested by [email protected] through Harness. - No firmware change. Never publish firmware, run upload scripts or touch the device update manifest.
- Swarm code stays out of
cli/src/core: the focus'sthreadRootis typed in the Swarm's files, not incore/api.ts. - Never run a test that signs this Mac out of the real CLI; Desktop tests use a memory store and a fake sign-in.
- Before Ready: a failing-first test for every risk below, red/green evidence in a PR comment, and the full Super Tab integration suite (
npm run test:super-tabs). - Files beyond the brief's list, each a pass-through or a comment:
cli/src/localWsServer.ts(readsthreadRootoffapp_swarms),cli/src/superTabs/inCore/cards.tsandcli/src/superTabs/service.ts(carry it in the focus),desktop/lib/super_tabs/client.dart(re-announces on a thread opening or closing),desktop/lib/super_tabs/controller.dart(says whether the thread's pane is on screen),desktop/lib/super_tabs/project_sidebar.dart(the note that the orders must match).
Review Focus
- Two dials, or one dial asking in a loop: device reads queue one at a time, so the backend never sees more than three recap reads at once (two background, one device). Test: two device recaps asked together both answer, and the second read starts after the first ends.
- A held recap from before another person signed in is never answered: the cache is cleared on a change of reader, as today. Test: covered by the existing reader-change test, kept green.
- A thread on the face whose root is in another conversation (the window moved to another chat with the thread pane still naming the old one) is not used: the thread counts only when it is in the face's own conversation. Test in Task 4.
- Words said while a thread was on the face that closed before they were sent go to the chat, never to a thread no longer shown. Test in Task 4.
- A project named with only case differences ("web" and "Web") keeps server order between them. Test in Task 2.
Task 1: The dial's recap is never refused, answers at once from what is held, and an empty one is logged
Files:
- Modify:
cli/src/superTabs/cards.ts(recap,pushOpenNow,prune,watchNotices/raise) - Modify:
cli/src/services/devices.ts:255-257(swarmCardRecap: a refusal throws its code instead of null) - Modify:
cli/src/cable/cableSession.ts:3031-3043(log once per Lead and reason) - Test:
cli/src/superTabs/cards.spec.ts,cli/src/cable/cableSession.spec.ts
Interfaces:
Produces:
SwarmCards.recap(tabId, leadId, chat)is the device's read: it waits for the device lane (one at a time) and never throws "too many recap reads". A privateread(tabId, leadId, chat, lane: 'device' | 'background')does the backend read;pushOpenNowuses'background'(still at mostMAX_RECAPS_IN_FLIGHT = 2, a refusal retried next tick).Produces: a recap held for the target's cache key (any sequence), else the Lead's notice for the target chat when it is a main-stream message, is answered at once; when it is older than the chat (
sequencemoved, or answered from a notice) a device-lane refresh follows andonRecappushes it when its text, time or chat differ.Produces:
prunekeeps a recap while its chat could be on this Lead's face (chatOfLead), not only while it is on it, so a swipe back finds it.Step 1: Write the failing tests (cards.spec.ts,
describe('SwarmCards dial recap'))answers the dial's recap while two background reads run: message reads take 50 ms; a tick reading a moved Lead conversation and a side switch's push are in flight;await cards.recap('t1', 'a1', 'buddy')resolves to the Lead's text, no throw.answers a side switch from the held recap with no backend request: PM recap read, swipe to Buddy (recap read), a tick, swipe back to PM;cards.recapanswers the PM text and noGET …/messagesis made.answers a stale held recap at once and pushes the newer one: the Lead conversation moved;cards.recapanswers the old text, thenonRecapgets the new text.queues two device recaps one after the other.
Step 2: Write the failing test (cableSession.spec.ts)
logs a recap answered empty once per Lead and reason: host recap answers null twice for a1 → one log line naming a1; a failure with a reason → one more line; a good answer and another null → a line again.Step 3: Run
cd cli && npx vitest run src/superTabs/cards.spec.ts src/cable/cableSession.spec.ts— Expected: the new tests FAIL ("too many recap reads at once", a messages read made, no log line).Step 4: Commit the failing tests.
Step 5: Implement as the Interfaces say; devices.ts throws
new Error(String(r.error ?? 'not a recap'))for a refused or unsound answer; cableSession keeps aSetof${lead}:${reason}logged, cleared for that Lead by a recap that came back.Step 6: Run the same command — Expected: PASS, whole files.
Step 7: Commit.
Task 2: Leads in the app's order
Files:
- Modify:
cli/src/superTabs/cards.ts:124-182(leadsOf) - Modify:
desktop/lib/super_tabs/project_sidebar.dart(comment at both sorts: the dial'sleadsOfmust match) - Test:
cli/src/superTabs/cards.spec.ts
Interfaces:
Produces: each
SwarmLead.orderis its project's rank byname.toLowerCase()compared by code unit (Dart'scompareTo), ties by server index; urgency sort ties go by that rank; the 12 most urgent are kept.Step 1: Write the failing tests:
orders Leads as the app lists projects: projectsZeta, alpha, Mid→orderalpha 0, Mid 1, Zeta 2 and, all done, leads[alpha, Mid, Zeta];keeps server order for a name tie:webthenWeb→ orders 0, 1. Update the two existing order tests to the A to Z rank.Step 2: Run
npx vitest run src/superTabs/cards.spec.ts -t "order"— Expected: FAIL (creation order).Step 3: Commit the failing tests.
Step 4: Implement the rank in
leadsOf, the note in both files.Step 5: Run the file — Expected: PASS. Step 6: Commit.
Task 3: The chat recap skips thread replies
Files:
- Modify:
cli/src/superTabs/cards.ts:198-212(lastAgentMessage) - Test:
cli/src/superTabs/cards.spec.ts
Interfaces:
Produces:
lastAgentMessage(messages, agentIds, place: 'any' | 'chat' | { thread: string } = 'any').'chat': the main stream (!thread || thread === id || alsoInChat, backend catchUp.tsinMainStream);{ thread }: rows whosethreadis that root. Notices keep'any'; recaps of a chat use'chat'.Step 1: Write the failing tests:
lastAgentMessage in the chat skips a thread reply but keeps one also sent to the chat;the chat recap is the agent's latest top-level message, not a thread reply(SwarmCards.recap over a page whose newest Lead row is a thread reply).Step 2: Run — Expected: FAIL (the reply's text). Step 3: Commit.
Step 4: Implement. Step 5: Run — PASS. Step 6: Commit.
Task 4: A thread open on Desktop is the dial's face
Files:
- Modify:
desktop/lib/state/app_state.dart:6080-6154(_dialThread,'threadRoot'on the row) - Modify:
desktop/lib/super_tabs/controller.dart:862-877(threadPaneOnScreen;threadPaneShownnotifies) - Modify:
desktop/lib/super_tabs/client.dart:766-769(anopenedThreadchange callsonSelection) - Modify:
cli/src/cable/cableSession.ts:328(AppSwarmsrowthreadRoot?),cli/src/localWsServer.ts:237(read it, an id or nothing) - Modify:
cli/src/cable/cableHost.ts:580(activeSwarmProjectcarriesthreadRoot),cli/src/services/devices.ts:583(focus carries it, a change refocuses) - Modify:
cli/src/superTabs/inCore/cards.ts:146,cli/src/superTabs/service.ts:500(carry it) - Modify:
cli/src/superTabs/cards.ts(want,target,Opened,pushOpenNow, cache key,say) - Test:
desktop/test/super_tab_dial_test.dart,cli/src/superTabs/cards.spec.ts,cli/src/cable/cableHost.spec.ts
Interfaces:
Produces: the
app_swarmsrow'sthreadRoot(the open thread's root id) while the selected conversation's thread pane is on screen; absent otherwise.Produces:
SwarmCards.want(on, include, focus: CardFocus & { threadRoot?: string }); a change ofthreadRootis a refocus.Produces:
Target.thread?: string, set when the face's conversation is the focused one and the focus names a thread;recapthen reads…/messages?thread=ROOTand takes the newest agent message there; the cache key andOpenedinclude the thread;saypostsreplyTo: threadwhentargetat send time has it.Step 1: Write the failing tests: Desktop
the Swarm row names the open thread while its pane shows, and not after it closes; cards.speca thread on the face shows its newest agent reply and closing it pushes the chat recap;words said with a thread on the face reply in it;a thread whose chat is not on the face is not usedandwords said after the thread closed go to the chat(Review Focus 3, 4); cableHost.specactiveSwarmProject carries the thread root.Step 2: Run
cd desktop && flutter test test/super_tab_dial_test.dartand the CLI files — Expected: FAIL. Step 3: Commit.Step 4: Implement as the Interfaces say. Step 5: Run — PASS, then
npx tsc --noEmit -p cli,npm run test:super-tabs,flutter analyzeon the changed files. Step 6: Commit and push.