fix: honor the terminal file browser filesystem root instead of clamping to home (#29006)

This commit is contained in:
G30
2026-08-24 17:55:51 -05:00
committed by GitHub
parent 5735123f50
commit e6648aefb5
+6 -27
View File
@@ -629,35 +629,14 @@
return isInsideFileRoot(path) ? asDirectoryPath(path) : fileRoot.path; return isInsideFileRoot(path) ? asDirectoryPath(path) : fileRoot.path;
}; };
const rootFromCwd = (cwd: TerminalCwd | null, pathHint?: string) => { const rootFromCwd = (cwd: TerminalCwd | null) => {
const cwdPath = cwd?.cwd ? asDirectoryPath(cwd.cwd) : null;
const homePath = cwd?.home ? asDirectoryPath(cwd.home) : null;
const hintPath = pathHint ? asDirectoryPath(pathHint) : null;
const rootPath = cwd?.root?.path ? asDirectoryPath(cwd.root.path) : null; const rootPath = cwd?.root?.path ? asDirectoryPath(cwd.root.path) : null;
return rootPath && rootPath !== '/' ? cwd?.root : undefined;
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 && pathForHome && (pathForHome === homePath || pathForHome.startsWith(homePath))) {
return { path: homePath, label: 'Home' };
}
return undefined;
}; };
const applyCwd = (cwd: TerminalCwd | null, pathHint?: string) => { const applyCwd = (cwd: TerminalCwd | null) => {
const cwdPath = cwd?.cwd ? asDirectoryPath(cwd.cwd) : null; const cwdPath = cwd?.cwd ? asDirectoryPath(cwd.cwd) : null;
setFileRoot(rootFromCwd(cwd, pathHint)); setFileRoot(rootFromCwd(cwd));
const path = cwdPath ?? fileRoot?.path ?? '/'; const path = cwdPath ?? fileRoot?.path ?? '/';
return clampToFileRoot(path); return clampToFileRoot(path);
}; };
@@ -1385,7 +1364,7 @@
const serverCwd = await getCwd(terminal.url, terminal.key, chatId ?? undefined); const serverCwd = await getCwd(terminal.url, terminal.key, chatId ?? undefined);
const useServerPath = !!chatId || savedPath === '/'; const useServerPath = !!chatId || savedPath === '/';
const serverPath = applyCwd(serverCwd, useServerPath ? undefined : savedPath); const serverPath = applyCwd(serverCwd);
if (useServerPath) { if (useServerPath) {
// Fetch session-specific cwd from the server (or global default for new chats) // Fetch session-specific cwd from the server (or global default for new chats)
savedPath = serverPath; savedPath = serverPath;
@@ -1911,7 +1890,7 @@
</div> </div>
{/if} {/if}
{#if !isSearching && !loading && !error && !uploading && !($selectedTerminalId && $terminalServers === null)} {#if !isSearching && !loading && !error && !uploading && !($selectedTerminalId && $terminalServers === null)}
{#if creatingFolder} {#if creatingFolder}
<div class="flex h-7 items-center gap-2 px-2"> <div class="flex h-7 items-center gap-2 px-2">
<FileTypeIcon name={newFolderName} type="directory" /> <FileTypeIcon name={newFolderName} type="directory" />