From 164139bafc331fdd73d8feddb6c02983dd4fa267 Mon Sep 17 00:00:00 2001 From: Neil <4138956+nwparker@users.noreply.github.com> Date: Fri, 29 May 2026 22:42:34 -0700 Subject: [PATCH] fix: share remote file browser timer cleanup --- .../src/components/sidebar/RemoteFileBrowser.tsx | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/renderer/src/components/sidebar/RemoteFileBrowser.tsx b/src/renderer/src/components/sidebar/RemoteFileBrowser.tsx index 24dbd78e884..ddf92ed9326 100644 --- a/src/renderer/src/components/sidebar/RemoteFileBrowser.tsx +++ b/src/renderer/src/components/sidebar/RemoteFileBrowser.tsx @@ -61,6 +61,7 @@ export function RemoteFileBrowser({ // Why: paste resolution intentionally runs next tick; closing the picker // before then should cancel stale preview work. const pasteResolveTimerRef = useRef | null>(null) + const clickTimerRef = useRef | null>(null) // Cache directory listings by absolute resolved path for the lifetime of // the picker so ordinary typing issues at most one remote call per newly // committed segment. targetId does not change within a picker instance. @@ -101,6 +102,10 @@ export function RemoteFileBrowser({ clearTimeout(pasteResolveTimerRef.current) pasteResolveTimerRef.current = null } + if (clickTimerRef.current) { + clearTimeout(clickTimerRef.current) + clickTimerRef.current = null + } } }, [invalidateBrowseRequests]) @@ -423,15 +428,6 @@ export function RemoteFileBrowser({ }, [resolvedPath, onSelect]) // Single-click navigates; double-click on a folder selects it. - const clickTimerRef = useRef | null>(null) - useEffect(() => { - return () => { - if (clickTimerRef.current) { - clearTimeout(clickTimerRef.current) - } - } - }, []) - // When preview is active, row clicks must be relative to the preview path, // not the committed `resolvedPath`. const listParentPath = preview?.resolvedPath ?? resolvedPath