Skip to content

Commit 8ffe863

Browse files
TonybynMp4claude
andcommitted
fix(web): free resolved-thread snapshots once activity refreshes
Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent a1dc160 commit 8ffe863

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

‎apps/web/src/components/pullRequest/PullRequestResolveThreadButton.tsx‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ import { useAtomCommand } from "~/state/use-atom-command";
1313
import { Button } from "../ui/button";
1414
import { toastManager } from "../ui/toast";
1515

16-
type Sent = PullRequestDetailView["reviewThreads"] | "pending";
16+
// Weak so a snapshot is freed once refreshed activity replaces it in `detail`.
17+
type Sent = WeakRef<PullRequestDetailView["reviewThreads"]> | "pending";
1718

1819
// Outlives the button, which unmounts when its thread collapses, so reopening it mid-request
1920
// cannot send a second one.
@@ -51,7 +52,7 @@ export function PullRequestResolveThreadButton({
5152
// which can land before activity does and would re-enable the button on the old label.
5253
const key = `${environmentId}:${thread.id}`;
5354
const sent = useSyncExternalStore(subscribeSent, () => sentByThread.get(key));
54-
const waiting = sent === "pending" || sent === detail.reviewThreads;
55+
const waiting = sent === "pending" || sent?.deref() === detail.reviewThreads;
5556
const setThreadResolution = useAtomCommand(pullRequestEnvironment.setThreadResolution, {
5657
reportFailure: false,
5758
});
@@ -70,7 +71,7 @@ export function PullRequestResolveThreadButton({
7071
toastManager.add({ type: "error", title: "The conversation could not be updated" });
7172
return;
7273
}
73-
setSentFor(key, detail.reviewThreads);
74+
setSentFor(key, new WeakRef(detail.reviewThreads));
7475
onRefresh();
7576
};
7677

0 commit comments

Comments
 (0)