take out the props the previous commit orphaned

`initialPath` and `defaultSort` reached `FileBrowserApp` from nowhere else — the panel wrapper was
their only caller, and it was passing the two context fields that had no setter. Both remaining
callers pass neither, so the whole chain below them was already running on its defaults.

That includes `isolated`, which was `!!initialPath` and therefore always false: the unscoped browser
has been mirroring its folder into `files/currentPath` unconditionally, which is what the comment
beside it describes. Same behaviour, one fewer flag that reads as if it sometimes fires.
This commit is contained in:
2026-08-07 09:35:03 +00:00
parent 717580f6e4
commit 585f234b5b
3 changed files with 7 additions and 27 deletions
@@ -8,20 +8,13 @@ import { VideoDownloadDialog } from './components/VideoDownloadDialog';
import { DictateDialog } from './components/DictateDialog';
import { useFileBrowserApp } from './useFileBrowserApp';
type DefaultSort = {
field: 'name' | 'size' | 'type' | 'date';
direction: 'asc' | 'desc';
};
type FileBrowserAppProps = {
basePath?: string;
rootOverride?: string;
initialPath?: string;
defaultSort?: DefaultSort;
};
export const FileBrowserApp = ({ basePath = '/', rootOverride, initialPath, defaultSort }: FileBrowserAppProps) => {
const fileBrowserManager = useFileBrowserApp(basePath, rootOverride, initialPath, defaultSort);
export const FileBrowserApp = ({ basePath = '/', rootOverride }: FileBrowserAppProps) => {
const fileBrowserManager = useFileBrowserApp(basePath, rootOverride);
const { handleNavigate } = fileBrowserManager;
return (
@@ -76,10 +76,9 @@ export const FileGrid = ({ fileBrowserManager }: FileGridProps) => {
setSearchQuery,
searchInputRef,
} = fileBrowserManager;
const { defaultSort } = fileBrowserManager;
const lastClickedIdx = useRef<number>(-1);
const [sortField, setSortField] = useState<SortField>(defaultSort?.field ?? 'name');
const [sortDirection, setSortDirection] = useState<SortDirection>(defaultSort?.direction ?? 'asc');
const [sortField, setSortField] = useState<SortField>('name');
const [sortDirection, setSortDirection] = useState<SortDirection>('asc');
const sorted = (() => {
const compare = (a: DirEntry, b: DirEntry): number => {
@@ -8,31 +8,20 @@ import { useUserState } from 'state/useUserState';
import { useAuth } from 'hooks/useAuth';
import { usePanelChannel } from 'hooks/usePanelChannel';
type DefaultSort = {
field: 'name' | 'size' | 'type' | 'date';
direction: 'asc' | 'desc';
};
export const useFileBrowserApp = (
basePath: string,
rootOverride?: string,
initialPath?: string,
defaultSort?: DefaultSort,
) => {
export const useFileBrowserApp = (basePath: string, rootOverride?: string) => {
const { user } = useAuth();
const navigate = useNavigate();
const [searchParams, setSearchParams] = useSearchParams();
const homeRoot = 'home';
const [, setGlobalPath] = useUserState<string>('files/currentPath', '/');
const [currentPath, setLocalPath] = useState(initialPath ?? basePath);
const [currentPath, setLocalPath] = useState(basePath);
const scoped = basePath !== '/';
const isolated = !!initialPath;
// 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);
if (!scoped) setGlobalPath(path);
};
const [entries, setEntries] = useState<DirEntry[]>([]);
const [rootDir, setRootDir] = useState('');
@@ -639,7 +628,6 @@ export const useFileBrowserApp = (
// View
viewMode,
setViewMode,
defaultSort,
showHidden,
setShowHidden,
hiddenForced,