mirror of
https://github.com/affaan-m/everything-claude-code.git
synced 2026-04-22 18:13:41 +08:00
review: apply sanitizeSessionId to UUID shortId, fix test comment
- Route the transcript-derived shortId through sanitizeSessionId so the fallback and transcript branches remain byte-for-byte equivalent for any non-UUID session IDs that still land in CLAUDE_SESSION_ID (greptile P1). - Clarify the inline comment in the first regression test: clearing CLAUDE_SESSION_ID exercises the transcript_path branch, not the getSessionIdShort() fallback (coderabbit P2). Refs #1494
This commit is contained in:
@@ -16,6 +16,7 @@ const {
|
|||||||
getDateString,
|
getDateString,
|
||||||
getTimeString,
|
getTimeString,
|
||||||
getSessionIdShort,
|
getSessionIdShort,
|
||||||
|
sanitizeSessionId,
|
||||||
getProjectName,
|
getProjectName,
|
||||||
ensureDir,
|
ensureDir,
|
||||||
readFile,
|
readFile,
|
||||||
@@ -202,7 +203,11 @@ async function main() {
|
|||||||
let shortId = null;
|
let shortId = null;
|
||||||
if (transcriptPath) {
|
if (transcriptPath) {
|
||||||
const m = path.basename(transcriptPath).match(/([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})\.jsonl$/i);
|
const m = path.basename(transcriptPath).match(/([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})\.jsonl$/i);
|
||||||
if (m) { shortId = m[1].slice(-8).toLowerCase(); }
|
if (m) {
|
||||||
|
// Run through sanitizeSessionId() for byte-for-byte parity with
|
||||||
|
// getSessionIdShort(sessionId.slice(-8)).
|
||||||
|
shortId = sanitizeSessionId(m[1].slice(-8).toLowerCase());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (!shortId) { shortId = getSessionIdShort(); }
|
if (!shortId) { shortId = getSessionIdShort(); }
|
||||||
const sessionFile = path.join(sessionsDir, `${today}-${shortId}-session.tmp`);
|
const sessionFile = path.join(sessionsDir, `${today}-${shortId}-session.tmp`);
|
||||||
|
|||||||
@@ -651,8 +651,10 @@ async function runTests() {
|
|||||||
await runScript(path.join(scriptsDir, 'session-end.js'), stdinJson, {
|
await runScript(path.join(scriptsDir, 'session-end.js'), stdinJson, {
|
||||||
HOME: isoHome,
|
HOME: isoHome,
|
||||||
USERPROFILE: isoHome,
|
USERPROFILE: isoHome,
|
||||||
// Explicitly clear CLAUDE_SESSION_ID so parent env does not leak in and
|
// Clear CLAUDE_SESSION_ID so parent-process env does not leak into the
|
||||||
// force the getSessionIdShort() fallback instead of the transcript path.
|
// child and the test deterministically exercises the transcript_path
|
||||||
|
// branch (getSessionIdShort() is the alternative path that is not
|
||||||
|
// exercised here).
|
||||||
CLAUDE_SESSION_ID: ''
|
CLAUDE_SESSION_ID: ''
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user