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) => (