Skip to content

Commit 7a83b0c

Browse files
krissdingclaude
andcommitted
fix(session): keep shipped session dir key, rely on cwd verification
Revert the percent-encoding change of the default session directory key. Changing the key would make existing project transcripts invisible after upgrade without migration. Literal percent-escapes in cwd paths (e.g. /home/a%2Fb) would also collide with the encoded separators. The continueRecent cwd-verification guard already prevents wrong-project resume when two cwds map to the same safe-path — keep the shipped key and let the header.cwd check handle collisions. ClawSweeper: keep shipped key, cwd verify (#96906) Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
1 parent 266c66e commit 7a83b0c

1 file changed

Lines changed: 4 additions & 8 deletions

File tree

src/agents/sessions/session-manager.ts

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -437,14 +437,10 @@ export function buildSessionContext(
437437
* Encodes cwd into a safe directory name under ~/.openclaw/agent/sessions/.
438438
*/
439439
export function getDefaultSessionDir(cwd: string, agentDir: string = getDefaultAgentDir()): string {
440-
// Percent-encode path separators so distinct cwds never collide on encoding.
441-
// Previously '/' '\\' ':' all mapped to '-', causing /home/a/b-c and
442-
// /home/a/b/c to share one session directory (#96542).
443-
const safePath = `--${cwd.replace(/^[/\\]/, "").replace(/[/\\:]/g, (ch) => {
444-
if (ch === "/") return "%2F";
445-
if (ch === "\\") return "%5C";
446-
return "%3A";
447-
})}--`;
440+
// Pairwise-cwd collisions (e.g. /home/a/b-c vs /home/a/b/c mapping to the
441+
// same safe-path) are caught by the header-cwd verification in continueRecent,
442+
// so the session directory key does not need to be injective (#96542).
443+
const safePath = `--${cwd.replace(/^[/\\]/, "").replace(/[/\\:]/g, "-")}--`;
448444
const sessionDir = join(agentDir, "sessions", safePath);
449445
if (!existsSync(sessionDir)) {
450446
mkdirSync(sessionDir, { recursive: true });

0 commit comments

Comments
 (0)