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

@@ -8,6 +8,7 @@ import {
loadSessionStore,
resolveMainSessionKey,
resolveSessionFilePath,
resolveSessionFilePathOptions,
resolveSessionTranscriptsDirForAgent,
resolveStorePath,
} from "../config/sessions.js";
@@ -386,6 +387,7 @@ export async function noteStateIntegrity(
}
const store = loadSessionStore(storePath);
const sessionPathOpts = resolveSessionFilePathOptions({ agentId, storePath });
const entries = Object.entries(store).filter(([, entry]) => entry && typeof entry === "object");
if (entries.length > 0) {
const recent = entries
@@ -401,9 +403,7 @@ export async function noteStateIntegrity(
if (!sessionId) {
return false;
}
const transcriptPath = resolveSessionFilePath(sessionId, entry, {
agentId,
});
const transcriptPath = resolveSessionFilePath(sessionId, entry, sessionPathOpts);
return !existsFile(transcriptPath);
});
if (missing.length > 0) {
@@ -415,7 +415,11 @@ export async function noteStateIntegrity(
const mainKey = resolveMainSessionKey(cfg);
const mainEntry = store[mainKey];
if (mainEntry?.sessionId) {
const transcriptPath = resolveSessionFilePath(mainEntry.sessionId, mainEntry, { agentId });
const transcriptPath = resolveSessionFilePath(
mainEntry.sessionId,
mainEntry,
sessionPathOpts,
);
if (!existsFile(transcriptPath)) {
warnings.push(
`- Main session transcript missing (${shortenHomePath(transcriptPath)}). History will appear to reset.`,