fix: assign reset transcript paths to new sessions

This commit is contained in:
Tak Hoffman
2026-03-26 21:03:54 -05:00
parent 14b3360c22
commit 708b9339a5
2 changed files with 20 additions and 2 deletions

View File

@@ -1095,12 +1095,19 @@ describe("gateway server sessions", () => {
const reset = await rpcReq<{
ok: true;
key: string;
entry: { sessionId: string; modelProvider?: string; model?: string; contextTokens?: number };
entry: {
sessionId: string;
sessionFile?: string;
modelProvider?: string;
model?: string;
contextTokens?: number;
};
}>(ws, "sessions.reset", { key: "main" });
expect(reset.ok).toBe(true);
expect(reset.payload?.key).toBe("agent:main:main");
expect(reset.payload?.entry.sessionId).not.toBe("sess-stale-model");
expect(reset.payload?.entry.sessionFile).toBeTruthy();
expect(reset.payload?.entry.modelProvider).toBe("openai");
expect(reset.payload?.entry.model).toBe("gpt-test-a");
expect(reset.payload?.entry.contextTokens).toBeUndefined();

View File

@@ -11,6 +11,7 @@ import {
type SessionEntry,
updateSessionStore,
} from "../config/sessions.js";
import { resolveSessionFilePath, resolveSessionFilePathOptions } from "../config/sessions/paths.js";
import { logVerbose } from "../globals.js";
import { createInternalHookEvent, triggerInternalHook } from "../hooks/internal-hooks.js";
import { closeTrackedBrowserTabsForSessions } from "../plugin-sdk/browser-runtime.js";
@@ -306,8 +307,18 @@ export async function performGatewaySessionReset(params: {
oldSessionId = currentEntry?.sessionId;
oldSessionFile = currentEntry?.sessionFile;
const now = Date.now();
const nextSessionId = randomUUID();
const sessionFile = resolveSessionFilePath(
nextSessionId,
undefined,
resolveSessionFilePathOptions({
storePath,
agentId: sessionAgentId,
}),
);
const nextEntry: SessionEntry = {
sessionId: randomUUID(),
sessionId: nextSessionId,
sessionFile,
updatedAt: now,
systemSent: false,
abortedLastRun: false,