This commit is contained in:
Timothy Jaeryang Baek
2026-02-27 16:01:57 -06:00
parent 2d82d260cc
commit 179a4ad9ea
11 changed files with 399 additions and 99 deletions
+28 -10
View File
@@ -42,12 +42,12 @@
functions,
selectedFolder,
pinnedChats,
showEmbeds
showEmbeds,
selectedTerminalId
} from '$lib/stores';
import { WEBUI_API_BASE_URL } from '$lib/constants';
import {
convertMessagesToHistory,
copyToClipboard,
@@ -140,13 +140,18 @@
let selectedToolIds = [];
let selectedFilterIds = [];
let imageGenerationEnabled = false;
let webSearchEnabled = false;
let codeInterpreterEnabled = false;
// Auto-inject terminal servers into selected tool IDs so they act like toggled-on tools
// Auto-inject direct terminal servers into selected tool IDs so they act like toggled-on tools
// System terminals (with id field) are handled server-side via terminal_id, not as direct tool servers
$: if ($terminalServers && $terminalServers.length > 0) {
const terminalIds = $terminalServers.map((_, i) => `direct_server:terminal_${i}`);
const directTerminalServers = $terminalServers.filter((t) => !t.id);
const terminalIds = directTerminalServers.map(
(_, i) => `direct_server:terminal_${$terminalServers.indexOf(directTerminalServers[i])}`
);
const missingIds = terminalIds.filter((id) => !selectedToolIds.includes(id));
if (missingIds.length > 0) {
selectedToolIds = [...selectedToolIds, ...missingIds];
@@ -155,7 +160,10 @@
// Remove disabled terminal servers from selectedToolIds automatically
$: if (selectedToolIds.length > 0) {
const terminalIds = ($terminalServers ?? []).map((_, i) => `direct_server:terminal_${i}`);
const directTerminalServers = ($terminalServers ?? []).filter((t) => !t.id);
const terminalIds = directTerminalServers.map(
(_, i) => `direct_server:terminal_${($terminalServers ?? []).indexOf(directTerminalServers[i])}`
);
const invalidTerminalIds = selectedToolIds.filter(
(id) => id.startsWith('direct_server:terminal_') && !terminalIds.includes(id)
);
@@ -354,9 +362,12 @@
selectedToolIds = selectedToolIds.filter((id) => !id.startsWith('direct_server:'));
}
// Auto-inject terminal servers
// Auto-inject direct terminal servers (system ones are handled via terminal_id)
if ($terminalServers && $terminalServers.length > 0) {
const terminalIds = $terminalServers.map((_, i) => `direct_server:terminal_${i}`);
const directTerminalServers = $terminalServers.filter((t) => !t.id);
const terminalIds = directTerminalServers.map(
(_, i) => `direct_server:terminal_${$terminalServers.indexOf(directTerminalServers[i])}`
);
selectedToolIds = [...new Set([...selectedToolIds, ...terminalIds])];
}
@@ -650,6 +661,14 @@
audioQueue.set(new AudioQueue(document.getElementById('audioElement')));
// Reset direct terminal enabled states — selectedTerminalId starts null on every page load
if ($settings?.terminalServers?.some((s) => s.enabled)) {
settings.set({
...$settings,
terminalServers: ($settings.terminalServers ?? []).map((s) => ({ ...s, enabled: false }))
});
}
pageSubscribe = page.subscribe(async (p) => {
if (p.url.pathname === '/') {
await tick();
@@ -2130,9 +2149,8 @@
});
}
// Determine the active terminal (first accessible backend terminal, or user-configured)
const activeTerminal = $terminalServers?.[0] ?? null;
const activeTerminalId = activeTerminal?.id ?? null;
// Use the user-selected terminal from the dropdown
const activeTerminalId = $selectedTerminalId ?? null;
const res = await generateOpenAIChatCompletion(
localStorage.token,