mirror of
https://github.com/open-webui/open-webui.git
synced 2026-11-26 07:11:00 -05:00
refac
This commit is contained in:
1 parent
b01fe7fae2
commit
6f2fc7bc7a
66 files changed
+2206
-2737
No files matched your search
@@ -8,6 +8,8 @@
|
||||
|
||||
export let char = '';
|
||||
export let query = '';
|
||||
export let modelId: string | null | (() => string | null) = null;
|
||||
$: selectedModelId = typeof modelId === 'function' ? modelId() : modelId;
|
||||
export let command: (payload: {
|
||||
id: string;
|
||||
label: string;
|
||||
@@ -111,6 +113,7 @@
|
||||
<div class="max-h-60 overflow-y-auto overflow-x-hidden scrollbar-thin">
|
||||
{#if char === '/'}
|
||||
<SlashCommands
|
||||
modelId={selectedModelId}
|
||||
bind:this={suggestionElement}
|
||||
{query}
|
||||
canCompare={onCompare !== null}
|
||||
@@ -209,6 +212,7 @@
|
||||
/>
|
||||
{:else if char === '@'}
|
||||
<AtCommands
|
||||
modelId={selectedModelId}
|
||||
bind:this={suggestionElement}
|
||||
{query}
|
||||
fileUploadEnabled={isFileUploadEnabled}
|
||||
@@ -249,6 +253,7 @@
|
||||
/>
|
||||
{:else if char === '$'}
|
||||
<Skills
|
||||
modelId={selectedModelId}
|
||||
bind:this={suggestionElement}
|
||||
{query}
|
||||
bind:filteredItems
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<script lang="ts">
|
||||
import { resolveTerminalTarget, type TerminalTarget } from '$lib/apis/terminal';
|
||||
import Fuse from 'fuse.js';
|
||||
import { getContext, onDestroy, onMount, tick } from 'svelte';
|
||||
|
||||
@@ -34,6 +35,7 @@
|
||||
const i18n = getContext<any>('i18n');
|
||||
|
||||
export let query = '';
|
||||
export let modelId: string | null = null;
|
||||
export let onSelect: (e: any) => void = () => {};
|
||||
export let fileUploadEnabled: boolean = true;
|
||||
|
||||
@@ -121,10 +123,7 @@
|
||||
getKnowledgeFileItems(signal);
|
||||
};
|
||||
|
||||
const getFilesystemItems = async (
|
||||
terminal: { url: string; key: string } | null,
|
||||
signal: AbortSignal
|
||||
) => {
|
||||
const getFilesystemItems = async (terminal: TerminalTarget | null, signal: AbortSignal) => {
|
||||
if (!terminal) {
|
||||
filesystemItems = [];
|
||||
return;
|
||||
@@ -133,13 +132,11 @@
|
||||
const terminalId = $selectedTerminalId;
|
||||
const sessionId = $activeChatId;
|
||||
const res = await searchFiles(
|
||||
terminal.url,
|
||||
terminal.key,
|
||||
terminal,
|
||||
query,
|
||||
'.',
|
||||
20,
|
||||
'any',
|
||||
sessionId || undefined,
|
||||
localStorage.getItem('fileNav:showHidden') === 'true',
|
||||
signal
|
||||
).catch(() => null);
|
||||
@@ -153,31 +150,17 @@
|
||||
}));
|
||||
};
|
||||
|
||||
const chatContext = (terminal: any) => terminal?.contexts?.chat ?? {};
|
||||
|
||||
const getSelectedTerminal = (): { url: string; key: string } | null => {
|
||||
if (!$selectedTerminalId) return null;
|
||||
|
||||
const systemTerminal = ($terminalServers ?? []).find(
|
||||
(t) => t.id && t.id === $selectedTerminalId
|
||||
const getSelectedTerminal = (): TerminalTarget | null => {
|
||||
const target = resolveTerminalTarget(
|
||||
$selectedTerminalId,
|
||||
$terminalServers ?? [],
|
||||
(($settings as any)?.terminalServers ?? []).filter((server: any) => server.enabled),
|
||||
localStorage.token,
|
||||
{ chatId: $activeChatId || null, modelId: modelId }
|
||||
);
|
||||
const systemChatContext = chatContext(systemTerminal);
|
||||
if (systemTerminal) {
|
||||
if (
|
||||
systemChatContext === false ||
|
||||
(($temporaryChatEnabled || isTemporaryChatId($activeChatId)) &&
|
||||
systemChatContext?.context_id === 'chat_id')
|
||||
) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return { url: systemTerminal.url, key: localStorage.token };
|
||||
}
|
||||
|
||||
const directTerminal = ($settings?.terminalServers ?? []).find(
|
||||
(t: any) => t.url === $selectedTerminalId && t.enabled
|
||||
);
|
||||
return directTerminal?.url ? { url: directTerminal.url, key: directTerminal.key ?? '' } : null;
|
||||
if (($terminalServers ?? []).find((server) => server.id === $selectedTerminalId)?.scope === 'chat' && ($temporaryChatEnabled || isTemporaryChatId($activeChatId)))
|
||||
return null;
|
||||
return target;
|
||||
};
|
||||
|
||||
$: folderItems = (($folders ?? []) as any[])
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
<script lang="ts">
|
||||
export let modelId: string | null = null;
|
||||
import { resolveLocalizedResource } from '$lib/utils/localizedContent';
|
||||
import { getContext, onDestroy } from 'svelte';
|
||||
import { getSkillItems } from '$lib/apis/skills';
|
||||
import {
|
||||
listTerminalSkills,
|
||||
resolveTerminalConnection,
|
||||
resolveTerminalTarget,
|
||||
type TerminalSkill
|
||||
} from '$lib/apis/terminal';
|
||||
import {
|
||||
@@ -47,13 +48,12 @@
|
||||
};
|
||||
|
||||
const getTerminalItems = async (query = ''): Promise<TerminalSkill[]> => {
|
||||
const connection = resolveTerminalConnection(
|
||||
const target = resolveTerminalTarget(
|
||||
$selectedTerminalId,
|
||||
$terminalServers ?? [],
|
||||
$settings?.terminalServers ?? [],
|
||||
localStorage.token
|
||||
);
|
||||
const items = await listTerminalSkills(connection, $chatId || null).catch(() => []);
|
||||
localStorage.token, { chatId: $chatId || null, modelId: modelId });
|
||||
const items = await listTerminalSkills(target).catch(() => []);
|
||||
terminalSkills.set(items);
|
||||
const q = query.trim().toLowerCase();
|
||||
return q
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
<script lang="ts">
|
||||
export let modelId: string | null = null;
|
||||
import { resolveLocalizedResource } from '$lib/utils/localizedContent';
|
||||
import { getContext, onDestroy } from 'svelte';
|
||||
import { getPrompts } from '$lib/apis/prompts';
|
||||
import { getSkillItems } from '$lib/apis/skills';
|
||||
import {
|
||||
listTerminalSkills,
|
||||
resolveTerminalConnection,
|
||||
resolveTerminalTarget,
|
||||
type TerminalSkill
|
||||
} from '$lib/apis/terminal';
|
||||
import {
|
||||
@@ -122,13 +123,12 @@
|
||||
});
|
||||
|
||||
const getTerminalItems = async (query = ''): Promise<TerminalSkill[]> => {
|
||||
const connection = resolveTerminalConnection(
|
||||
const target = resolveTerminalTarget(
|
||||
$selectedTerminalId,
|
||||
$terminalServers ?? [],
|
||||
$settings?.terminalServers ?? [],
|
||||
localStorage.token
|
||||
);
|
||||
const items = await listTerminalSkills(connection, $chatId || null).catch(() => []);
|
||||
localStorage.token, { chatId: $chatId || null, modelId: modelId });
|
||||
const items = await listTerminalSkills(target).catch(() => []);
|
||||
terminalSkills.set(items);
|
||||
const q = query.trim().toLowerCase();
|
||||
return q
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
import { getSkills } from '$lib/apis/skills';
|
||||
import {
|
||||
listTerminalSkills,
|
||||
resolveTerminalConnection,
|
||||
resolveTerminalTarget,
|
||||
type TerminalSkill
|
||||
} from '$lib/apis/terminal';
|
||||
|
||||
@@ -188,13 +188,12 @@
|
||||
};
|
||||
|
||||
const getTerminalSkillItems = async (): Promise<TerminalSkill[]> => {
|
||||
const connection = resolveTerminalConnection(
|
||||
const target = resolveTerminalTarget(
|
||||
$selectedTerminalId,
|
||||
$terminalServers ?? [],
|
||||
$settings?.terminalServers ?? [],
|
||||
localStorage.token
|
||||
);
|
||||
const items = await listTerminalSkills(connection, $chatId || null).catch(() => []);
|
||||
localStorage.token, { chatId: $chatId || null, modelId: selectedModels[0] ?? null });
|
||||
const items = await listTerminalSkills(target).catch(() => []);
|
||||
terminalSkills.set(items);
|
||||
return items;
|
||||
};
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
<script lang="ts">
|
||||
export let modelId: string | null = null;
|
||||
import { getContext, tick } from 'svelte';
|
||||
import { resolveTerminalConnection, type TerminalConnection } from '$lib/apis/terminal';
|
||||
import { resolveTerminalTarget, type TerminalTarget } from '$lib/apis/terminal';
|
||||
import UserTerminalsModal from '../UserTerminalsModal.svelte';
|
||||
import { updateChatById } from '$lib/apis/chats';
|
||||
import { toast } from 'svelte-sonner';
|
||||
import TerminalSystemInfoModal from '../TerminalSystemInfoModal.svelte';
|
||||
@@ -36,23 +38,21 @@
|
||||
export let chatId: string | null = null;
|
||||
export let terminalContext: TerminalContext | null = null;
|
||||
|
||||
const chatContext = (terminal: any) => terminal?.contexts?.chat ?? {};
|
||||
|
||||
$: systemTerminals = ($terminalServers ?? []).filter(
|
||||
(t) =>
|
||||
t.id &&
|
||||
chatContext(t) !== false &&
|
||||
!(
|
||||
($temporaryChatEnabled || isTemporaryChatId($activeChatId)) &&
|
||||
chatContext(t)?.context_id === 'chat_id'
|
||||
t.scope === 'chat'
|
||||
)
|
||||
);
|
||||
// Tether presences are the user's own paired devices, listed apart from servers.
|
||||
const isDevice = (terminal: any) => terminal.id.startsWith('tether:');
|
||||
$: systemSections = [
|
||||
{ devices: false, terminals: systemTerminals.filter((t) => !isDevice(t)) },
|
||||
{ devices: true, terminals: systemTerminals.filter(isDevice) }
|
||||
].filter((section) => section.terminals.length > 0);
|
||||
{ devices: false, managed: true, terminals: systemTerminals.filter((t) => !isDevice(t)) },
|
||||
{ devices: true, managed: false, terminals: systemTerminals.filter(isDevice) }
|
||||
].filter((section) => !section.devices || section.terminals.length > 0);
|
||||
$: directTerminals = (
|
||||
$config?.features?.enable_direct_integrations &&
|
||||
($user?.role === 'admin' || ($user?.permissions?.features?.direct_tool_servers ?? true))
|
||||
@@ -132,14 +132,13 @@
|
||||
show = false;
|
||||
};
|
||||
|
||||
$: selectedSystemTerminal = systemTerminals.find((t) => t.id === $selectedTerminalId);
|
||||
$: selectedSystemTerminal = systemTerminals.find((t) => (!!$selectedTerminalId && t.id === $selectedTerminalId));
|
||||
$: selectedDirectTerminal = directTerminals.find((t) => t.url === $selectedTerminalId);
|
||||
$: folderConnection = resolveTerminalConnection(
|
||||
$: folderTarget = resolveTerminalTarget(
|
||||
$selectedTerminalId,
|
||||
systemTerminals,
|
||||
directTerminals,
|
||||
''
|
||||
);
|
||||
'', { chatId: $activeChatId || null, modelId: modelId });
|
||||
$: selectedDevice = !!selectedSystemTerminal && isDevice(selectedSystemTerminal);
|
||||
|
||||
$: selectedLabel =
|
||||
@@ -147,9 +146,10 @@
|
||||
selectedSystemTerminal?.id ||
|
||||
selectedDirectTerminal?.name ||
|
||||
selectedDirectTerminal?.url?.replace(/^https?:\/\//, '') ||
|
||||
$i18n.t('Terminal');
|
||||
($selectedTerminalId ? $i18n.t('Unavailable terminal') : $i18n.t('Terminal'));
|
||||
$: if (disabled && show) show = false;
|
||||
|
||||
let showTerminals = false;
|
||||
async function saveSelection(id: string | null) {
|
||||
if (isSavedChatId(chatId)) {
|
||||
try {
|
||||
@@ -164,32 +164,33 @@
|
||||
}
|
||||
return true;
|
||||
}
|
||||
let info: { connection: TerminalConnection; chatId: string | null; label: string } | null = null;
|
||||
async function selectTerminal(id: string) {
|
||||
if (await saveSelection(id)) selectedTerminalId.set(id);
|
||||
}
|
||||
let info: { target: TerminalTarget; label: string } | null = null;
|
||||
const openInfo = async (selector: string, label: string) => {
|
||||
if (
|
||||
chatContext(systemTerminals.find((t) => t.id === selector))?.context_id === 'chat_id' &&
|
||||
systemTerminals.find((t) => (!!selector && t.id === selector))?.scope === 'chat' &&
|
||||
!isSavedChatId($activeChatId)
|
||||
)
|
||||
return;
|
||||
const connection = resolveTerminalConnection(
|
||||
const target = resolveTerminalTarget(
|
||||
selector,
|
||||
systemTerminals,
|
||||
directTerminals,
|
||||
localStorage.token ?? ''
|
||||
);
|
||||
if (!connection) return;
|
||||
const chatId = $activeChatId;
|
||||
localStorage.token ?? '', { chatId: $activeChatId || null, modelId: modelId });
|
||||
if (!target) return;
|
||||
show = false;
|
||||
await tick();
|
||||
info = { connection, chatId, label };
|
||||
info = { target, label };
|
||||
};
|
||||
$: if (
|
||||
!$config?.features?.enable_tool_servers ||
|
||||
(info &&
|
||||
(info.chatId !== $activeChatId ||
|
||||
(info.connection.system
|
||||
? !systemTerminals.some((t) => t.id === info?.connection.selector)
|
||||
: !directTerminals.some((t) => t.url === info?.connection.selector))))
|
||||
(info.target.context.chatId !== $activeChatId ||
|
||||
(info.target.system
|
||||
? !systemTerminals.some((t) => t.id === info?.target.selector)
|
||||
: !directTerminals.some((t) => t.url === info?.target.selector))))
|
||||
)
|
||||
info = null;
|
||||
|
||||
@@ -287,7 +288,7 @@
|
||||
|
||||
{#each directTerminals as terminal}
|
||||
<div
|
||||
class="group/instance relative rounded-xl hover:bg-gray-50/40 dark:hover:bg-gray-800/40"
|
||||
class="group/terminal relative rounded-xl hover:bg-gray-50/40 dark:hover:bg-gray-800/40"
|
||||
>
|
||||
<button
|
||||
type="button"
|
||||
@@ -328,7 +329,7 @@
|
||||
<div
|
||||
class="absolute inset-y-0 {$selectedTerminalId === terminal.url
|
||||
? 'right-6'
|
||||
: 'right-1'} flex items-center opacity-0 pointer-events-none transition-opacity group-hover/instance:opacity-100 group-hover/instance:pointer-events-auto group-focus-within/instance:opacity-100 group-focus-within/instance:pointer-events-auto"
|
||||
: 'right-1'} flex items-center opacity-0 pointer-events-none transition-opacity group-hover/terminal:opacity-100 group-hover/terminal:pointer-events-auto group-focus-within/terminal:opacity-100 group-focus-within/terminal:pointer-events-auto"
|
||||
>
|
||||
<Tooltip content={$i18n.t('System info')} placement="top">
|
||||
<button
|
||||
@@ -355,9 +356,36 @@
|
||||
<span
|
||||
class="text-[0.625rem] font-normal text-gray-400 dark:text-gray-500 uppercase tracking-wider"
|
||||
>
|
||||
{section.devices ? $i18n.t('Your devices') : $i18n.t('System')}
|
||||
{section.devices
|
||||
? $i18n.t('Your devices')
|
||||
: section.managed
|
||||
? $i18n.t('Terminals')
|
||||
: $i18n.t('System')}
|
||||
</span>
|
||||
{#if !section.devices && $user?.role === 'admin'}
|
||||
{#if section.managed}
|
||||
<Tooltip content={$i18n.t('Manage terminals')} placement="top">
|
||||
<button
|
||||
type="button"
|
||||
aria-label={$i18n.t('Manage terminals')}
|
||||
class="p-0.5 rounded-md text-gray-400 hover:text-gray-600 dark:text-gray-500 dark:hover:text-gray-300 transition"
|
||||
on:click|stopPropagation={() => {
|
||||
show = false;
|
||||
showTerminals = true;
|
||||
}}
|
||||
>
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
viewBox="0 0 20 20"
|
||||
fill="currentColor"
|
||||
class="size-3.5"
|
||||
>
|
||||
<path
|
||||
d="M10.75 4.75a.75.75 0 00-1.5 0v4.5h-4.5a.75.75 0 000 1.5h4.5v4.5a.75.75 0 001.5 0v-4.5h4.5a.75.75 0 000-1.5h-4.5v-4.5z"
|
||||
/>
|
||||
</svg>
|
||||
</button>
|
||||
</Tooltip>
|
||||
{:else if !section.devices && $user?.role === 'admin'}
|
||||
<Tooltip content={$i18n.t('Add Terminal')} placement="top">
|
||||
<button
|
||||
type="button"
|
||||
@@ -385,7 +413,7 @@
|
||||
|
||||
{#each section.terminals as terminal}
|
||||
<div
|
||||
class="group/instance relative rounded-xl hover:bg-gray-50/40 dark:hover:bg-gray-800/40"
|
||||
class="group/terminal relative rounded-xl hover:bg-gray-50/40 dark:hover:bg-gray-800/40"
|
||||
>
|
||||
<button
|
||||
type="button"
|
||||
@@ -425,11 +453,11 @@
|
||||
</div>
|
||||
{/if}
|
||||
</button>
|
||||
{#if chatContext(terminal)?.context_id !== 'chat_id' || isSavedChatId($activeChatId)}
|
||||
{#if terminal.scope !== 'chat' || isSavedChatId($activeChatId)}
|
||||
<div
|
||||
class="absolute inset-y-0 {$selectedTerminalId === terminal.id
|
||||
? 'right-6'
|
||||
: 'right-1'} flex items-center opacity-0 pointer-events-none transition-opacity group-hover/instance:opacity-100 group-hover/instance:pointer-events-auto group-focus-within/instance:opacity-100 group-focus-within/instance:pointer-events-auto"
|
||||
: 'right-1'} flex items-center opacity-0 pointer-events-none transition-opacity group-hover/terminal:opacity-100 group-hover/terminal:pointer-events-auto group-focus-within/terminal:opacity-100 group-focus-within/terminal:pointer-events-auto"
|
||||
>
|
||||
<Tooltip content={$i18n.t('System info')} placement="top">
|
||||
<button
|
||||
@@ -446,6 +474,15 @@
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
{:else}
|
||||
<button
|
||||
type="button"
|
||||
class="flex w-full items-center h-[1.6875rem] px-2 text-[0.8125rem] text-gray-500 rounded-xl hover:bg-gray-50/40 dark:hover:bg-gray-800/40"
|
||||
on:click={() => {
|
||||
show = false;
|
||||
showTerminals = true;
|
||||
}}>{$i18n.t('New terminal')}</button
|
||||
>
|
||||
{/each}
|
||||
{/each}
|
||||
</DropdownMenu>
|
||||
@@ -457,19 +494,18 @@
|
||||
{#if info}
|
||||
{#key info}
|
||||
<TerminalSystemInfoModal
|
||||
connection={info.connection}
|
||||
chatId={info.chatId}
|
||||
target={info.target}
|
||||
label={info.label}
|
||||
onClose={() => (info = null)}
|
||||
/>
|
||||
{/key}
|
||||
{/if}
|
||||
|
||||
{#if folderConnection && (chatContext(selectedSystemTerminal)?.context_id !== 'chat_id' || isSavedChatId(chatId))}
|
||||
{#key `${$user?.id}:${folderConnection.selector}:${chatId ?? ''}`}
|
||||
{#if folderTarget && (selectedSystemTerminal?.scope !== 'chat' || isSavedChatId(chatId))}
|
||||
{#key `${$user?.id}:${folderTarget.selector}:${chatId ?? ''}`}
|
||||
<WorkingDirectoryMenu
|
||||
{inMenu}
|
||||
connection={folderConnection}
|
||||
target={folderTarget}
|
||||
{chatId}
|
||||
userId={$user?.id ?? ''}
|
||||
bind:terminalContext
|
||||
@@ -482,3 +518,12 @@
|
||||
/>
|
||||
{/key}
|
||||
{/if}
|
||||
|
||||
{#if showTerminals}
|
||||
<UserTerminalsModal {modelId}
|
||||
bind:show={showTerminals}
|
||||
{chatId}
|
||||
selected={$selectedTerminalId}
|
||||
onSelect={selectTerminal}
|
||||
/>
|
||||
{/if}
|
||||
@@ -1,7 +1,7 @@
|
||||
<script lang="ts">
|
||||
import { getContext, onMount, onDestroy } from 'svelte';
|
||||
import { toast } from 'svelte-sonner';
|
||||
import { getCwd, setCwd, type TerminalConnection } from '$lib/apis/terminal';
|
||||
import { getCwd, setCwd, type TerminalTarget } from '$lib/apis/terminal';
|
||||
import { loadRecentFolders, rememberRecentFolder } from '$lib/apis/terminal/recentFolders';
|
||||
import { selectedFolder, showFileNav } from '$lib/stores';
|
||||
import type { TerminalContext } from '$lib/types';
|
||||
@@ -18,7 +18,7 @@
|
||||
import FileNav from '../FileNav.svelte';
|
||||
|
||||
const i18n = getContext<any>('i18n');
|
||||
export let connection: TerminalConnection;
|
||||
export let target: TerminalTarget;
|
||||
export let chatId: string | null = null;
|
||||
export let userId: string;
|
||||
export let terminalContext: TerminalContext | null = null;
|
||||
@@ -40,7 +40,7 @@
|
||||
const folderName = (path: string) => path.replace(/\/+$/, '').split('/').pop() || '/';
|
||||
const normalize = (path: string) => path.replace(/\/+$/, '') || '/';
|
||||
|
||||
$: if (terminalContext?.terminalId === connection.selector)
|
||||
$: if (terminalContext?.terminalId === target.selector)
|
||||
cwd = terminalContext.currentDirectory;
|
||||
$: directory = cwd;
|
||||
$: options = [...new Set([directory, ...recent].filter(Boolean).map(normalize))].filter((path) =>
|
||||
@@ -55,12 +55,12 @@
|
||||
await initialization;
|
||||
if (disposed) return;
|
||||
if (!home) {
|
||||
const result = await getCwd(connection.baseUrl, connection.key, chatId ?? undefined);
|
||||
const result = await getCwd(target);
|
||||
if (disposed) return;
|
||||
home = result?.home ?? '';
|
||||
}
|
||||
if (!home) throw new Error('Terminal home is unavailable');
|
||||
const paths = await loadRecentFolders(connection, chatId, home, userId);
|
||||
const paths = await loadRecentFolders(target, home, userId);
|
||||
if (disposed || version !== historyVersion) return;
|
||||
recent = paths;
|
||||
historyError = '';
|
||||
@@ -71,19 +71,19 @@
|
||||
}
|
||||
|
||||
onMount(() => {
|
||||
if (!chatId && terminalContext?.terminalId !== connection.selector) {
|
||||
if (!chatId && terminalContext?.terminalId !== target.selector) {
|
||||
terminalContext = {
|
||||
terminalId: connection.selector,
|
||||
terminalId: target.selector,
|
||||
currentDirectory:
|
||||
$selectedFolder?.data?.terminal_id === connection.selector
|
||||
$selectedFolder?.data?.terminal_id === target.selector
|
||||
? ($selectedFolder.data.working_directory ?? '')
|
||||
: ''
|
||||
};
|
||||
}
|
||||
const selectedContext =
|
||||
terminalContext?.terminalId === connection.selector ? terminalContext : null;
|
||||
terminalContext?.terminalId === target.selector ? terminalContext : null;
|
||||
if (selectedContext) cwd = selectedContext.currentDirectory;
|
||||
initialization = getCwd(connection.baseUrl, connection.key, chatId ?? undefined).then(
|
||||
initialization = getCwd(target).then(
|
||||
(result) => {
|
||||
if (disposed) return;
|
||||
home = result?.home ?? '';
|
||||
@@ -100,7 +100,7 @@
|
||||
saving = true;
|
||||
// A draft has no terminal session yet; submission applies this choice after creating the chat.
|
||||
const result = chatId
|
||||
? await setCwd(connection.baseUrl, connection.key, path, chatId)
|
||||
? await setCwd(target, path)
|
||||
: { cwd: path || home };
|
||||
if (disposed) return;
|
||||
if (!result?.cwd) {
|
||||
@@ -110,7 +110,7 @@
|
||||
}
|
||||
// An empty path resets the terminal to its default directory.
|
||||
cwd = path ? result.cwd : '';
|
||||
terminalContext = { terminalId: connection.selector, currentDirectory: cwd };
|
||||
terminalContext = { terminalId: target.selector, currentDirectory: cwd };
|
||||
try {
|
||||
await onSelect(cwd);
|
||||
} catch (error) {
|
||||
@@ -129,7 +129,7 @@
|
||||
try {
|
||||
await initialization;
|
||||
if (disposed) return;
|
||||
await rememberRecentFolder(connection, chatId, home, userId, cwd);
|
||||
await rememberRecentFolder(target, home, userId, cwd);
|
||||
if (disposed) return;
|
||||
historyError = '';
|
||||
} catch {
|
||||
@@ -253,7 +253,7 @@
|
||||
on:click|stopPropagation={() => {
|
||||
show = false;
|
||||
showFileNav.set({
|
||||
terminalId: connection.selector,
|
||||
terminalId: target.selector,
|
||||
directory: path,
|
||||
chatId
|
||||
});
|
||||
@@ -299,7 +299,7 @@
|
||||
</div>
|
||||
<div class="h-[60dvh] min-h-0" aria-busy={saving}>
|
||||
<FileNav
|
||||
terminalId={connection.selector}
|
||||
terminalId={target.selector}
|
||||
{chatId}
|
||||
initialDirectory={directory || null}
|
||||
manageFileRequests={false}
|
||||
|
||||
Reference in new issue
Block a user