From 9ea6af17315cf1d0151a2dd78c8eb60dbb5d0994 Mon Sep 17 00:00:00 2001 From: Jaime Idolpx Date: Sun, 7 Jun 2026 23:26:07 -0400 Subject: [PATCH] feat(FileManager): persist file manager path in local storage for improved navigation --- src/app/components/FileManager.tsx | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/app/components/FileManager.tsx b/src/app/components/FileManager.tsx index dcbd75a..f406c33 100644 --- a/src/app/components/FileManager.tsx +++ b/src/app/components/FileManager.tsx @@ -252,8 +252,10 @@ interface FileManagerProps { // ─── Main component ─────────────────────────────────────────────────────────── +const FM_PATH_KEY = 'fileManager.path'; + export default function FileManager({ initialPath = '/', config, setConfig, onBack }: FileManagerProps) { - const [path, setPath] = useState(normalizePath(initialPath)); + const [path, setPath] = useState(() => normalizePath(localStorage.getItem(FM_PATH_KEY) || initialPath)); const [entries, setEntries] = useState([]); const [loading, setLoading] = useState(false); const [error, setError] = useState(null); @@ -303,7 +305,12 @@ export default function FileManager({ initialPath = '/', config, setConfig, onBa useEffect(() => { void load(path); }, [path, load]); - const navigateTo = (p: string) => { setPath(normalizePath(p)); setFilter(''); }; + const navigateTo = (p: string) => { + const norm = normalizePath(p); + localStorage.setItem(FM_PATH_KEY, norm); + setPath(norm); + setFilter(''); + }; const navigateUp = () => { if (path !== '/') navigateTo(splitPath(path).parent); }; // ── Sort + filter ──────────────────────────────────────────────────────── @@ -862,7 +869,7 @@ export default function FileManager({ initialPath = '/', config, setConfig, onBa )} - {actionEntry?.type === 'file' && fileCategory(actionEntry) === 'disk' && ( + {actionEntry?.type === 'file' && (