Skip to content

Commit a163ec4

Browse files
committed
fix(sessions): disable session conversion
- Mark derived sessions in session-detail responses for UI gating\n- Disable conversion for derived sessions across sources\n- Disable the conversion button in the sessions UI
1 parent 0b79956 commit a163ec4

5 files changed

Lines changed: 43 additions & 2 deletions

File tree

cli.js

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6346,10 +6346,14 @@ function isDerivedSessionFile(filePath) {
63466346
const metaPath = getDerivedSessionMetaPath(filePath);
63476347
if (!metaPath) return false;
63486348
try {
6349-
return fs.existsSync(metaPath);
6349+
if (fs.existsSync(metaPath)) {
6350+
return true;
6351+
}
63506352
} catch (_) {
63516353
return false;
63526354
}
6355+
const base = path.basename(filePath || '', path.extname(filePath || ''));
6356+
return /-\d{8}-\d{6}-[0-9a-f]{6}$/i.test(base);
63536357
}
63546358

63556359
function resolveStateMaxMessages(state) {
@@ -6697,6 +6701,20 @@ async function readSessionDetail(params = {}) {
66976701
sessionId,
66986702
cwd: extracted.cwd || '',
66996703
updatedAt: extracted.updatedAt || '',
6704+
derived: (() => {
6705+
try {
6706+
const metaPath = filePath.toLowerCase().endsWith('.jsonl')
6707+
? `${filePath.slice(0, -5)}.meta.json`
6708+
: `${filePath}.meta.json`;
6709+
if (fs.existsSync(metaPath)) {
6710+
return true;
6711+
}
6712+
} catch (_) {
6713+
return false;
6714+
}
6715+
const base = path.basename(filePath || '', path.extname(filePath || ''));
6716+
return /-\d{8}-\d{6}-[0-9a-f]{6}$/i.test(base);
6717+
})(),
67006718
totalMessages: hasExactTotalMessages ? extracted.totalMessages : null,
67016719
clipped: typeof extracted.clipped === 'boolean'
67026720
? extracted.clipped

tests/unit/web-ui-behavior-parity.test.mjs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -487,6 +487,8 @@ test('captured bundled app skeleton only exposes expected data key drift versus
487487
'openClaudeMdEditor'
488488
];
489489
allowedExtraCurrentMethodKeys.push(
490+
'isDerivedSession',
491+
'isDerivedSessionId',
490492
'resetConfigTemplateDiffState',
491493
'onConfigTemplateContentInput',
492494
'buildConfigTemplateDiffFingerprint',

web-ui/modules/app.methods.session-actions.mjs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,24 @@ export function createSessionActionMethods(options = {}) {
1010
} = options;
1111

1212
return {
13+
isDerivedSessionId(value) {
14+
const sessionId = typeof value === 'string' ? value.trim() : String(value || '');
15+
if (!sessionId) return false;
16+
return /-\d{8}-\d{6}-[0-9a-f]{6}$/i.test(sessionId);
17+
},
18+
19+
isDerivedSession(session) {
20+
if (!session || typeof session !== 'object') return false;
21+
if (session.derived === true) return true;
22+
if (this.isDerivedSessionId(session.sessionId)) return true;
23+
const rawFilePath = typeof session.filePath === 'string' ? session.filePath.trim() : '';
24+
if (!rawFilePath) return false;
25+
const normalized = rawFilePath.replace(/\\/g, '/');
26+
if (normalized.includes('/.codexmate/sessions/derived/')) return true;
27+
if (normalized.includes('/codexmate-derived/')) return true;
28+
return false;
29+
},
30+
1331
getSessionStandaloneContext() {
1432
try {
1533
const url = new URL(window.location.href);

web-ui/partials/index/panel-sessions.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@
208208
<button
209209
class="btn-session-export"
210210
@click="convertSession(activeSession)"
211-
:disabled="!activeSession || activeSession.derived || sessionConverting[getSessionExportKey(activeSession)] || (activeSession.source !== 'codex' && activeSession.source !== 'claude')">
211+
:disabled="true">
212212
{{ (activeSession && sessionConverting[getSessionExportKey(activeSession)]) ? t('sessions.preview.converting') : t('sessions.preview.convert') }}
213213
</button>
214214
<button

web-ui/session-helpers.mjs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -422,6 +422,9 @@ export async function loadActiveSessionDetail(api, options = {}) {
422422
if (res.sourceLabel) {
423423
this.activeSession.sourceLabel = res.sourceLabel;
424424
}
425+
if (typeof res.derived === 'boolean') {
426+
this.activeSession.derived = res.derived;
427+
}
425428
if (res.sessionId) {
426429
this.activeSession.sessionId = res.sessionId;
427430
if (!this.activeSession.title) {

0 commit comments

Comments
 (0)