diff --git a/src/lib/components/chat/ChatTabs.svelte b/src/lib/components/chat/ChatTabs.svelte index bc3c56061b..7ad1206948 100644 --- a/src/lib/components/chat/ChatTabs.svelte +++ b/src/lib/components/chat/ChatTabs.svelte @@ -108,7 +108,6 @@ > = {}; let dirtyFiles: Record = {}; let fileContexts: Record = {}; - let gitDirectories: Record = {}; let panelTarget: HTMLElement | null = null; let initialized = false; let tabsChatId = chatId; @@ -165,9 +164,10 @@ $: activeTabId = tabs.activeId; $: activeTab = tabs.tabs.find((tab) => tab.id === tabs.activeId); $: terminalContext = fileContexts[tabs.activeId] ?? activeTab?.context ?? null; + // Resolve before reactive Files-tab creation, which can run later in the same update. $: gitConnection = mounted && - tabs.tabs.length > 0 && + $config?.features?.enable_tool_servers && (tabs.tabs.find((tab) => tab.id === tabs.activeId)?.connection ?? resolveTerminalConnection( tabs.tabs.find((tab) => tab.id === tabs.activeId)?.terminalId ?? $selectedTerminalId, @@ -305,7 +305,6 @@ tabs = removeTab(tabs, id); delete dirtyFiles[id]; delete fileContexts[id]; - delete gitDirectories[id]; if (!tabs.tabs.length) showTabs.set(false); await tick(); document.getElementById(domId(tabs.activeId))?.focus(); @@ -469,7 +468,6 @@ tabs = removeTab(tabs, tab.id); delete dirtyFiles[tab.id]; delete fileContexts[tab.id]; - delete gitDirectories[tab.id]; } } }; @@ -522,7 +520,6 @@ tabs = emptyTabs(); dirtyFiles = {}; fileContexts = {}; - gitDirectories = {}; initialized = false; commentTarget = {}; } @@ -905,7 +902,6 @@ overlay={dragged} {chatId} bind:terminalContext={fileContexts[tab.id]} - bind:gitDirectory={gitDirectories[tab.id]} /> {:else if tab.kind === 'files' && codeInterpreterEnabled} @@ -918,14 +914,14 @@ {$i18n.t('Open a tab using the + menu.')} {/if} - {#if gitConnection} + {#if gitConnection && tabs.tabs.length} openFile(path, gitConnection.selector)} onOpenDirectory={(path) => openFiles(gitConnection.selector, path)} diff --git a/src/lib/components/chat/FileNav.svelte b/src/lib/components/chat/FileNav.svelte index f0bf556ddb..beba0770bb 100644 --- a/src/lib/components/chat/FileNav.svelte +++ b/src/lib/components/chat/FileNav.svelte @@ -68,7 +68,6 @@ export let overlay = false; export let active = true; export let gitStatus: GitStatus | null = null; - export let gitDirectory: string | null = null; export let gitConnection: TerminalConnection | null = null; export let gitDiffMode: 'unified' | 'split' = 'unified'; export let gitHideWhitespace = false; @@ -1024,9 +1023,10 @@ selectedFileWritable = true; clearFilePreview(); clearSelection(); - if (!options.preserveTree || directory !== currentPath) gitDirectory = directory; + if (!options.preserveTree || directory !== currentPath || !terminalContext) { + terminalContext = { terminalId: effectiveTerminalId, currentDirectory: directory }; + } currentPath = directory; - terminalContext = { terminalId: effectiveTerminalId, currentDirectory: directory }; savedPath = directory; pushNavHistory(directory); @@ -1089,7 +1089,7 @@ } expandedDirs = new Set(expandedDirs).add(directory); - gitDirectory = directory; + terminalContext = { terminalId: effectiveTerminalId, currentDirectory: directory }; saveTreeState(); const result = await fetchExpandedDir(directory); @@ -2108,6 +2108,7 @@ }} breadcrumbs={buildBreadcrumbs(currentPath)} {selectedFile} + fileSize={openedFile?.size ?? pendingFile?.size} {loading} {showSearch} onToggleSearch={toggleSearch} diff --git a/src/lib/components/chat/FileNav/FileNavToolbar.svelte b/src/lib/components/chat/FileNav/FileNavToolbar.svelte index 9ee6db9972..87c6bb735a 100644 --- a/src/lib/components/chat/FileNav/FileNavToolbar.svelte +++ b/src/lib/components/chat/FileNav/FileNavToolbar.svelte @@ -10,12 +10,14 @@ import DropdownMenu from '$lib/components/common/DropdownMenu.svelte'; import Icon from './Icon.svelte'; import Check from '$lib/components/icons/Check.svelte'; + import { formatFileSize } from '$lib/utils'; export let dragType = 'application/x-terminal-file-move'; const i18n: any = getContext('i18n'); export let breadcrumbs: { label: string; path: string }[] = []; export let selectedFile: string | null = null; + export let fileSize: number | undefined = undefined; export let loading = false; export let writable = true; export let viewMode: 'grid' | 'list' | null = null; @@ -159,6 +161,9 @@ {/if} {/if} + {#if selectedFile && fileSize !== undefined} + {formatFileSize(fileSize)} + {/if} {#if selectedFile && (gitFile || gitDiffOpen)}