refac
This commit is contained in:
@@ -465,11 +465,14 @@
|
||||
return isInsideFileRoot(path) ? asDirectoryPath(path) : fileRoot.path;
|
||||
};
|
||||
|
||||
const applyCwd = (cwd: TerminalCwd | null) => {
|
||||
const applyCwd = (cwd: TerminalCwd | null, preferredPath?: string) => {
|
||||
const cwdPath = cwd?.cwd ? asDirectoryPath(cwd.cwd) : null;
|
||||
const homePath = cwd?.home ? asDirectoryPath(cwd.home) : null;
|
||||
const preferredDirectory = preferredPath ? asDirectoryPath(preferredPath) : null;
|
||||
const pathForRoot =
|
||||
preferredDirectory && preferredDirectory !== '/' ? preferredDirectory : cwdPath;
|
||||
const homeRoot =
|
||||
homePath && cwdPath && (cwdPath === homePath || cwdPath.startsWith(homePath))
|
||||
homePath && pathForRoot && (pathForRoot === homePath || pathForRoot.startsWith(homePath))
|
||||
? { path: homePath, label: 'Home' }
|
||||
: undefined;
|
||||
const rootPath = cwd?.root?.path ? asDirectoryPath(cwd.root.path) : null;
|
||||
@@ -1137,18 +1140,20 @@
|
||||
if (!handledDisplayFile && terminal) {
|
||||
loading = true;
|
||||
|
||||
void (async () => {
|
||||
// Discover server features on initial mount
|
||||
const config = await getTerminalConfig(terminal.url, terminal.key);
|
||||
terminalEnabled = config?.features?.terminal !== false;
|
||||
void (async () => {
|
||||
// Discover server features on initial mount
|
||||
const config = await getTerminalConfig(terminal.url, terminal.key);
|
||||
terminalEnabled = config?.features?.terminal !== false;
|
||||
|
||||
if (chatId || savedPath === '/') {
|
||||
// Fetch session-specific cwd from the server (or global default for new chats)
|
||||
savedPath = applyCwd(await getCwd(terminal.url, terminal.key, chatId ?? undefined));
|
||||
}
|
||||
savedPath = clampToFileRoot(savedPath);
|
||||
loadDir(savedPath, { restoreTree: true });
|
||||
})();
|
||||
const serverCwd = await getCwd(terminal.url, terminal.key, chatId ?? undefined);
|
||||
const serverPath = applyCwd(serverCwd, savedPath);
|
||||
if (chatId || savedPath === '/') {
|
||||
// Fetch session-specific cwd from the server (or global default for new chats)
|
||||
savedPath = serverPath;
|
||||
}
|
||||
savedPath = clampToFileRoot(savedPath);
|
||||
loadDir(savedPath, { restoreTree: true });
|
||||
})();
|
||||
}
|
||||
|
||||
mounted = true;
|
||||
|
||||
@@ -377,6 +377,28 @@
|
||||
fill="currentColor"
|
||||
stroke="none">PDF</text
|
||||
>
|
||||
{:else if name === 'docx-logo'}
|
||||
<path
|
||||
d="M4 21.4V2.6C4 2.26863 4.26863 2 4.6 2H16.2515C16.4106 2 16.5632 2.06321 16.6757 2.17574L19.8243 5.32426C19.9368 5.43679 20 5.5894 20 5.74853V21.4C20 21.7314 19.7314 22 19.4 22H4.6C4.26863 22 4 21.7314 4 21.4Z"
|
||||
/>
|
||||
<path d="M16 2V5.4C16 5.73137 16.2686 6 16.6 6H20" />
|
||||
<path d="M8 10H16" />
|
||||
<path d="M8 14H16" />
|
||||
<path d="M8 18H13" />
|
||||
{:else if name === 'xlsx-logo'}
|
||||
<path
|
||||
d="M4 21.4V2.6C4 2.26863 4.26863 2 4.6 2H16.2515C16.4106 2 16.5632 2.06321 16.6757 2.17574L19.8243 5.32426C19.9368 5.43679 20 5.5894 20 5.74853V21.4C20 21.7314 19.7314 22 19.4 22H4.6C4.26863 22 4 21.7314 4 21.4Z"
|
||||
/>
|
||||
<path d="M16 2V5.4C16 5.73137 16.2686 6 16.6 6H20" />
|
||||
<path d="M7.5 10H16.5V18H7.5V10Z" />
|
||||
<path d="M7.5 14H16.5" />
|
||||
<path d="M12 10V18" />
|
||||
{:else if name === 'pptx-logo'}
|
||||
<path
|
||||
d="M4 21.4V2.6C4 2.26863 4.26863 2 4.6 2H16.2515C16.4106 2 16.5632 2.06321 16.6757 2.17574L19.8243 5.32426C19.9368 5.43679 20 5.5894 20 5.74853V21.4C20 21.7314 19.7314 22 19.4 22H4.6C4.26863 22 4 21.7314 4 21.4Z"
|
||||
/>
|
||||
<path d="M16 2V5.4C16 5.73137 16.2686 6 16.6 6H20" />
|
||||
<path d="M8 10H16V16H8V10Z" />
|
||||
{:else if name === 'npm'}
|
||||
<path d="M1 8L23 8V15L11 15V17L7.5 17V15L1 15V8Z" />
|
||||
<path d="M7.5 8L7.5 15" />
|
||||
|
||||
@@ -149,13 +149,14 @@ export function fileIconName(name: string, type: string = 'file'): string {
|
||||
case 'rar':
|
||||
return 'archive';
|
||||
case 'docx':
|
||||
return 'docx-logo';
|
||||
case 'txt':
|
||||
return 'page-text';
|
||||
case 'xlsx':
|
||||
case 'xls':
|
||||
return 'table';
|
||||
return 'xlsx-logo';
|
||||
case 'pptx':
|
||||
return 'page';
|
||||
return 'pptx-logo';
|
||||
default:
|
||||
return 'empty-page';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user