Skip to content

Commit 904c4ef

Browse files
committed
fix(server): preserve stopped-session cleanup after main merge
1 parent 6461453 commit 904c4ef

2 files changed

Lines changed: 7 additions & 3 deletions

File tree

‎apps/server/src/storageCleanup.test.ts‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1757,6 +1757,10 @@ describe("storage cleanup reports and local file policies", () => {
17571757
worktreeOnDelete,
17581758
});
17591759
fixture.setThreads([]);
1760+
fixture.setDeletedThreads([
1761+
shell({ branch: "feature", worktreePath: fixture.worktree, deletedAt: at(0) }),
1762+
]);
1763+
yield* fixture.fs.writeFileString(`${fixture.worktree}/tracked.txt`, "agent edit\n");
17601764
const events = yield* Queue.unbounded<{
17611765
readonly event: OrchestrationV2DomainEvent;
17621766
readonly processed: Deferred.Deferred<void>;
@@ -1827,7 +1831,7 @@ describe("storage cleanup reports and local file policies", () => {
18271831

18281832
yield* publish(sessionUpdated("stopped", ""));
18291833
expect(fixture.snapshotReads()).toBe(startupReads + 2 * Number(worktreeOnDelete));
1830-
expect(fixture.sessionLiveChecks()).toBe(worktreeOnDelete ? 7 : 0);
1834+
expect(fixture.sessionLiveChecks()).toBe(worktreeOnDelete ? 6 : 0);
18311835

18321836
fixture.setSessionLive(true);
18331837
yield* publish({
@@ -1838,7 +1842,7 @@ describe("storage cleanup reports and local file policies", () => {
18381842
payload: { ...shell({ deletedAt: at(0) }), lastVisitedAt: null },
18391843
});
18401844
expect(fixture.snapshotReads()).toBe(startupReads + 3 * Number(worktreeOnDelete));
1841-
expect(fixture.sessionLiveChecks()).toBe(worktreeOnDelete ? 7 : 0);
1845+
expect(fixture.sessionLiveChecks()).toBe(worktreeOnDelete ? 6 : 0);
18421846
}),
18431847
),
18441848
);

‎apps/server/src/storageCleanup.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1340,7 +1340,7 @@ const make = Effect.gen(function* () {
13401340
return Effect.void;
13411341
}
13421342
if (!anyWorktreePolicy(lastSettings, (rules) => rules.worktreeOnDelete)) return Effect.void;
1343-
return event.type === "provider-session.updated"
1343+
return event.type === "provider-session.updated" && event.payload.status === "error"
13441344
? providerSessions
13451345
.isLive(event.payload.id)
13461346
.pipe(Effect.flatMap((live) => (live ? Effect.void : requestSweep)))

0 commit comments

Comments
 (0)