From 77fd8aea613c42e0d590804c7f9fdcf6f5f4af02 Mon Sep 17 00:00:00 2001 From: Classic298 <27028174+Classic298@users.noreply.github.com> Date: Wed, 14 Oct 2026 21:18:56 +0200 Subject: [PATCH] fix: some file browser actions ignore the chat's own terminal workspace in Per chat mode (#32418) With an orchestrator connection in Admin > Integrations > Open Terminal set to Terminal Contexts > Chat = "Per chat", several file browser actions ran in the shared terminal workspace, outside the chat's own one. Opening an HTML file showed "File not found", notebooks could not run, saving an edited file and New File wrote to the shared workspace so the change never showed up in the chat, and deleting several selected files or downloading a folder or a selection as a zip failed. All of these now use the chat's own workspace, like the rest of the file browser. Fixes #29965 --- src/lib/components/chat/FileNav.svelte | 45 ++++++++++++++++++++------ 1 file changed, 36 insertions(+), 9 deletions(-) diff --git a/src/lib/components/chat/FileNav.svelte b/src/lib/components/chat/FileNav.svelte index 12b015a3da..1e821dc173 100644 --- a/src/lib/components/chat/FileNav.svelte +++ b/src/lib/components/chat/FileNav.svelte @@ -389,7 +389,7 @@ let terminalChatContextPending = false; let terminalChatContextHidden = false; let isPerChatTerminal = false; - $: portPreviewBaseUrl = + $: previewBaseUrl = selectedTerminal && isPerChatTerminal && chatId ? `${selectedTerminal.url}/chats/${encodeURIComponent(chatId)}` : (selectedTerminal?.url ?? ''); @@ -1033,7 +1033,12 @@ // Directories end with '/', downloaded as a ZIP archive const isDir = path.endsWith('/'); const result = isDir - ? await archiveFromTerminal(terminal.url, terminal.key, [path.replace(/\/$/, '')]) + ? await archiveFromTerminal( + terminal.url, + terminal.key, + [path.replace(/\/$/, '')], + chatId ?? undefined + ) : await downloadFileBlob(terminal.url, terminal.key, path, chatId ?? undefined); if (!result) { toast.error($i18n.t('Download failed')); @@ -1218,7 +1223,13 @@ if (!terminal) return; const emptyFile = new File([''], name, { type: 'application/octet-stream' }); - const result = await uploadToTerminal(terminal.url, terminal.key, currentPath, emptyFile); + const result = await uploadToTerminal( + terminal.url, + terminal.key, + currentPath, + emptyFile, + chatId ?? undefined + ); toast[result ? 'success' : 'error']( result ? $i18n.t('File created') : $i18n.t('Failed to create file') ); @@ -1387,7 +1398,12 @@ const paths = [...selectedEntries]; let ok = 0; for (const p of paths) { - const result = await deleteEntry(terminal.url, terminal.key, p.replace(/\/$/, '')); + const result = await deleteEntry( + terminal.url, + terminal.key, + p.replace(/\/$/, ''), + chatId ?? undefined + ); if (result) ok++; } toast[ok > 0 ? 'success' : 'error']( @@ -1415,7 +1431,12 @@ const toastId = toast.loading($i18n.t('Preparing download...')); try { // Archive everything into a single ZIP - const result = await archiveFromTerminal(terminal.url, terminal.key, paths); + const result = await archiveFromTerminal( + terminal.url, + terminal.key, + paths, + chatId ?? undefined + ); if (!result) { toast.error($i18n.t('Download failed')); return; @@ -1907,7 +1928,7 @@ > {#if previewPort !== null} { @@ -1945,7 +1966,7 @@ const DOMPurify = (await import('dompurify')).default; fileOfficeHtml = DOMPurify.sanitize(result.html); }} - baseUrl={selectedTerminal?.url ?? ''} + baseUrl={previewBaseUrl} apiKey={selectedTerminal?.key ?? ''} overlay={overlay || isDraggingHandle} onSave={async (content) => { @@ -1954,7 +1975,13 @@ const fileName = selectedFile.split('/').pop() ?? 'file'; const dir = selectedFile.substring(0, selectedFile.lastIndexOf('/') + 1) || '/'; const file = new File([content], fileName, { type: 'text/plain' }); - const result = await uploadToTerminal(terminal.url, terminal.key, dir, file); + const result = await uploadToTerminal( + terminal.url, + terminal.key, + dir, + file, + chatId ?? undefined + ); toast[result ? 'success' : 'error']( result ? $i18n.t('File saved') : $i18n.t('Failed to save file') ); @@ -2192,7 +2219,7 @@ {#key JSON.stringify([chatId, selectedTerminal.url])} {