Skip to content

Commit b3b5b08

Browse files
committed
fix(memory): preserve Windows session transcript paths
1 parent 71ef6b2 commit b3b5b08

2 files changed

Lines changed: 25 additions & 11 deletions

File tree

‎packages/memory-host-sdk/src/host/session-files.ts‎

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -217,16 +217,21 @@ export function normalizeSessionTranscriptPathForComparison(pathname: string): s
217217
function resolveSessionStoreTranscriptPath(
218218
sessionsDir: string,
219219
entry: { sessionFile?: unknown; sessionId?: unknown } | undefined,
220+
): string | null {
221+
const resolved = resolveSessionStoreTranscriptResolvedPath(sessionsDir, entry);
222+
return resolved ? normalizeComparablePath(resolved) : null;
223+
}
224+
225+
function resolveSessionStoreTranscriptResolvedPath(
226+
sessionsDir: string,
227+
entry: { sessionFile?: unknown; sessionId?: unknown } | undefined,
220228
): string | null {
221229
if (typeof entry?.sessionFile === "string" && entry.sessionFile.trim().length > 0) {
222230
const sessionFile = entry.sessionFile.trim();
223-
const resolved = path.isAbsolute(sessionFile)
224-
? sessionFile
225-
: path.resolve(sessionsDir, sessionFile);
226-
return normalizeComparablePath(resolved);
231+
return path.isAbsolute(sessionFile) ? sessionFile : path.resolve(sessionsDir, sessionFile);
227232
}
228233
if (typeof entry?.sessionId === "string" && entry.sessionId.trim().length > 0) {
229-
return normalizeComparablePath(path.join(sessionsDir, `${entry.sessionId.trim()}.jsonl`));
234+
return path.join(sessionsDir, `${entry.sessionId.trim()}.jsonl`);
230235
}
231236
return null;
232237
}
@@ -431,7 +436,7 @@ export function resolveSessionFileForSyncTarget(
431436
let store: Record<string, SessionTranscriptStoreEntry> | null = null;
432437
if (sessionKey) {
433438
store = readSessionTranscriptClassificationStore(path.join(sessionsDir, "sessions.json"));
434-
const persistedPath = resolveSessionStoreTranscriptPath(sessionsDir, store[sessionKey]);
439+
const persistedPath = resolveSessionStoreTranscriptResolvedPath(sessionsDir, store[sessionKey]);
435440
const canonicalPath = resolveCanonicalSessionSyncFilePath(agentId, persistedPath);
436441
if (canonicalPath) {
437442
return {
@@ -442,7 +447,7 @@ export function resolveSessionFileForSyncTarget(
442447
}
443448
}
444449
store ??= readSessionTranscriptClassificationStore(path.join(sessionsDir, "sessions.json"));
445-
const persistedPath = resolveSessionStoreTranscriptPath(
450+
const persistedPath = resolveSessionStoreTranscriptResolvedPath(
446451
sessionsDir,
447452
findSessionTranscriptStoreEntryBySessionId(store, sessionId),
448453
);

‎test/openclaw-launcher.e2e.test.ts‎

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { spawn, spawnSync } from "node:child_process";
33
import { once } from "node:events";
44
import fs from "node:fs/promises";
55
import path from "node:path";
6+
import { pathToFileURL } from "node:url";
67
import { afterEach, describe, expect, it } from "vitest";
78
import { cleanupTempDirs, makeTempDir } from "./helpers/temp-dir.js";
89

@@ -130,7 +131,10 @@ function isProcessAlive(pid: number | undefined): boolean {
130131
function launcherEnv(extra: NodeJS.ProcessEnv = {}): NodeJS.ProcessEnv {
131132
const env = { ...process.env, ...extra };
132133
delete env.OPENCLAW_BUNDLED_PLUGINS_DIR;
134+
delete env.OPENCLAW_CONFIG_PATH;
133135
delete env.OPENCLAW_DISABLE_BUNDLED_PLUGINS;
136+
delete env.OPENCLAW_HOME;
137+
delete env.OPENCLAW_STATE_DIR;
134138
delete env.OPENCLAW_TEST_TRUST_BUNDLED_PLUGINS_DIR;
135139
delete env.NODE_COMPILE_CACHE;
136140
delete env.NODE_DISABLE_COMPILE_CACHE;
@@ -211,7 +215,12 @@ describe("openclaw launcher", () => {
211215

212216
const result = spawnSync(
213217
process.execPath,
214-
["--import", mockNodeVersionPath, path.join(fixtureRoot, "openclaw.mjs"), "--help"],
218+
[
219+
"--import",
220+
pathToFileURL(mockNodeVersionPath).href,
221+
path.join(fixtureRoot, "openclaw.mjs"),
222+
"--help",
223+
],
215224
{
216225
cwd: fixtureRoot,
217226
env: launcherEnv(),
@@ -1010,7 +1019,7 @@ describe("openclaw launcher", () => {
10101019

10111020
const result = spawnSync(
10121021
process.execPath,
1013-
["--import", mockRuntime, path.join(fixtureRoot, "openclaw.mjs")],
1022+
["--import", pathToFileURL(mockRuntime).href, path.join(fixtureRoot, "openclaw.mjs")],
10141023
{
10151024
cwd: fixtureRoot,
10161025
env: launcherEnv({
@@ -1039,7 +1048,7 @@ describe("openclaw launcher", () => {
10391048

10401049
const result = spawnSync(
10411050
process.execPath,
1042-
["--import", mockRuntime, path.join(fixtureRoot, "openclaw.mjs")],
1051+
["--import", pathToFileURL(mockRuntime).href, path.join(fixtureRoot, "openclaw.mjs")],
10431052
{
10441053
cwd: fixtureRoot,
10451054
env: launcherEnv({
@@ -1072,7 +1081,7 @@ describe("openclaw launcher", () => {
10721081

10731082
const result = spawnSync(
10741083
process.execPath,
1075-
["--import", mockRuntime, path.join(fixtureRoot, "openclaw.mjs")],
1084+
["--import", pathToFileURL(mockRuntime).href, path.join(fixtureRoot, "openclaw.mjs")],
10761085
{
10771086
cwd: fixtureRoot,
10781087
env: launcherEnv({

0 commit comments

Comments
 (0)