This commit is contained in:
Timothy Jaeryang Baek
2026-03-02 15:01:10 -06:00
parent 4f6cb771f1
commit 1a2b360d3d
4 changed files with 18 additions and 49 deletions
+4 -41
View File
@@ -146,33 +146,7 @@
let webSearchEnabled = false;
let codeInterpreterEnabled = false;
// 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 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];
}
}
// Remove disabled terminal servers from selectedToolIds automatically
$: if (selectedToolIds.length > 0) {
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)
);
if (invalidTerminalIds.length > 0) {
selectedToolIds = selectedToolIds.filter((id) => !invalidTerminalIds.includes(id));
}
}
let showCommands = false;
@@ -354,25 +328,12 @@
[...(model?.info?.meta?.toolIds ?? [])].filter((id) => $tools.find((t) => t.id === id))
)
];
} else if (
$settings?.tools &&
$settings.tools.some((id) => !id.startsWith('direct_server:terminal_'))
) {
} else if ($settings?.tools) {
selectedToolIds = $settings.tools;
} else {
// Don't wipe existing terminal servers if no default tool IDs
selectedToolIds = selectedToolIds.filter((id) => !id.startsWith('direct_server:'));
}
// Auto-inject direct terminal servers (system ones are handled via terminal_id)
if ($terminalServers && $terminalServers.length > 0) {
const directTerminalServers = $terminalServers.filter((t) => !t.id);
const terminalIds = directTerminalServers.map(
(_, i) => `direct_server:terminal_${$terminalServers.indexOf(directTerminalServers[i])}`
);
selectedToolIds = [...new Set([...selectedToolIds, ...terminalIds])];
}
// Set Default Filters (Toggleable only)
if (model?.info?.meta?.defaultFilterIds) {
selectedFilterIds = model.info.meta.defaultFilterIds.filter((id) =>
@@ -2210,7 +2171,9 @@
tool_servers: [
...($toolServers ?? []).filter(
(server, idx) => toolServerIds.includes(idx) || toolServerIds.includes(server?.id)
)
),
// Direct terminal servers — always included when enabled (not routed through selectedToolIds)
...($terminalServers ?? []).filter((t) => !t.id)
],
features: getFeatures(),
variables: {
+3 -7
View File
@@ -1636,12 +1636,10 @@
{/if}
<div class="ml-1 flex gap-1.5">
{#if (selectedToolIds ?? []).filter((id) => !id.startsWith('direct_server:terminal_')).length > 0}
{#if (selectedToolIds ?? []).length > 0}
<Tooltip
content={$i18n.t('{{COUNT}} Available Tools', {
COUNT: (selectedToolIds ?? []).filter(
(id) => !id.startsWith('direct_server:terminal_')
).length
COUNT: (selectedToolIds ?? []).length
})}
>
<button
@@ -1655,9 +1653,7 @@
<Wrench className="size-4" strokeWidth="1.75" />
<span class="text-sm">
{(selectedToolIds ?? []).filter(
(id) => !id.startsWith('direct_server:terminal_')
).length}
{(selectedToolIds ?? []).length}
</span>
</button>
</Tooltip>
@@ -97,7 +97,7 @@
}
selectedToolIds = selectedToolIds.filter(
(id) => Object.keys(tools).includes(id) || id.startsWith('direct_server:terminal_')
(id) => Object.keys(tools).includes(id)
);
};
</script>
+10
View File
@@ -239,6 +239,16 @@
connect();
};
// Reconnect when the selected terminal changes
$: if ($selectedTerminalId !== undefined && term) {
// Clear the terminal screen and reconnect to the new server
disconnect();
term.clear();
if ($selectedTerminalId) {
connect();
}
}
onMount(() => {
initTerminal();
});