|
9 | 9 | formatTokenReduction, |
10 | 10 | isChatTranscriptPath, |
11 | 11 | maxRepoFileSize, |
| 12 | + sessionRootCandidatePaths, |
| 13 | + sessionRootSpecs, |
12 | 14 | shouldIgnoreSessionPath, |
13 | 15 | summarizeTokenReduction |
14 | 16 | } from "../src/core.js" |
@@ -87,6 +89,61 @@ describe("session path filtering", () => { |
87 | 89 | }) |
88 | 90 | }) |
89 | 91 |
|
| 92 | +describe("session root resolution", () => { |
| 93 | + const codexSpec = sessionRootSpecs.find((spec) => spec.name === ".codex/sessions") |
| 94 | + const claudeSpec = sessionRootSpecs.find((spec) => spec.name === ".claude/projects") |
| 95 | + |
| 96 | + it("resolves Claude session roots from CLAUDE_CONFIG_DIR (issue #422)", () => { |
| 97 | + expect(claudeSpec).toBeDefined() |
| 98 | + if (claudeSpec === undefined) { |
| 99 | + return |
| 100 | + } |
| 101 | + const configDir = path.join(tmpDir, ".docker-git", ".orch", "auth", "claude", "default") |
| 102 | + const candidates = sessionRootCandidatePaths(claudeSpec, "/home/dev", { |
| 103 | + CLAUDE_CONFIG_DIR: configDir |
| 104 | + }) |
| 105 | + |
| 106 | + // The env override wins, but the home-relative path stays as a fallback. |
| 107 | + expect(candidates).toEqual([ |
| 108 | + path.join(configDir, "projects"), |
| 109 | + path.join("/home/dev", ".claude", "projects") |
| 110 | + ]) |
| 111 | + }) |
| 112 | + |
| 113 | + it("falls back to the home directory when the env override is empty", () => { |
| 114 | + expect(codexSpec).toBeDefined() |
| 115 | + if (codexSpec === undefined || claudeSpec === undefined) { |
| 116 | + return |
| 117 | + } |
| 118 | + expect(sessionRootCandidatePaths(codexSpec, "/home/dev", {})).toEqual([ |
| 119 | + path.join("/home/dev", ".codex", "sessions") |
| 120 | + ]) |
| 121 | + expect(sessionRootCandidatePaths(claudeSpec, "/home/dev", { CLAUDE_CONFIG_DIR: " " })).toEqual([ |
| 122 | + path.join("/home/dev", ".claude", "projects") |
| 123 | + ]) |
| 124 | + }) |
| 125 | + |
| 126 | + it("resolves Codex session roots from CODEX_HOME", () => { |
| 127 | + if (codexSpec === undefined) { |
| 128 | + return |
| 129 | + } |
| 130 | + const codexHome = path.join(tmpDir, "codex-home") |
| 131 | + expect(sessionRootCandidatePaths(codexSpec, "/home/dev", { CODEX_HOME: codexHome })).toEqual([ |
| 132 | + path.join(codexHome, "sessions"), |
| 133 | + path.join("/home/dev", ".codex", "sessions") |
| 134 | + ]) |
| 135 | + }) |
| 136 | + |
| 137 | + it("collapses to a single candidate when the override matches the home path", () => { |
| 138 | + if (claudeSpec === undefined) { |
| 139 | + return |
| 140 | + } |
| 141 | + expect( |
| 142 | + sessionRootCandidatePaths(claudeSpec, "/home/dev", { CLAUDE_CONFIG_DIR: "/home/dev/.claude" }) |
| 143 | + ).toEqual([path.join("/home/dev", ".claude", "projects")]) |
| 144 | + }) |
| 145 | +}) |
| 146 | + |
90 | 147 | describe("snapshot refs", () => { |
91 | 148 | it("uses stable current refs for PR and branch snapshots", () => { |
92 | 149 | expect(buildSnapshotRef("org/repo", 230, "issue-230")).toBe("org/repo/pr-230/current") |
|
0 commit comments