mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-27 23:12:52 +00:00
fix: preserve compat session transcript paths
This commit is contained in:
@@ -6,6 +6,7 @@ import {
|
||||
getSessionEntry,
|
||||
loadSessionStore,
|
||||
readSessionUpdatedAt,
|
||||
resolveAndPersistSessionFile,
|
||||
saveSessionStore,
|
||||
updateSessionStore,
|
||||
upsertSessionEntry,
|
||||
@@ -145,4 +146,46 @@ describe("session-store-runtime compatibility", () => {
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
it("preserves persisted transcript paths when resolving existing sessions", async () => {
|
||||
await withOpenClawTestState(
|
||||
{
|
||||
layout: "state-only",
|
||||
prefix: "openclaw-session-store-compat-",
|
||||
scenario: "minimal",
|
||||
},
|
||||
async (state) => {
|
||||
const env = testEnv(state.stateDir);
|
||||
const storePath = canonicalStorePath(state.stateDir);
|
||||
const existingFile = path.join(state.stateDir, "legacy", "custom.jsonl");
|
||||
const fallbackFile = path.join(
|
||||
state.stateDir,
|
||||
"agents",
|
||||
"main",
|
||||
"sessions",
|
||||
"fallback.jsonl",
|
||||
);
|
||||
const sessionStore = {
|
||||
"agent:main:main": {
|
||||
sessionId: "existing-session",
|
||||
sessionFile: existingFile,
|
||||
updatedAt: 100,
|
||||
sessionStartedAt: 100,
|
||||
},
|
||||
};
|
||||
|
||||
const result = await resolveAndPersistSessionFile({
|
||||
sessionId: "existing-session",
|
||||
sessionKey: "agent:main:main",
|
||||
sessionStore,
|
||||
storePath,
|
||||
fallbackSessionFile: fallbackFile,
|
||||
});
|
||||
|
||||
expect(result.sessionFile).toBe(existingFile);
|
||||
const persisted = getSessionEntry({ agentId: "main", env, sessionKey: "agent:main:main" });
|
||||
expect((persisted as { sessionFile?: string } | undefined)?.sessionFile).toBe(existingFile);
|
||||
},
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -270,8 +270,11 @@ export async function resolveAndPersistSessionFile(params: {
|
||||
updatedAt: now,
|
||||
sessionStartedAt: now,
|
||||
};
|
||||
const persistedSessionFile =
|
||||
baseEntry.sessionId === params.sessionId ? baseEntry.sessionFile?.trim() : undefined;
|
||||
const sessionFile =
|
||||
params.fallbackSessionFile?.trim() ??
|
||||
persistedSessionFile ||
|
||||
params.fallbackSessionFile?.trim() ||
|
||||
resolveSessionTranscriptPathInDir(
|
||||
params.sessionId,
|
||||
params.sessionsDir ?? path.dirname(path.resolve(params.storePath)),
|
||||
|
||||
Reference in New Issue
Block a user