refactor(session): centralize transcript path option resolution

This commit is contained in:
Peter Steinberger
2026-02-22 12:00:54 +01:00
parent 37f12eb7ee
commit b77e53da67
5 changed files with 58 additions and 14 deletions

View File

@@ -1,4 +1,3 @@
import path from "node:path";
import {
listAgentIds,
resolveAgentDir,
@@ -45,6 +44,7 @@ import {
resolveAndPersistSessionFile,
resolveAgentIdFromSessionKey,
resolveSessionFilePath,
resolveSessionFilePathOptions,
resolveSessionTranscriptPath,
type SessionEntry,
updateSessionStore,
@@ -510,10 +510,11 @@ export async function agentCommand(
});
}
}
let sessionFile = resolveSessionFilePath(sessionId, sessionEntry, {
const sessionPathOpts = resolveSessionFilePathOptions({
agentId: sessionAgentId,
sessionsDir: path.dirname(storePath),
storePath,
});
let sessionFile = resolveSessionFilePath(sessionId, sessionEntry, sessionPathOpts);
if (sessionStore && sessionKey) {
const threadIdFromSessionKey = parseSessionThreadInfo(sessionKey).threadId;
const fallbackSessionFile = !sessionEntry?.sessionFile
@@ -529,8 +530,8 @@ export async function agentCommand(
sessionStore,
storePath,
sessionEntry,
agentId: sessionAgentId,
sessionsDir: path.dirname(storePath),
agentId: sessionPathOpts?.agentId,
sessionsDir: sessionPathOpts?.sessionsDir,
fallbackSessionFile,
});
sessionFile = resolvedSessionFile.sessionFile;