This commit is contained in:
Timothy Jaeryang Baek
2026-02-25 19:58:50 -06:00
parent 58d685eea4
commit eca9b405eb
4 changed files with 76 additions and 30 deletions
+8 -1
View File
@@ -15,7 +15,8 @@
showCallOverlay,
showArtifacts,
showEmbeds,
settings
settings,
showFileNavPath
} from '$lib/stores';
import { uploadFile } from '$lib/apis/files';
@@ -61,6 +62,12 @@
$: hasMessages = history?.messages && Object.keys(history.messages).length > 0;
$: if (!hasMessages && activeTab === 'overview') activeTab = 'controls';
// Auto-switch to Files tab when display_file is triggered
$: if ($showFileNavPath) {
activeTab = 'files';
showControls.set(true);
}
// Attach a terminal file to the chat input
const handleTerminalAttach = async (blob: Blob, name: string, contentType: string) => {
const tempItemId = uuidv4();
+36 -6
View File
@@ -6,7 +6,7 @@
<script lang="ts">
import { toast } from 'svelte-sonner';
import { getContext, onMount, onDestroy, tick } from 'svelte';
import { settings } from '$lib/stores';
import { settings, showFileNavPath } from '$lib/stores';
import {
getCwd,
listFiles,
@@ -224,12 +224,42 @@
onMount(async () => {
if (!configured) return;
// On first ever open, resolve the server's CWD instead of defaulting to /
if (savedPath === '/') {
const cwd = await getCwd(terminalUrl, terminalKey);
if (cwd) savedPath = cwd.endsWith('/') ? cwd : cwd + '/';
let handledDisplayFile = false;
// Subscribe to display_file requests
const unsubFileNav = showFileNavPath.subscribe(async (filePath) => {
if (!filePath || !configured) return;
handledDisplayFile = true;
// Clear the store so it can be re-triggered for the same path
showFileNavPath.set(null);
// Navigate to the parent directory
const lastSlash = filePath.lastIndexOf('/');
const dir = lastSlash > 0 ? filePath.substring(0, lastSlash + 1) : '/';
const fileName = filePath.substring(lastSlash + 1);
if (dir !== currentPath) {
await loadDir(dir);
}
// Open the file for preview
await tick();
const entry = entries.find((e) => e.name === fileName);
if (entry) {
await openEntry(entry);
}
});
// Only load the default directory if a display_file wasn't pending
if (!handledDisplayFile) {
// On first ever open, resolve the server's CWD instead of defaulting to /
if (savedPath === '/') {
const cwd = await getCwd(terminalUrl, terminalKey);
if (cwd) savedPath = cwd.endsWith('/') ? cwd : cwd + '/';
}
loadDir(savedPath);
}
loadDir(savedPath);
const onKeyDown = (e: KeyboardEvent) => {
if (e.key === 'Shift') shiftKey = true;