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 <noreply@anthropic.com>
This commit is contained in:
2026-07-20 23:46:15 +00:00
co-authored by Claude Opus 4.8
parent 82d0e9afd6
commit 5fd3d4faac
@@ -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<string>('files/currentPath', '/');
const [localPath, setLocalPath] = useState(initialPath ?? basePath);
const [, setGlobalPath] = useUserState<string>('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<DirEntry[]>([]);
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<typeof useFileBrowserApp>;
// ── Types ──
type ClipboardState = { paths: string[]; mode: 'copy' | 'cut' } | null;