This commit is contained in:
Timothy Jaeryang Baek committed 2026-11-13 19:23:38 +09:00
1 parent 8256fc722a
commit 3bfc168d6c
1 file changed
+22 -15
+22 -15
View File
@@ -95,6 +95,10 @@
};
const refreshTerminalServers = async () => {
if (!$config?.features?.enable_tool_servers) {
terminalServers.set([]);
return;
}
const userId = $user?.id;
if (!userId || !localStorage.token) return;
const systemTerminals = await getTerminalServers(localStorage.token);
@@ -108,14 +112,6 @@
);
};
const setToolServers = async () => {
if (!$config?.features?.enable_tool_servers) {
terminalServers.set([]);
return;
}
await refreshTerminalServers();
};
const setBanners = async () => {
const bannersData = await getBanners(localStorage.token);
banners.set(bannersData);
@@ -134,7 +130,7 @@
getBackendConfig().then((value) => config.set(value)),
setModels(),
setTools(),
setToolServers(),
refreshTerminalServers(),
getSkills(localStorage.token).then((value) => skills.set(value))
]);
for (const result of results) {
@@ -255,13 +251,15 @@
return;
}
selectedTerminalId.set(
$config?.features?.enable_tool_servers ? (localStorage.selectedTerminalId ?? null) : null
);
setToolServers().catch((e) => {
console.error('Failed to load tool servers:', e);
await refreshTerminalServers().catch((e) => {
console.error('Failed to load terminals:', e);
});
selectedTerminalId.set(
$config?.features?.enable_tool_servers &&
$terminalServers?.some((terminal) => terminal.id === localStorage.selectedTerminalId)
? localStorage.selectedTerminalId
: null
);
const setupKeyboardShortcuts = () => {
document.addEventListener('keydown', async (event) => {
@@ -429,6 +427,15 @@
loaded = true;
});
$: if (
loaded &&
$selectedTerminalId &&
$terminalServers !== null &&
!$terminalServers.some((terminal) => terminal.id === $selectedTerminalId)
) {
selectedTerminalId.set(null);
}
// `$page.url` must be referenced here: `$:` only tracks variables used in
// the statement itself, and reads inside openSettingsFromUrl don't count —
// without it, client-side navigations to `?settings=...` are never handled.