Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/session/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -244,15 +244,18 @@ export async function listSessions(cwd: string, home: string = homedir()): Promi
});
continue;
}
// TUI sessions persist conversation under context/ before run.json exists.
// A session directory with context/ but no readable run.json never
// reached its first saveState call (see src/tui/runner.ts's early
// "running" write) and therefore isn't actually running: report it as
// crashed rather than fabricating liveness.
try {
const dirStat = await stat(sessionDir(cwd, entry, home));
await stat(sessionContextDir(cwd, entry, home));
summaries.push({
sessionId: entry,
task: "(conversation)",
startedAt: dirStat.birthtimeMs > 0 ? dirStat.birthtimeMs : dirStat.mtimeMs,
status: "running",
status: "crashed",
});
} catch {
// Not a resumable session directory.
Expand Down
9 changes: 9 additions & 0 deletions src/session/list-sessions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,15 @@ test("listSessions includes TUI sessions with context/ but no run.json", async (
expect(row?.task).toBe("Untitled session");
});

test("listSessions reports crashed, not running, for a session with no readable run.json", async () => {
const sessionId = generateSessionId();
await initSessionDir(cwd, sessionId, home);
const listed = await listSessions(cwd, home);
const row = listed.find((s) => s.sessionId === sessionId);
expect(row?.status).not.toBe("running");
expect(row?.status).toBe("crashed");
});

test("listSessions prefers run.json task title when present", async () => {
const sessionId = generateSessionId();
await initSessionDir(cwd, sessionId, home);
Expand Down
Loading