Skip to content

Commit 85de9a7

Browse files
saphidclaude
andcommitted
fix(web): a failed family read no longer blocks deleting a thread
Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 74df5f4 commit 85de9a7

2 files changed

Lines changed: 16 additions & 3 deletions

File tree

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

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ function deferred<T>() {
2525

2626
const state = vi.hoisted(() => ({
2727
serverConfig: { shellThreadFamilies: false },
28+
familyLookupFails: false,
2829
scopes: new Map<string, Set<string>>(),
2930
threads: [] as {
3031
environmentId: EnvironmentId;
@@ -78,7 +79,9 @@ vi.mock("../state/use-atom-command", () => ({
7879
vi.mock("../state/use-atom-query-runner", () => ({
7980
useAtomQueryRunner: (family: unknown) => async (environmentId: string) =>
8081
family === "threadFamily"
81-
? AsyncResult.success({ threads: state.familyThreads })
82+
? state.familyLookupFails
83+
? AsyncResult.failure(Cause.fail(new Error("Family lookup failed")))
84+
: AsyncResult.success({ threads: state.familyThreads })
8285
: state.sessionLookupFails
8386
? AsyncResult.failure(Cause.fail(new Error("Session lookup failed")))
8487
: AsyncResult.success({
@@ -249,6 +252,7 @@ const operations = [
249252

250253
beforeEach(() => {
251254
state.serverConfig.shellThreadFamilies = false;
255+
state.familyLookupFails = false;
252256
state.familyThreads = [];
253257
state.scopes = new Map([
254258
[primary, new Set([AuthOrchestrationOperateScope])],
@@ -366,6 +370,16 @@ describe("thread action permissions", () => {
366370
);
367371
expect(state.localEffects).not.toContain("clear-draft:fork");
368372
expect(state.localEffects).not.toContain("clear-draft:other-side-chat");
373+
374+
// The family read only finds drafts to clear; it never blocks the delete.
375+
state.familyLookupFails = true;
376+
state.requests = [];
377+
state.localEffects = [];
378+
expect((await actions.deleteThread(target))._tag).toBe("Success");
379+
expect(state.requests).toEqual([
380+
expect.objectContaining({ action: "delete", environmentId: secondary }),
381+
]);
382+
expect(state.localEffects).toContain("clear-draft:thread");
369383
});
370384

371385
it("stops before delete and local cleanup when permission is revoked during session stop", async () => {

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -456,8 +456,7 @@ export function useThreadActions() {
456456
environmentId: target.environmentId,
457457
input: { threadId: target.threadId },
458458
});
459-
if (family._tag === "Failure") return family;
460-
threads = [...family.value.threads];
459+
if (family._tag === "Success") threads = [...family.value.threads];
461460
}
462461
const result = await deleteThreadMutation({
463462
environmentId: target.environmentId,

0 commit comments

Comments
 (0)