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
feat: trace registry launch state transitions and fix activity timestamp fallback for unhooked agents
0xken15f1e972d921b2
diff --git a/cli/src/lib/agentFrame.spec.ts b/cli/src/lib/agentFrame.spec.tsindex 9a7337708..4274a8558 100644--- a/cli/src/lib/agentFrame.spec.ts+++ b/cli/src/lib/agentFrame.spec.ts@@ -122,6 +122,23 @@ describe('agentFrame updatedAt', () => {expect((await agentFrame(row, context)).updatedAt).toBe('2026-09-17T07:00:00.000Z')})+ // A row no hook has ever reached — a bare terminal, an engine still starting, a harness opened from+ // the catalog (`resumePendingAgent` writes `lastHookAt: 0`) — answered the epoch, and the desk+ // rendered its age as "20719d" and sorted it below everything ever used.+ it('falls back to when the agent came into being, never to the epoch', async () => {+ const bound = Date.UTC(2026, 8, 20, 9)+ const created = Date.UTC(2026, 8, 19, 8)+ const never = { ...session(null), updatedAt: Date.now(), lastHookAt: 0 }+ expect((await agentFrame({ ...never, boundAt: bound, registeredAt: created }, context)).updatedAt)+ .toBe('2026-09-20T09:00:00.000Z')+ expect((await agentFrame({ ...never, boundAt: null, registeredAt: created }, context)).updatedAt)+ .toBe('2026-09-19T08:00:00.000Z')+ // Only stamps the row already carries: a client compares this field to decide whether the agent+ // changed, so reading a clock here would redraw the row on every sync and reset its age.+ const row = { ...never, boundAt: null, registeredAt: created }+ expect((await agentFrame(row, context)).updatedAt).toBe((await agentFrame(row, context)).updatedAt)+ })+it('uses actual conversation activity even when an idle transcript was rewritten hours later', async () => {const dir = await mkdtemp(join(tmpdir(), 'agent-frame-'))try {diff --git a/cli/src/lib/agentFrame.ts b/cli/src/lib/agentFrame.tsindex 41019d85b..38c161c68 100644--- a/cli/src/lib/agentFrame.ts+++ b/cli/src/lib/agentFrame.ts@@ -136,9 +136,19 @@ export interface AgentFrameContext {* (`updateRuntimes`), so falling back to it stamped every agent without a readable transcript "now"* — and a client sorting by recency put exactly those agents above the ones just used. File mtime is* bookkeeping too: an idle transcript can be rewritten without a new conversation event.+ *+ * "The agent's creation at the latest" is the part that was missing: a row no hook has ever reached —+ * a bare terminal, an engine still starting, a harness opened from the catalog — carries+ * `lastHookAt: 0`, and answering the epoch made a client render its age as 20719 days ("20719d") and+ * sort it below everything. Creation is a real answer for "nothing has happened yet"; zero is not.+ *+ * Every step is a stamp the row already carries, never a fresh clock read: a client compares this+ * field to decide whether an agent changed at all (the desktop's `agentsEqual`), so a value that+ * moves on its own would redraw the row on every sync and reset its age to "0m" forever.*/export async function lastActivityAt(s: RegisteredSession): Promise<number> {- return await transcriptActivityAt(s.transcriptPath, s.engine) ?? s.lastHookAt+ return await transcriptActivityAt(s.transcriptPath, s.engine)+ ?? (s.lastHookAt || s.boundAt || s.registeredAt)}function frameTitle(s: RegisteredSession): string | null {diff --git a/cli/src/lib/registry.spec.ts b/cli/src/lib/registry.spec.tsindex 571522a29..ec7fa4757 100644--- a/cli/src/lib/registry.spec.ts+++ b/cli/src/lib/registry.spec.ts@@ -1047,6 +1047,37 @@ describe('agent identity: the process owns the agent, the session is bound to itexpect(reloaded.unbound()).toHaveLength(1)})+ // A row that does not leave `starting` reads as "Starting" on the desk while its engine is working,+ // and the state is written from six places that cannot see each other. Each one says so, and a+ // settled row says nothing — so a log from a machine where it sticks names the pair doing it.+ it('names every launch change by the door it came through, and is silent when nothing changed', async () => {+ const { registry } = await loadRegistryModule()+ registry.load()+ const lines: string[] = []+ const log = vi.spyOn(console, 'log').mockImplementation((message: unknown) => {+ if (typeof message === 'string' && message.startsWith('[launch]')) lines.push(message)+ })+ try {+ const pending = registry.openPendingAgent({ engine: 'claude', runtimes: [{ backend: 'tmux', paneId: '%7' }], cwd: '/tmp/demo' })!+ registry.openProcessAgent({ engine: 'claude', tmuxPane: '%7', cwd: '/tmp/demo', processIdentity: processIdentity(707) })+ registry.setLaunch(pending.agentId, { state: 'ready' }) // already ready — silent+ registry.setLaunch(pending.agentId, { state: 'failed', error: 'START_TIMEOUT' })+ const id = pending.agentId.slice(0, 8)+ expect(lines).toEqual([+ `[launch] ${id} starting → ready · openProcessAgent re-observed`,+ `[launch] ${id} ready → failed · setLaunch (START_TIMEOUT)`,+ ])++ // A bind ends the launch without naming it: the rebuilt row carries none.+ lines.length = 0+ registry.setLaunch(pending.agentId, { state: 'starting' })+ registerProcess(registry, { launcherId: pending.agentId, sessionId: 's1', transcriptPath: transcript('s1'), tmuxPane: '%7', cwd: '/tmp/demo' })+ expect(lines.filter(line => line.includes('→ none'))).toHaveLength(1)+ } finally {+ log.mockRestore()+ }+ })+it('opens a route-only pending agent and adopts the engine process without changing agentId', async () => {const { registry } = await loadRegistryModule()registry.load()diff --git a/cli/src/lib/registry.ts b/cli/src/lib/registry.tsindex a843bd46a..a1de055ed 100644--- a/cli/src/lib/registry.ts+++ b/cli/src/lib/registry.ts@@ -1063,7 +1063,11 @@ class Registry {if (!existing.sessionId || !existing.cwd) existing.cwd = input.cwd ?? existing.cwdexisting.processIdentity = processIdentityexisting.active = true- if (existing.launch && !existing.resumeOnly) existing.launch = { state: 'ready' }+ if (existing.launch && !existing.resumeOnly) {+ const before = existing.launch+ existing.launch = { state: 'ready' }+ this.traceLaunch(existing.agentId, before, existing.launch, 'openProcessAgent re-observed')+ }// Only a successful read speaks: an undefined probe (ps failed, /proc unreadable) keeps whatever// the last good one said rather than silently downgrading a gateway agent to a vendor one.if (input.gateway !== undefined) existing.gateway = input.gateway@@ -1459,6 +1463,10 @@ class Registry {}entry.tmuxPane = tmuxProjection(entry.runtimes)entry.primaryRuntimeKey = selectedRuntimeKey(entry.runtimes, input.primaryRuntimeKey || existing?.primaryRuntimeKey)+ // A bind REBUILDS the row, and the rebuild carries no `launch` unless the row is resume-only:+ // an engine reporting for duty is the end of any launch. Traced like the setters, because this+ // is the one that changes the state without naming it.+ this.traceLaunch(agentId, existing?.launch, entry.launch, `register ${engine} (${isNew ? 'new session' : 're-register'})`)if (rebound) this.sessionIndex.delete(rebound)this.index(entry)this.save()@@ -1542,6 +1550,7 @@ class Registry {this.drop(entry)entry.engine = engineentry.terminalHost = true+ this.traceLaunch(entry.agentId, entry.launch, { state: 'ready' }, `adoptEngine ${engine}`)entry.launch = { state: 'ready' }entry.active = trueif (validProcessIdentity(processIdentity)) entry.processIdentity = processIdentity@@ -1583,6 +1592,7 @@ class Registry {entry.engine = 'terminal'entry.terminalHost = trueentry.processIdentity = null+ this.traceLaunch(entry.agentId, entry.launch, { state: 'ready' }, 'releaseEngine')entry.launch = { state: 'ready' }entry.active = trueentry.gateway = null@@ -1622,12 +1632,30 @@ class Registry {return true}+ /**+ * Every change of a row's launch state, named by the door it came through.+ *+ * `launch` is what a desk reads as "Starting", and a row that does not leave that state looks stuck+ * on a harness that is working — measured once at 9 minutes on a restored opencode agent whose+ * engine the log had already confirmed up. The state is written from six places and no two of them+ * see each other, so the only way to say which one is fighting which is to have each say so. Rare+ * in a settled daemon (create, restore, an engine exiting); a row that oscillates prints the pair+ * that is doing it, once per pass.+ */+ private traceLaunch(agentId: string, before: AgentLaunch | undefined, after: AgentLaunch | undefined, where: string): void {+ const name = (launch: AgentLaunch | undefined): string => launch ? launch.state : 'none'+ if (name(before) === name(after)) return+ console.log(`[launch] ${agentId.slice(0, 8)} ${name(before)} → ${name(after)} · ${where}`)+ }+setLaunch(agentId: string, launch: AgentLaunch): RegisteredSession | null {const entry = this.agents.get(agentId)if (!entry) return null+ const before = entry.launchentry.launch = normalizedLaunch(launch)entry.active = launch.state !== 'failed'entry.updatedAt = Date.now()+ this.traceLaunch(agentId, before, entry.launch, `setLaunch${launch.state === 'failed' ? ` (${launch.error})` : ''}`)this.save()return entry}