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
fix(cable): push the ring before the focus that lands on it
0xdiego25a9f3050b69ae
diff --git a/cli/src/cable/cableSession.spec.ts b/cli/src/cable/cableSession.spec.tsindex 37948b74b..c32838bb0 100644--- a/cli/src/cable/cableSession.spec.ts+++ b/cli/src/cable/cableSession.spec.ts@@ -297,6 +297,31 @@ describe('cable session', () => {await session.stop()})+ it('pushes the ring BEFORE the focus that needs it', async () => {+ // Reported from the desk: clicking a rail agent that has NO tile yet moves the window and leaves the+ // dial where it was — often, not always.+ //+ // A focus names a tile the dial has to centre, and the dial centres only what its ring WALKS; an+ // agent with no tile can be sitting off that ring entirely, where the device drops the focus with+ // nothing to move to. The click is what changes the ring — it opens a tile — so the list and the+ // focus are one transaction, and the list has to go first.+ let agents: CableAgent[] = [{ id: 'a1', name: 'one' }, { id: 'a2', name: 'two' }]+ const { session, port } = await connect(makeHost({ listAgents: async () => agents }))+ port.say({ t: 'hello', product: 'harness', mac: 'aa:bb' })+ await settle()+ port.sent.length = 0++ agents = [{ id: 'a2', name: 'two' }, { id: 'a1', name: 'one' }] // the click re-shaped the desk+ await session.followApp('', 'a2')+ await settle()++ const order = port.types().filter((t) => t === 'agents.end' || t === 'focus')+ expect(order[0]).toBe('agents.end') // the ring the focus lands on, first+ expect(order).toContain('focus')+ expect(port.sent.filter((m) => m.t === 'focus').every((m) => m.agentId === 'a2')).toBe(true)+ await session.stop()+ })+it("never echoes the dial's own move back at it", async () => {// THE RING: the dial's carousel reports `focus` up, the daemon hands that to the window, the window// opens that agent's terminal, and a window opening a terminal is exactly what calls followApp. Leftdiff --git a/cli/src/cable/cableSession.ts b/cli/src/cable/cableSession.tsindex 7e71870db..618ff9a11 100644--- a/cli/src/cable/cableSession.ts+++ b/cli/src/cable/cableSession.ts@@ -1181,6 +1181,22 @@ export class CableSession {this.host.log(`cable: following the app to agent ${agentId}${unknown ? ' — NOT in this daemon\'s list, the dial has no tile for it' : ''}`)this.expectedAppFocusEcho = agentIdthis.expectedAppFocusEchoUntil = Date.now() + APP_FOCUS_SETTLE_MS+ // THE LIST FIRST, THEN THE FOCUS — the fix for "clicking a rail agent that has no tile does not+ // move the dial".+ //+ // A focus names a tile the dial has to CENTRE, and the dial can only centre what its ring walks.+ // The click that brought us here is usually the very thing that changed the ring: opening an+ // agent that had no tile puts it on the desk, and until that list is pushed the dial is still+ // walking a ring where that agent sits off it — where the device drops the focus, by design, with+ // no column to move to. Racing the two produced exactly the reported symptom: mostly it worked+ // (the tick's push arrived first), sometimes it did not, and nothing in either log said which.+ //+ // The record is written BEFORE the push so the re-assert at the end of syncAgents names the agent+ // we are moving to, not the one we are leaving — otherwise the dial visibly steps onto the old+ // tile on its way. Cheap when nothing changed: syncAgents returns without sending a frame.+ this.desiredFocus = agentId+ await this.syncAgents()+ if (generation !== this.appFocusGeneration) returnawait this.focusAgent(agentId) // writes the record} finally {this.drivingAppFocus = falsediff --git a/cli/src/cli.ts b/cli/src/cli.tsindex b3a11dccb..9495f8a3a 100644--- a/cli/src/cli.ts+++ b/cli/src/cli.ts@@ -2774,6 +2774,14 @@ async function runForeground(session: AuthSession): Promise<void> {// around these — tiles first, in tile order — so the thumb walks the same// grid the eyes are on. `openPaneAgents` below only ever asks "is this// one on screen", which is why it can stay a set.+ //+ // THE RING IS A FUNCTION OF THIS LIST, so a change here is a new ring and has to be pushed at once.+ // Leaving it to the next tick opened a one-second window with a real failure in it: clicking a rail+ // agent that has NO tile yet changes the desk and then immediately follows with the focus, and a+ // focus for an agent the dial's CURRENT ring does not walk is dropped on the device — it has no+ // column to centre on. The window moved, the dial did not, and nothing anywhere said why.+ const deskChanged = agentIds.length !== appPaneAgents.length+ || agentIds.some((id, at) => id !== appPaneAgents[at])appPaneAgents = agentIdscableHostRef?.setDesk(agentIds)const next = new Set(agentIds)@@ -2783,6 +2791,8 @@ async function runForeground(session: AuthSession): Promise<void> {const changed = next.size !== openPaneAgents.size || [...next].some((id) => !openPaneAgents.has(id))openPaneAgents = nextif (changed) console.log(`[cable] window tiles: ${next.size ? [...next].map(sid).join(' ') : '(none)'}`)+ // Ordered, not set-wise: two tiles swapping places is the same set and a different ring.+ if (deskChanged) void cableRef?.syncAgents()},machineId: backend.machineId,backend,