mirror of
https://github.com/open-webui/open-webui.git
synced 2026-10-15 04:18:18 +00:00
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
This commit is contained in:
parent
8bddf9bc62
commit
77fd8aea61
1 changed files with 36 additions and 9 deletions
|
|
@ -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}
|
||||
<PortPreview
|
||||
baseUrl={portPreviewBaseUrl}
|
||||
baseUrl={previewBaseUrl}
|
||||
port={previewPort}
|
||||
overlay={overlay || isDraggingHandle}
|
||||
onClose={() => {
|
||||
|
|
@ -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])}
|
||||
<PortList
|
||||
baseUrl={selectedTerminal.url}
|
||||
previewBaseUrl={portPreviewBaseUrl}
|
||||
{previewBaseUrl}
|
||||
apiKey={selectedTerminal.key}
|
||||
{chatId}
|
||||
on:previewPort={(e) => {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue