Skip to content

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.

fix: update recent recap provider to resolve agent IDs to engine session IDs

0xken15b25f9f8b99c9
diff --git a/cli/src/cli.ts b/cli/src/cli.ts
index b85ae27fb..53857612b 100644
--- a/cli/src/cli.ts
+++ b/cli/src/cli.ts
@@ -862,7 +862,10 @@ async function runForeground(token: string): Promise<void> {
dataDir: env.ADAPTER_DATA_DIR,
recapForce: env.RECAP_FORCE,
})
- backend.recentProvider = (sessionId, n) => mirror.recent(sessionId, n)
+ // Recaps are STORED under the engine session id — that is what lets `--resume` bring the last recap
+ // back under a brand-new agent — but they are ASKED FOR by agent id, which is the only id the device
+ // and the voice router know. Resolve across the two, or every tile restores empty.
+ backend.recentProvider = (id, n) => mirror.recent(registry.resolve(id)?.sessionId || id, n)
const input = new SessionInputController({
getSession: (id) => registry.resolve(id),
diff --git a/cli/src/lib/commander.spec.ts b/cli/src/lib/commander.spec.ts
index 4017d3d96..fdacd62e5 100644
--- a/cli/src/lib/commander.spec.ts
+++ b/cli/src/lib/commander.spec.ts
@@ -373,3 +373,28 @@ describe('device frames address the agent, not the session', () => {
expect(frames[0]).toMatchObject({ agentId: 'agent-uuid', dbSessionId: 'engine-session' })
})
})
+
+describe('recap lookup spans both ids', () => {
+ beforeEach(() => { vi.useFakeTimers(); dataDir = mkdtempSync(join(tmpdir(), 'adapter-recent-')) })
+ afterEach(() => { vi.useRealTimers(); rmSync(dataDir, { recursive: true, force: true }) })
+
+ it('stores a recap under the session but serves it for the agent', async () => {
+ // The device restores a tile by AGENT id; the recap is filed under the ENGINE session id so a
+ // `--resume` under a new agent still finds it. Ask with the wrong one and every tile came back empty.
+ const mirror = new CommanderMirror({
+ send: () => {}, sendWeb: () => {}, hasDevice: () => true,
+ summarize: async () => 'Short recap\n\nLong body', dataDir,
+ })
+ mirror.ingest([
+ { type: 'turn_started', payload: { userMessage: 'what happened?' } },
+ { type: 'text_delta', payload: { content: 'It happened.' } },
+ { type: 'turn_ended', payload: {} },
+ ] as LiveEvent[], 'engine-session')
+ await vi.runAllTimersAsync()
+
+ expect(mirror.recent('engine-session')).toHaveLength(1)
+ // …and the daemon's provider resolves an agent id to that session before asking.
+ const resolve = (id: string) => (id === 'agent-uuid' ? 'engine-session' : id)
+ expect(mirror.recent(resolve('agent-uuid'))[0].recap).toBe('Short recap')
+ })
+})