Skip to content

Commit dd612b6

Browse files
voltcrashclaude
andcommitted
fix(web): refresh only environments a bulk archive action reached
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
1 parent 5c91426 commit dd612b6

2 files changed

Lines changed: 5 additions & 3 deletions

File tree

‎apps/web/src/hooks/useThreadActions.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ describe("runArchivedThreadBatch", () => {
4949
await expect(runArchivedThreadBatch(targets, run)).resolves.toBeNull();
5050

5151
expect(run).toHaveBeenCalledOnce();
52-
expect(refreshArchivedThreadsForEnvironment).toHaveBeenCalledTimes(2);
52+
expect(vi.mocked(refreshArchivedThreadsForEnvironment).mock.calls).toEqual([[local]]);
5353
});
5454
});
5555

‎apps/web/src/hooks/useThreadActions.ts‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ export async function navigateAfterThreadDeletion(navigate: () => Promise<void>)
196196
}
197197

198198
/**
199-
* Runs one command per archived thread in order, then refreshes each touched
199+
* Runs one command per archived thread in order, then refreshes each reached
200200
* environment's archive once instead of once per thread. Stops at the first
201201
* interruption and reports the first failure.
202202
*/
@@ -205,13 +205,15 @@ export async function runArchivedThreadBatch(
205205
run: (target: ScopedThreadRef) => Promise<AtomCommandResult<unknown, unknown>>,
206206
) {
207207
let firstFailure: AsyncResult.Failure<unknown, unknown> | null = null;
208+
const reachedEnvironmentIds = new Set<EnvironmentId>();
208209
for (const target of targets) {
210+
reachedEnvironmentIds.add(target.environmentId);
209211
const result = await run(target);
210212
if (result._tag === "Success") continue;
211213
if (isAtomCommandInterrupted(result)) break;
212214
firstFailure ??= result;
213215
}
214-
for (const environmentId of new Set(targets.map((target) => target.environmentId))) {
216+
for (const environmentId of reachedEnvironmentIds) {
215217
refreshArchivedThreadsForEnvironment(environmentId);
216218
}
217219
return firstFailure;

0 commit comments

Comments
 (0)