mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-17 04:01:05 +00:00
Prefer active store path for session export
This commit is contained in:
@@ -140,4 +140,28 @@ describe("buildExportSessionReply", () => {
|
||||
storePath: "/tmp/target-store/sessions.json",
|
||||
});
|
||||
});
|
||||
|
||||
it("prefers the active command storePath over the default target-agent store", async () => {
|
||||
const { buildExportSessionReply } = await import("./commands-export-session.js");
|
||||
hoisted.loadSessionStoreMock.mockReturnValue({
|
||||
"agent:target:session": {
|
||||
sessionId: "session-1",
|
||||
updatedAt: 1,
|
||||
},
|
||||
});
|
||||
|
||||
await buildExportSessionReply({
|
||||
...makeParams(),
|
||||
storePath: "/tmp/custom-store/sessions.json",
|
||||
});
|
||||
|
||||
expect(hoisted.resolveDefaultSessionStorePathMock).not.toHaveBeenCalled();
|
||||
expect(hoisted.loadSessionStoreMock).toHaveBeenCalledWith("/tmp/custom-store/sessions.json", {
|
||||
skipCache: true,
|
||||
});
|
||||
expect(hoisted.resolveSessionFilePathOptionsMock).toHaveBeenCalledWith({
|
||||
agentId: "target",
|
||||
storePath: "/tmp/custom-store/sessions.json",
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -121,7 +121,7 @@ export async function buildExportSessionReply(params: HandleCommandsParams): Pro
|
||||
}
|
||||
|
||||
const targetAgentId = resolveAgentIdFromSessionKey(params.sessionKey) || params.agentId;
|
||||
const storePath = resolveDefaultSessionStorePath(targetAgentId);
|
||||
const storePath = params.storePath ?? resolveDefaultSessionStorePath(targetAgentId);
|
||||
const store = loadSessionStore(storePath, { skipCache: true });
|
||||
const entry = store[params.sessionKey] as SessionEntry | undefined;
|
||||
if (!entry?.sessionId) {
|
||||
|
||||
Reference in New Issue
Block a user