fix: harden session transcript path resolution

This commit is contained in:
Peter Steinberger
2026-02-13 01:27:33 +01:00
parent 3eb6a31b6f
commit 4199f9889f
13 changed files with 322 additions and 66 deletions

View File

@@ -55,10 +55,12 @@ export type SessionInitResult = {
function forkSessionFromParent(params: {
parentEntry: SessionEntry;
sessionsDir: string;
}): { sessionId: string; sessionFile: string } | null {
const parentSessionFile = resolveSessionFilePath(
params.parentEntry.sessionId,
params.parentEntry,
{ sessionsDir: params.sessionsDir },
);
if (!parentSessionFile || !fs.existsSync(parentSessionFile)) {
return null;
@@ -320,6 +322,7 @@ export async function initSessionState(params: {
);
const forked = forkSessionFromParent({
parentEntry: sessionStore[parentSessionKey],
sessionsDir: path.dirname(storePath),
});
if (forked) {
sessionId = forked.sessionId;