diff --git a/src/bridge/agent-registry.js b/src/bridge/agent-registry.js index 507d65e..1c50911 100644 --- a/src/bridge/agent-registry.js +++ b/src/bridge/agent-registry.js @@ -566,6 +566,13 @@ export function createAgentRegistry({ if (typeof state.sessionName === "string") runtime.sessionName = state.sessionName; if (typeof state.sessionId === "string") runtime.sessionId = state.sessionId; + if (resolved && !runtime.sessionName && !runtime.firstMessage) { + const summary = await readSessionSummary(resolved, resolved).catch( + () => undefined, + ); + if (summary?.name) runtime.sessionName = summary.name; + if (summary?.firstMessage) runtime.firstMessage = summary.firstMessage; + } if (resolved) { if (indexSession) { if ( diff --git a/test/multi-session-registry.test.js b/test/multi-session-registry.test.js index 3de2843..1b0c2ef 100644 --- a/test/multi-session-registry.test.js +++ b/test/multi-session-registry.test.js @@ -177,9 +177,16 @@ test("closing removes desired-open intent, preserves history, and refuses direct await registry.stop(); }); -test("restores durable runtime IDs with two-at-a-time concurrency and preserves command isolation", async () => { +test("restores durable runtime IDs and history labels with two-at-a-time concurrency", async () => { const paths = await fixture(); const firstPath = await sessionFile(paths.sessionRoot, paths.home, "one"); + await writeFile( + firstPath, + `${await readFile(firstPath, "utf8")}${JSON.stringify({ + type: "message", + message: { role: "user", content: "Hydrate this session label" }, + })}\n`, + ); const secondPath = await sessionFile(paths.sessionRoot, paths.home, "two"); const thirdPath = await sessionFile(paths.sessionRoot, paths.home, "three"); const firstAdapters = adapterFactory({ @@ -195,6 +202,7 @@ test("restores durable runtime IDs with two-at-a-time concurrency and preserves if (!initial.sessionPath) await firstRegistry.closeSessionRuntime(initial.runtimeId); const one = await firstRegistry.openSessionRuntime(paths.home, firstPath); + assert.equal(one.label, "Hydrate this session label"); const two = await firstRegistry.openSessionRuntime(paths.home, secondPath); const three = await firstRegistry.openSessionRuntime(paths.home, thirdPath); await firstRegistry.stop(); @@ -241,6 +249,14 @@ test("restores durable runtime IDs with two-at-a-time concurrency and preserves new Set([one.runtimeId, two.runtimeId, three.runtimeId]), ); assert.equal(maxActiveStarts, 2); + assert.equal( + restored + .getWorkspace() + .directories[0].runtimes.find( + (runtime) => runtime.runtimeId === one.runtimeId, + )?.label, + "Hydrate this session label", + ); assert.ok( restored .listAgents()