Skip to content

Commit 04f46ca

Browse files
saltboCopilot
andcommitted
fix(daemon): exclude closed sessions from stale cleanup and audit
cleanupStaleSessions was treating 'closed' worker sessions as stale, calling closeSession on an already-closed server session and deleting the local file. auditOrphanedTasks was also making unnecessary API calls for closed sessions. Exclude closed sessions from both paths — they are intentionally retained on disk for tunnel history lookups. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 91dc036 commit 04f46ca

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

packages/cli/src/daemon/cleanup.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,9 @@ export async function cleanupStaleSessions(client: MachineClient, machineId: str
5050
// orphaned at boot time (no live handle can exist yet).
5151
// Leader sessions: pid liveness.
5252
if (local?.type === "worker") {
53-
if (local.status === "in_review") continue;
53+
// in_review survives restarts (reject-resume entry point).
54+
// closed sessions are intentionally retained for history lookup — skip.
55+
if (local.status === "in_review" || local.status === "closed") continue;
5456
} else if (local?.type === "leader") {
5557
if (isPidAlive(local.pid)) continue;
5658
}
@@ -79,7 +81,7 @@ export async function cleanupStaleSessions(client: MachineClient, machineId: str
7981
// the right action depends on context (release vs cancel vs manual merge).
8082
export async function auditOrphanedTasks(client: MachineClient, _machineId: string): Promise<void> {
8183
try {
82-
const workers = listSessions({ type: "worker" });
84+
const workers = listSessions({ type: "worker" }).filter((s) => s.status !== "closed");
8385
let resumeQueued = 0;
8486
let diverged = 0;
8587

0 commit comments

Comments
 (0)