fix: guard work item link copy feedback (#3509)

This commit is contained in:
Neil
2026-05-30 00:03:26 -07:00
committed by GitHub
parent 6760be4edf
commit 504b98d873
2 changed files with 26 additions and 0 deletions
@@ -5440,6 +5440,16 @@ export default function GitHubItemDialog({
const files = details?.files ?? []
const checks = details?.checks ?? []
const [pendingViewedPaths, setPendingViewedPaths] = useState<Set<string>>(() => 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 {
@@ -5325,6 +5325,16 @@ export default function PullRequestPage({
const files = details?.files ?? []
const checks = details?.checks ?? []
const [pendingViewedPaths, setPendingViewedPaths] = useState<Set<string>>(() => 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 {