From 2be4430d57db88da31d46f65bd233eb3b1552511 Mon Sep 17 00:00:00 2001 From: Neil <4138956+nwparker@users.noreply.github.com> Date: Sun, 31 May 2026 09:48:34 -0700 Subject: [PATCH] perf: move pr link copy cleanup to button ref --- src/renderer/src/components/PullRequestPage.tsx | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/renderer/src/components/PullRequestPage.tsx b/src/renderer/src/components/PullRequestPage.tsx index 18dac2c4d..a41ae4d8a 100644 --- a/src/renderer/src/components/PullRequestPage.tsx +++ b/src/renderer/src/components/PullRequestPage.tsx @@ -5410,17 +5410,23 @@ export default function PullRequestPage({ window.clearTimeout(linkCopiedResetTimerRef.current) linkCopiedResetTimerRef.current = null }, []) - const setLinkCopyButtonRef = useCallback((node: HTMLButtonElement | null) => { - linkCopyMountedRef.current = node !== null - }, []) + const setLinkCopyButtonRef = useCallback( + (node: HTMLButtonElement | null) => { + linkCopyMountedRef.current = node !== null + if (node === null) { + // Why: the copied-state timer belongs to the copy control surface; + // clear it when that surface detaches without a passive cleanup Effect. + clearLinkCopiedResetTimer() + } + }, + [clearLinkCopiedResetTimer] + ) useEffect(() => { clearLinkCopiedResetTimer() setLinkCopied(false) }, [clearLinkCopiedResetTimer, workItemId]) - useEffect(() => clearLinkCopiedResetTimer, [clearLinkCopiedResetTimer]) - const handleCopyWorkItemLink = useCallback(async (): Promise => { if (!workItem) { return