Skip to content

Commit 7e911df

Browse files
committed
fix(sessions): place derived codex sessions in codex store
1 parent 38c9a89 commit 7e911df

2 files changed

Lines changed: 17 additions & 5 deletions

File tree

cli.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6835,7 +6835,9 @@ async function convertSessionToDerived(params = {}) {
68356835
const baseSessionId = extracted.sessionId || params.sessionId || path.basename(filePath, '.jsonl');
68366836
const derivedSessionId = buildDerivedSessionId(baseSessionId);
68376837
const sourceKey = buildSessionDerivedSourceKey(source, baseSessionId, filePath);
6838-
const outputDir = buildDerivedSessionOutputDir(target, source, sourceKey);
6838+
const outputDir = target === 'codex'
6839+
? getCodexSessionsDir()
6840+
: buildDerivedSessionOutputDir(target, source, sourceKey);
68396841
ensureDir(outputDir);
68406842
const outputPath = path.join(outputDir, `${derivedSessionId}.jsonl`);
68416843
const metaPath = path.join(outputDir, `${derivedSessionId}.meta.json`);

tests/e2e/test-session-convert-derived.js

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@ function derivedMetaPath(filePath) {
1212
return filePath.endsWith('.jsonl') ? filePath.replace(/\.jsonl$/, '.meta.json') : `${filePath}.meta.json`;
1313
}
1414

15+
function isCodexSessionPath(tmpHome, filePath) {
16+
const normalized = String(filePath || '');
17+
return normalized.startsWith(path.join(tmpHome, '.codex', 'sessions') + path.sep)
18+
|| normalized.startsWith(path.join(tmpHome, '.config', 'codex', 'sessions') + path.sep);
19+
}
20+
1521
function buildIso(baseIso, offsetSeconds) {
1622
return new Date(Date.parse(baseIso) + (offsetSeconds * 1000)).toISOString();
1723
}
@@ -48,10 +54,14 @@ async function convertAndAssertListed(api, tmpHome, source, target, params = {},
4854
const outPath = res.session.filePath;
4955
assert(fs.existsSync(outPath), `derived ${target} session file missing`);
5056
assert(fs.existsSync(derivedMetaPath(outPath)), `derived ${target} meta missing`);
51-
assert(
52-
outPath.startsWith(path.join(tmpHome, '.codexmate', 'sessions', 'derived', target) + path.sep),
53-
`derived ${target} session path should stay inside ~/.codexmate`
54-
);
57+
if (target === 'codex') {
58+
assert(isCodexSessionPath(tmpHome, outPath), 'derived codex session path should stay inside ~/.codex or ~/.config/codex');
59+
} else {
60+
assert(
61+
outPath.startsWith(path.join(tmpHome, '.codexmate', 'sessions', 'derived', target) + path.sep),
62+
`derived ${target} session path should stay inside ~/.codexmate`
63+
);
64+
}
5565
if (options.assertListed !== false) {
5666
const list = await api('list-sessions', { source: target, limit: 300, forceRefresh: true });
5767
assert(Array.isArray(list.sessions), `list-sessions(${target}) missing sessions`);

0 commit comments

Comments
 (0)