From e330feb1318824e8b3fad04406d91c1610b355a5 Mon Sep 17 00:00:00 2001 From: Neil <4138956+nwparker@users.noreply.github.com> Date: Sat, 30 May 2026 00:15:47 -0700 Subject: [PATCH] fix: clear source copy mounted guards from refs (#3516) --- .../right-sidebar/SourceControl.tsx | 23 +++++++------------ 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/src/renderer/src/components/right-sidebar/SourceControl.tsx b/src/renderer/src/components/right-sidebar/SourceControl.tsx index 568462d30..35e29ae62 100644 --- a/src/renderer/src/components/right-sidebar/SourceControl.tsx +++ b/src/renderer/src/components/right-sidebar/SourceControl.tsx @@ -1033,16 +1033,13 @@ function SourceControlInner(): React.JSX.Element { // Why: clipboard IPC can resolve after Source Control unmounts; skip copied // feedback instead of starting a reset timer on a stale panel. const diffCommentsCopyMountedRef = useRef(false) - - useEffect(() => { - return () => cancelSourceControlEditorRevealFrames(pendingCommentEditorRevealFrameIdsRef) + const setSourceControlRootRef = useCallback((node: HTMLDivElement | null) => { + sourceControlRef.current = node + diffCommentsCopyMountedRef.current = node !== null }, []) useEffect(() => { - diffCommentsCopyMountedRef.current = true - return () => { - diffCommentsCopyMountedRef.current = false - } + return () => cancelSourceControlEditorRevealFrames(pendingCommentEditorRevealFrameIdsRef) }, []) const handleCopyDiffComments = useCallback(async (): Promise => { @@ -3939,7 +3936,7 @@ function SourceControlInner(): React.JSX.Element { return ( <> -
+
{(['all', 'uncommitted'] as const).map((value) => (