This commit is contained in:
Timothy Jaeryang Baek committed 2026-11-17 01:05:45 +09:00
1 parent 7e5c7c02b9
commit de68d0ce47
3 files changed
+97 -42

No files matched your search

@@ -17,6 +17,7 @@
import AdvancedParams from '$lib/components/chat/Settings/Advanced/AdvancedParams.svelte';
import Capabilities from '$lib/components/workspace/Models/Capabilities.svelte';
import ToolsSelector from '$lib/components/workspace/Models/ToolsSelector.svelte';
import TerminalSelector from '$lib/components/workspace/Models/TerminalSelector.svelte';
import LanguageModeSelect from '$lib/components/common/LanguageModeSelect.svelte';
import LocalizedPromptSuggestions from '$lib/components/workspace/Models/LocalizedPromptSuggestions.svelte';
@@ -34,6 +35,7 @@
let defaultCapabilities = {};
let defaultFeatureIds = [];
let toolIds = [];
let terminalId = '';
let defaultParams = {};
let builtinTools = {};
let promptSuggestions = [];
@@ -45,6 +47,9 @@
$: configuredParams = Object.entries(defaultParams ?? {}).filter(
([_, value]) => value !== null && value !== '' && value !== undefined
);
$: hasTerminal =
$appConfig?.features?.enable_terminal_servers ||
$appConfig?.features?.enable_direct_integrations;
$: enabledCapabilities = Object.entries(defaultCapabilities ?? {}).filter(([_, value]) => value);
$: translatedPromptLocales = Object.entries(promptSuggestionsI18n ?? {})
.filter(([_, value]) => Array.isArray(value?.suggestion_prompts))
@@ -56,6 +61,7 @@
defaultCapabilities,
defaultFeatureIds,
toolIds,
terminalId,
defaultParams: Object.fromEntries(configuredParams),
builtinTools,
promptSuggestions: useDefaultPromptSuggestions
@@ -69,7 +75,7 @@
dirty = savedSnapshot !== '' && getSnapshot() !== savedSnapshot;
};
$: (toolIds, updateDirty());
$: (toolIds, terminalId, updateDirty());
const resetPromptSuggestions = () => {
useDefaultPromptSuggestions = true;
@@ -87,11 +93,13 @@
defaultFeatureIds = savedMeta.defaultFeatureIds ?? [];
builtinTools = savedMeta.builtinTools ?? {};
toolIds = savedMeta.toolIds ?? [];
terminalId = savedMeta.terminalId ?? '';
} else {
defaultCapabilities = { ...DEFAULT_CAPABILITIES };
defaultFeatureIds = [];
builtinTools = {};
toolIds = [];
terminalId = '';
}
await tools.set((await getTools(localStorage.token).catch(() => null)) ?? []);
@@ -118,7 +126,8 @@
capabilities: defaultCapabilities,
...(defaultFeatureIds.length > 0 ? { defaultFeatureIds } : {}),
...(Object.keys(builtinTools).length > 0 ? { builtinTools } : {}),
...(toolIds.length > 0 ? { toolIds } : {})
...(toolIds.length > 0 ? { toolIds } : {}),
...(terminalId ? { terminalId } : {})
};
config = await getModelsConfig(localStorage.token);
@@ -225,6 +234,15 @@
<ToolsSelector bind:selectedToolIds={toolIds} tools={$tools ?? []} />
{#if defaultCapabilities.terminal && hasTerminal}
<TerminalSelector
bind:terminalId
description={$i18n.t(
'Choose the terminal server selected by default for chats with models that do not set their own.'
)}
/>
{/if}
<div>
<button
class="flex w-full items-center justify-between gap-2 rounded-md px-1 py-1.5 text-left font-normal focus-visible:outline focus-visible:outline-2"
@@ -521,7 +521,7 @@
delete modelInfo.meta.i18n;
}
if (terminalId) {
if (terminalId || defaultMeta.terminalId) {
modelInfo.meta.terminalId = terminalId;
} else {
if (modelInfo.meta.terminalId) {
@@ -760,7 +760,7 @@
};
defaultFeatureIds = model?.meta?.defaultFeatureIds ?? defaultMeta.defaultFeatureIds ?? [];
builtinTools = model?.meta?.builtinTools ?? defaultMeta.builtinTools ?? {};
terminalId = model?.meta?.terminalId ?? '';
terminalId = model?.meta?.terminalId ?? defaultMeta.terminalId ?? '';
tts = { voice: model?.meta?.tts?.voice ?? '' };
voice = { voice: model?.meta?.voice?.voice ?? '' };
@@ -807,6 +807,7 @@
defaultFeatureIds = defaultMeta.defaultFeatureIds ?? [];
builtinTools = defaultMeta.builtinTools ?? {};
toolIds = defaultMeta.toolIds ?? [];
terminalId = defaultMeta.terminalId ?? '';
// Scroll to top 'workspace-container' element
const workspaceContainer = document.getElementById('workspace-container');
@@ -1,7 +1,7 @@
<script lang="ts">
import { getContext, onMount } from 'svelte';
import Select from '$lib/components/common/Select.svelte';
import ChevronDown from '$lib/components/icons/ChevronDown.svelte';
import Dropdown from '$lib/components/common/Dropdown.svelte';
import ChevronRight from '$lib/components/icons/ChevronRight.svelte';
import Check from '$lib/components/icons/Check.svelte';
import ModelSettingsLabel from './ModelSettingsLabel.svelte';
import { getTerminalServers, type TerminalServer } from '$lib/apis/terminal';
@@ -14,49 +14,85 @@
export let onChange: () => void = () => {};
let terminals: TerminalServer[] = [];
let show = false;
let valueElement: HTMLElement | null = null;
onMount(async () => {
terminals = await getTerminalServers(localStorage.token);
});
$: items = [
{ value: '', label: $i18n.t('None') },
...(terminalId && !terminals.some((terminal) => terminal.id === terminalId)
? [{ value: terminalId, label: $i18n.t('Unavailable') }]
: []),
...terminals.map((terminal) => ({
value: terminal.id,
label: terminal.name || terminal.id
}))
];
$: selectedLabel = items.find((item) => item.value === terminalId)?.label ?? $i18n.t('None');
const select = (value: string) => {
terminalId = value;
show = false;
onChange();
};
</script>
{#if terminals.length > 0 || terminalId}
<div
class="grid min-h-7 grid-cols-[7rem_minmax(0,1fr)] items-center gap-2 px-1 text-xs font-normal text-gray-600 dark:text-gray-400 sm:grid-cols-[8rem_minmax(0,1fr)]"
>
<ModelSettingsLabel
label={label || $i18n.t('Default terminal')}
description={description ||
$i18n.t('Choose the terminal server selected by default for chats with this model.')}
/>
<Select
bind:value={terminalId}
items={[
{ value: '', label: $i18n.t('None') },
...(terminalId && !terminals.some((terminal) => terminal.id === terminalId)
? [{ value: terminalId, label: $i18n.t('Unavailable') }]
: []),
...terminals.map((terminal) => ({
value: terminal.id,
label: terminal.name || terminal.id
}))
]}
triggerClass="flex w-fit max-w-full min-w-0 items-center gap-1 bg-transparent px-0.5 text-left text-xs font-normal text-gray-900 dark:text-gray-100"
onChange={() => onChange()}
<Dropdown anchorElement={valueElement} bind:show>
<button
type="button"
aria-expanded={show}
class="grid w-full grid-cols-[7rem_minmax(0,1fr)_auto] items-center gap-2 rounded-md px-1 py-1.5 text-left text-xs font-normal disabled:cursor-default sm:grid-cols-[8rem_minmax(0,1fr)_auto]"
>
<svelte:fragment slot="trigger" let:selectedLabel>
<span class="sr-only">{label || $i18n.t('Default terminal')}: </span>
<span class="truncate">{selectedLabel}</span>
<ChevronDown className="size-3 shrink-0" />
</svelte:fragment>
<svelte:fragment slot="item" let:item let:selected>
<span class="min-w-0 flex-1 truncate text-left">{item.label}</span>
{#if selected}<Check className="size-3 shrink-0" />{/if}
</svelte:fragment>
</Select>
</div>
<span class="text-gray-600 dark:text-gray-400"
><ModelSettingsLabel
label={label || $i18n.t('Default terminal')}
description={description ||
$i18n.t('Choose the terminal server selected by default for chats with this model.')}
/></span
>
<span bind:this={valueElement} class="min-w-0 truncate text-gray-900 dark:text-gray-100"
>{selectedLabel}</span
>
<ChevronRight className="size-3 text-gray-400" />
</button>
<div slot="content">
<div
class="flex max-h-64 w-56 max-w-[calc(100vw-2rem)] flex-col gap-0.5 overflow-y-auto rounded-xl border border-gray-200 bg-white p-1 text-gray-900 shadow-lg dark:border-gray-800 dark:bg-gray-850 dark:text-gray-100"
>
{#each items as item (item.value)}
<button
type="button"
class="flex min-h-7 w-full items-center justify-between gap-2 rounded-xl px-2 py-1 text-left text-xs hover:bg-gray-50 dark:hover:bg-gray-800"
aria-pressed={item.value === terminalId}
on:click={() => select(item.value)}
>
<span class="min-w-0 flex-1 truncate">{item.label}</span>
{#if item.value === terminalId}<Check
className="size-3.5 shrink-0 text-gray-500 dark:text-gray-400"
/>{/if}
</button>
{/each}
</div>
</div>
</Dropdown>
{:else}
<p class="px-1 py-1 text-xs text-gray-500 dark:text-gray-400">
{$i18n.t('No terminal servers available')}
</p>
<div
class="grid grid-cols-[7rem_minmax(0,1fr)_auto] items-center gap-2 px-1 py-1.5 text-xs font-normal sm:grid-cols-[8rem_minmax(0,1fr)_auto]"
>
<span class="text-gray-600 dark:text-gray-400"
><ModelSettingsLabel
label={label || $i18n.t('Default terminal')}
description={description ||
$i18n.t('Choose the terminal server selected by default for chats with this model.')}
/></span
>
<span class="truncate text-gray-500 dark:text-gray-400"
>{$i18n.t('No terminal servers available')}</span
>
</div>
{/if}