fix api tools logic (#6144)

This commit is contained in:
centdix
2025-07-08 17:44:58 +02:00
committed by GitHub
parent f4bb9eb573
commit 3151afabc0
2 changed files with 9 additions and 11 deletions
@@ -87,10 +87,6 @@
$effect(() => {
aiChatManager.updateMode(untrack(() => aiChatManager.mode))
})
$effect(() => {
aiChatManager.loadApiTools()
})
</script>
<svelte:window
@@ -89,13 +89,15 @@ class AIChatManager {
open = $derived(chatState.size > 0)
async loadApiTools() {
if (this.apiTools.length === 0) {
this.apiTools = await loadApiTools()
if (this.mode === AIMode.NAVIGATOR) {
this.tools = [this.changeModeTool, ...navigatorTools, ...this.apiTools]
}
}
constructor() {
loadApiTools()
.then((tools) => {
this.apiTools = tools
})
.catch((err) => {
console.error('Error loading api tools', err)
this.apiTools = []
})
}
setAiChatInput(aiChatInput: AIChatInput | null) {