diff --git a/src/resources/extensions/gsd/interrupted-session.ts b/src/resources/extensions/gsd/interrupted-session.ts index 679983cf9e..043b59cd2d 100644 --- a/src/resources/extensions/gsd/interrupted-session.ts +++ b/src/resources/extensions/gsd/interrupted-session.ts @@ -128,8 +128,7 @@ export async function assessInterruptedSession( ? existsSync(pausedSession.worktreePath) : false; const assessmentBasePath = worktreeExists ? pausedSession!.worktreePath! : basePath; - const rawLock = readCrashLock(basePath); - const lock = rawLock && rawLock.pid !== process.pid ? rawLock : null; + const lock = readCrashLock(basePath); if (!lock && !pausedSession) { return { @@ -146,7 +145,7 @@ export async function assessInterruptedSession( }; } - if (lock && isLockProcessAlive(lock)) { + if (lock && lock.pid !== process.pid && isLockProcessAlive(lock)) { return { classification: "running", lock, diff --git a/src/resources/extensions/gsd/tests/interrupted-session-auto.test.ts b/src/resources/extensions/gsd/tests/interrupted-session-auto.test.ts index 1a76da758b..23f9d201e7 100644 --- a/src/resources/extensions/gsd/tests/interrupted-session-auto.test.ts +++ b/src/resources/extensions/gsd/tests/interrupted-session-auto.test.ts @@ -186,6 +186,14 @@ test("direct /gsd auto source only resumes paused-session metadata for recoverab assert.ok(source.includes('|| !!freshStartAssessment.lock')); }); +test("interrupted-session source preserves raw lock and excludes same-pid from running classification", async () => { + const source = await import(`node:fs/promises`).then((fs) => + fs.readFile(new URL("../interrupted-session.ts", import.meta.url), "utf-8") + ); + assert.ok(source.includes('const lock = readCrashLock(basePath);')); + assert.ok(source.includes('if (lock && lock.pid !== process.pid && isLockProcessAlive(lock)) {')); +}); + test("auto module imports successfully after interrupted-session changes", async () => { const mod = await import(`../auto.ts?ts=${Date.now()}-${Math.random()}`); assert.equal(typeof mod.startAuto, "function");