From 5fd3d4faac11915ace0d831d966db666f0b7c26f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Padez?= Date: Mon, 20 Jul 2026 23:46:15 +0000 Subject: [PATCH] file browser opens at home instead of restoring the last path Navigation is now session-local state that always starts at home. The unscoped browser still mirrors its folder into files/currentPath so the Create Dashboard flow keeps defaulting a new dashboard's cwd to it. Co-Authored-By: Claude Opus 4.8 --- .../FileBrowserApp/useFileBrowserApp.ts | 69 +++++++++++++------ 1 file changed, 48 insertions(+), 21 deletions(-) diff --git a/src/workspaces/officerdev/src/apps/FileBrowser/FileBrowserApp/useFileBrowserApp.ts b/src/workspaces/officerdev/src/apps/FileBrowser/FileBrowserApp/useFileBrowserApp.ts index 0c5035c5..9428880d 100644 --- a/src/workspaces/officerdev/src/apps/FileBrowser/FileBrowserApp/useFileBrowserApp.ts +++ b/src/workspaces/officerdev/src/apps/FileBrowser/FileBrowserApp/useFileBrowserApp.ts @@ -12,17 +12,27 @@ type DefaultSort = { direction: 'asc' | 'desc'; }; -export const useFileBrowserApp = (basePath: string, rootOverride?: string, initialPath?: string, defaultSort?: DefaultSort) => { +export const useFileBrowserApp = ( + basePath: string, + rootOverride?: string, + initialPath?: string, + defaultSort?: DefaultSort, +) => { const { user } = useAuth(); const navigate = useNavigate(); const [searchParams, setSearchParams] = useSearchParams(); const homeRoot = 'home'; - const [globalPath, setGlobalPath] = useUserState('files/currentPath', '/'); - const [localPath, setLocalPath] = useState(initialPath ?? basePath); + const [, setGlobalPath] = useUserState('files/currentPath', '/'); + const [currentPath, setLocalPath] = useState(initialPath ?? basePath); const scoped = basePath !== '/'; const isolated = !!initialPath; - const currentPath = (scoped || isolated) ? localPath : globalPath; - const setCurrentPath = (scoped || isolated) ? setLocalPath : setGlobalPath; + // Navigation is session-local — the browser always opens at home, never restoring the + // last path. The main (unscoped) browser still mirrors its folder into files/currentPath + // so the Create Dashboard flow can default a new dashboard's cwd to it. + const setCurrentPath = (path: string) => { + setLocalPath(path); + if (!scoped && !isolated) setGlobalPath(path); + }; const [entries, setEntries] = useState([]); const [rootDir, setRootDir] = useState(''); const [loading, setLoading] = useState(true); @@ -661,37 +671,55 @@ export const useFileBrowserApp = (basePath: string, rootOverride?: string, initi user, // Navigation homeRoot, - currentPath, setCurrentPath, + currentPath, + setCurrentPath, // Directory listing - visibleEntries, loading, refresh, + visibleEntries, + loading, + refresh, // View - viewMode, setViewMode, defaultSort, - showHidden, setShowHidden, hiddenForced, + viewMode, + setViewMode, + defaultSort, + showHidden, + setShowHidden, + hiddenForced, // Selection - selected, setSelected, + selected, + setSelected, clipboard, - renamingName, setRenamingName, + renamingName, + setRenamingName, // Search - searchQuery, setSearchQuery, - searchResults, searching, + searchQuery, + setSearchQuery, + searchResults, + searching, searchInputRef, // Upload uploadProgress, // Clone - showCloneInput, setShowCloneInput, - cloneUrl, setCloneUrl, + showCloneInput, + setShowCloneInput, + cloneUrl, + setCloneUrl, cloning, // Drag & drop dragging, // Task runner - runningTask, setRunningTask, + runningTask, + setRunningTask, getMatchingTasks, // Video download - showVideoDownload, setShowVideoDownload, - videoUrl, setVideoUrl, - audioOnly, setAudioOnly, + showVideoDownload, + setShowVideoDownload, + videoUrl, + setVideoUrl, + audioOnly, + setAudioOnly, // Dictate - showDictate, setShowDictate, + showDictate, + setShowDictate, // Refs fileScrollRef, // Handlers @@ -737,4 +765,3 @@ export type UseFileBrowserAppType = ReturnType; // ── Types ── type ClipboardState = { paths: string[]; mode: 'copy' | 'cut' } | null; -