diff --git a/src/lib/components/chat/FileNav.svelte b/src/lib/components/chat/FileNav.svelte index 486a1182f4..0f7e5cd833 100644 --- a/src/lib/components/chat/FileNav.svelte +++ b/src/lib/components/chat/FileNav.svelte @@ -1,6 +1,7 @@ @@ -92,7 +93,7 @@ // ── Directory state ────────────────────────────────────────────────── let currentPath = savedPath; - let fileRoot: TerminalFileRoot | null = null; + let fileRoot: TerminalFileRoot | null = savedFileRoot; let entries: FileEntry[] = []; let currentWritable = true; let loading = false; @@ -463,6 +464,7 @@ label: root.label || labelFromPath(root.path) } : null; + savedFileRoot = fileRoot; if ((fileRoot?.path ?? null) !== previousRoot) resetTreeState(); }; @@ -485,6 +487,16 @@ if (rootPath && rootPath !== '/') return cwd?.root; + const knownRoot = fileRoot ?? savedFileRoot; + if ( + knownRoot?.path && + hintPath && + hintPath !== '/' && + (hintPath === knownRoot.path || hintPath.startsWith(knownRoot.path)) + ) { + return knownRoot; + } + const pathForHome = hintPath && hintPath !== '/' ? hintPath : cwdPath; if ( homePath &&