Skip to content

Commit 0235cca

Browse files
committed
fix: preserve explicit reset transcript paths
1 parent b15d9eb commit 0235cca

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

src/gateway/server.sessions.gateway-server-sessions-a.test.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1118,10 +1118,15 @@ describe("gateway server sessions", () => {
11181118

11191119
test("sessions.reset preserves spawned session ownership metadata", async () => {
11201120
const { storePath } = await createSessionStoreDir();
1121+
const customSessionFile = path.join(
1122+
await fs.realpath(path.dirname(storePath)),
1123+
"custom-owned-child-transcript.jsonl",
1124+
);
11211125
await writeSessionStore({
11221126
entries: {
11231127
"subagent:child": {
11241128
sessionId: "sess-owned-child",
1129+
sessionFile: customSessionFile,
11251130
updatedAt: Date.now(),
11261131
chatType: "group",
11271132
channel: "discord",
@@ -1175,6 +1180,7 @@ describe("gateway server sessions", () => {
11751180
ok: true;
11761181
key: string;
11771182
entry: {
1183+
sessionFile?: string;
11781184
chatType?: string;
11791185
channel?: string;
11801186
groupId?: string;
@@ -1220,6 +1226,7 @@ describe("gateway server sessions", () => {
12201226
}>(ws, "sessions.reset", { key: "subagent:child" });
12211227

12221228
expect(reset.ok).toBe(true);
1229+
expect(reset.payload?.entry.sessionFile).toBe(customSessionFile);
12231230
expect(reset.payload?.entry.chatType).toBe("group");
12241231
expect(reset.payload?.entry.channel).toBe("discord");
12251232
expect(reset.payload?.entry.groupId).toBe("group-1");
@@ -1265,6 +1272,7 @@ describe("gateway server sessions", () => {
12651272
const store = JSON.parse(await fs.readFile(storePath, "utf-8")) as Record<
12661273
string,
12671274
{
1275+
sessionFile?: string;
12681276
chatType?: string;
12691277
channel?: string;
12701278
groupId?: string;
@@ -1308,6 +1316,7 @@ describe("gateway server sessions", () => {
13081316
label?: string;
13091317
}
13101318
>;
1319+
expect(store["agent:main:subagent:child"]?.sessionFile).toBe(customSessionFile);
13111320
expect(store["agent:main:subagent:child"]?.chatType).toBe("group");
13121321
expect(store["agent:main:subagent:child"]?.channel).toBe("discord");
13131322
expect(store["agent:main:subagent:child"]?.groupId).toBe("group-1");

src/gateway/session-reset-service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ export async function performGatewaySessionReset(params: {
313313
const nextSessionId = randomUUID();
314314
const sessionFile = resolveSessionFilePath(
315315
nextSessionId,
316-
undefined,
316+
currentEntry?.sessionFile ? { sessionFile: currentEntry.sessionFile } : undefined,
317317
resolveSessionFilePathOptions({
318318
storePath,
319319
agentId: sessionAgentId,

0 commit comments

Comments
 (0)