fix(bridge): restore labels from session history
Hydrate missing runtime names from persisted session metadata so opened and restored conversations no longer remain titled New session.
This commit is contained in:
@@ -566,6 +566,13 @@ export function createAgentRegistry({
|
|||||||
if (typeof state.sessionName === "string")
|
if (typeof state.sessionName === "string")
|
||||||
runtime.sessionName = state.sessionName;
|
runtime.sessionName = state.sessionName;
|
||||||
if (typeof state.sessionId === "string") runtime.sessionId = state.sessionId;
|
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 (resolved) {
|
||||||
if (indexSession) {
|
if (indexSession) {
|
||||||
if (
|
if (
|
||||||
|
|||||||
@@ -177,9 +177,16 @@ test("closing removes desired-open intent, preserves history, and refuses direct
|
|||||||
await registry.stop();
|
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 paths = await fixture();
|
||||||
const firstPath = await sessionFile(paths.sessionRoot, paths.home, "one");
|
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 secondPath = await sessionFile(paths.sessionRoot, paths.home, "two");
|
||||||
const thirdPath = await sessionFile(paths.sessionRoot, paths.home, "three");
|
const thirdPath = await sessionFile(paths.sessionRoot, paths.home, "three");
|
||||||
const firstAdapters = adapterFactory({
|
const firstAdapters = adapterFactory({
|
||||||
@@ -195,6 +202,7 @@ test("restores durable runtime IDs with two-at-a-time concurrency and preserves
|
|||||||
if (!initial.sessionPath)
|
if (!initial.sessionPath)
|
||||||
await firstRegistry.closeSessionRuntime(initial.runtimeId);
|
await firstRegistry.closeSessionRuntime(initial.runtimeId);
|
||||||
const one = await firstRegistry.openSessionRuntime(paths.home, firstPath);
|
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 two = await firstRegistry.openSessionRuntime(paths.home, secondPath);
|
||||||
const three = await firstRegistry.openSessionRuntime(paths.home, thirdPath);
|
const three = await firstRegistry.openSessionRuntime(paths.home, thirdPath);
|
||||||
await firstRegistry.stop();
|
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]),
|
new Set([one.runtimeId, two.runtimeId, three.runtimeId]),
|
||||||
);
|
);
|
||||||
assert.equal(maxActiveStarts, 2);
|
assert.equal(maxActiveStarts, 2);
|
||||||
|
assert.equal(
|
||||||
|
restored
|
||||||
|
.getWorkspace()
|
||||||
|
.directories[0].runtimes.find(
|
||||||
|
(runtime) => runtime.runtimeId === one.runtimeId,
|
||||||
|
)?.label,
|
||||||
|
"Hydrate this session label",
|
||||||
|
);
|
||||||
assert.ok(
|
assert.ok(
|
||||||
restored
|
restored
|
||||||
.listAgents()
|
.listAgents()
|
||||||
|
|||||||
Reference in New Issue
Block a user