From 504b98d873addc5915fe289b2e4e12ac883ce8fa Mon Sep 17 00:00:00 2001 From: Neil <4138956+nwparker@users.noreply.github.com> Date: Sat, 30 May 2026 00:03:26 -0700 Subject: [PATCH] fix: guard work item link copy feedback (#3509) --- src/renderer/src/components/GitHubItemDialog.tsx | 13 +++++++++++++ src/renderer/src/components/PullRequestPage.tsx | 13 +++++++++++++ 2 files changed, 26 insertions(+) diff --git a/src/renderer/src/components/GitHubItemDialog.tsx b/src/renderer/src/components/GitHubItemDialog.tsx index 8144b3bbc45..c4088335df6 100644 --- a/src/renderer/src/components/GitHubItemDialog.tsx +++ b/src/renderer/src/components/GitHubItemDialog.tsx @@ -5440,6 +5440,16 @@ export default function GitHubItemDialog({ const files = details?.files ?? [] const checks = details?.checks ?? [] const [pendingViewedPaths, setPendingViewedPaths] = useState>(() => new Set()) + // Why: clipboard IPC can resolve after the dialog unmounts; skip copied-state + // feedback instead of starting its reset timer on a stale surface. + const linkCopyMountedRef = useRef(false) + + useEffect(() => { + linkCopyMountedRef.current = true + return () => { + linkCopyMountedRef.current = false + } + }, []) useEffect(() => { setLinkCopied(false) @@ -5461,6 +5471,9 @@ export default function GitHubItemDialog({ // Why: Electron's clipboard IPC is reliable even when browser clipboard // APIs lose focus/activation inside nested overlay surfaces. await window.api.ui.writeClipboardText(workItem.url) + if (!linkCopyMountedRef.current) { + return + } setLinkCopied(true) toast.success('GitHub link copied') } catch { diff --git a/src/renderer/src/components/PullRequestPage.tsx b/src/renderer/src/components/PullRequestPage.tsx index 1ac3c4ce549..195d3b72cd5 100644 --- a/src/renderer/src/components/PullRequestPage.tsx +++ b/src/renderer/src/components/PullRequestPage.tsx @@ -5325,6 +5325,16 @@ export default function PullRequestPage({ const files = details?.files ?? [] const checks = details?.checks ?? [] const [pendingViewedPaths, setPendingViewedPaths] = useState>(() => new Set()) + // Why: clipboard IPC can resolve after the page unmounts; skip copied-state + // feedback instead of starting its reset timer on a stale surface. + const linkCopyMountedRef = useRef(false) + + useEffect(() => { + linkCopyMountedRef.current = true + return () => { + linkCopyMountedRef.current = false + } + }, []) useEffect(() => { setLinkCopied(false) @@ -5346,6 +5356,9 @@ export default function PullRequestPage({ // Why: Electron's clipboard IPC is reliable even when browser clipboard // APIs lose focus/activation inside nested overlay surfaces. await window.api.ui.writeClipboardText(workItem.url) + if (!linkCopyMountedRef.current) { + return + } setLinkCopied(true) toast.success('GitHub link copied') } catch {