Skip to content

Commit 3d1bc83

Browse files
Merge pull request #396 from corbitsdev/cl-5672-listsessions-fabricates-status-running-forever
Stop reporting crashed sessions as running forever
2 parents 360a999 + e9cf1f1 commit 3d1bc83

2 files changed

Lines changed: 14 additions & 2 deletions

File tree

‎src/session/index.ts‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,15 +244,18 @@ export async function listSessions(cwd: string, home: string = homedir()): Promi
244244
});
245245
continue;
246246
}
247-
// TUI sessions persist conversation under context/ before run.json exists.
247+
// A session directory with context/ but no readable run.json never
248+
// reached its first saveState call (see src/tui/runner.ts's early
249+
// "running" write) and therefore isn't actually running: report it as
250+
// crashed rather than fabricating liveness.
248251
try {
249252
const dirStat = await stat(sessionDir(cwd, entry, home));
250253
await stat(sessionContextDir(cwd, entry, home));
251254
summaries.push({
252255
sessionId: entry,
253256
task: "(conversation)",
254257
startedAt: dirStat.birthtimeMs > 0 ? dirStat.birthtimeMs : dirStat.mtimeMs,
255-
status: "running",
258+
status: "crashed",
256259
});
257260
} catch {
258261
// Not a resumable session directory.

‎src/session/list-sessions.test.ts‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,15 @@ test("listSessions includes TUI sessions with context/ but no run.json", async (
3030
expect(row?.task).toBe("Untitled session");
3131
});
3232

33+
test("listSessions reports crashed, not running, for a session with no readable run.json", async () => {
34+
const sessionId = generateSessionId();
35+
await initSessionDir(cwd, sessionId, home);
36+
const listed = await listSessions(cwd, home);
37+
const row = listed.find((s) => s.sessionId === sessionId);
38+
expect(row?.status).not.toBe("running");
39+
expect(row?.status).toBe("crashed");
40+
});
41+
3342
test("listSessions prefers run.json task title when present", async () => {
3443
const sessionId = generateSessionId();
3544
await initSessionDir(cwd, sessionId, home);

0 commit comments

Comments
 (0)