feat(gui): wire Footer + Settings to daemon over IPC (closes the gap from a6a098d)
a6a098d added daemon-side IPC handlers (SwitchLlm, ReloadLlm, QueryHealth)
but the GUI was still talking only to its own process. This commit wires
the frontend to actually use those handlers.
frontend/src/lib/ipc.ts
- New DaemonHealth interface + daemonHealth: writable<DaemonHealth | null>.
- handleEvent: "health_snapshot" case fills daemonHealth from daemon's IpcEvent.
- New senders:
switchDaemonLlm(backend) → action "switch_llm"
reloadDaemonLlm() → action "reload_llm"
queryDaemonHealth() → action "query_health"
frontend/src/stores.ts
- Re-exports daemonHealth + the three new senders + DaemonHealth type.
frontend/src/components/Footer.svelte
- Polls every 5s but PREFERS IPC: if daemon connected, calls queryDaemonHealth
(snapshot arrives via daemonHealth store).
- Falls back to invoke("get_active_backends") if daemon offline — shows
GUI-process view in that case, with the chip tooltip distinguishing
"daemon" vs "gui-process" source.
frontend/src/routes/settings/index.svelte (AI Backends tab)
- applyLlmBackend now ALSO fires switchDaemonLlm so the running listener
picks the new backend without restart.
- "Auto" (empty) path calls reloadDaemonLlm so daemon re-reads DB.
End-to-end flow now:
GUI dropdown → set_llm_backend (Tauri, persists DB + swaps GUI proc)
↘ switchDaemonLlm (IPC, swaps daemon proc too)
↘ daemon emits health_snapshot on next QueryHealth
↘ daemonHealth store updates
↘ Footer chips re-render with new state
Build: cargo build --release -p jarvis-gui green.
This commit is contained in:
parent
a6a098de15
commit
a2dfadf5c1
4 changed files with 90 additions and 6 deletions
|
|
@ -12,6 +12,21 @@ export const lastRecognizedText = writable("")
|
|||
export const lastExecutedCommand = writable("")
|
||||
export const lastError = writable("")
|
||||
|
||||
// Daemon runtime state — populated by health_snapshot events from jarvis-app.
|
||||
// `null` means we never received one (daemon not running or doesn't support
|
||||
// QueryHealth yet).
|
||||
export interface DaemonHealth {
|
||||
tts_backend: string
|
||||
llm_backend: string
|
||||
llm_model: string | null
|
||||
active_profile: string
|
||||
memory_facts: number
|
||||
scheduled_tasks: number
|
||||
language: string
|
||||
version: string | null
|
||||
}
|
||||
export const daemonHealth = writable<DaemonHealth | null>(null)
|
||||
|
||||
// ### CONNECTION ###
|
||||
|
||||
const IPC_URL = "ws://127.0.0.1:9712"
|
||||
|
|
@ -133,6 +148,19 @@ function handleEvent(data: any) {
|
|||
// bring window to foreground
|
||||
revealWindow()
|
||||
break
|
||||
|
||||
case "health_snapshot":
|
||||
daemonHealth.set({
|
||||
tts_backend: data.tts_backend ?? "none",
|
||||
llm_backend: data.llm_backend ?? "none",
|
||||
llm_model: data.llm_model ?? null,
|
||||
active_profile: data.active_profile ?? "default",
|
||||
memory_facts: data.memory_facts ?? 0,
|
||||
scheduled_tasks: data.scheduled_tasks ?? 0,
|
||||
language: data.language ?? "ru",
|
||||
version: data.version ?? null,
|
||||
})
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -175,6 +203,24 @@ export function sendTextCommand(text: string): boolean {
|
|||
return sendAction("text_command", { text })
|
||||
}
|
||||
|
||||
// IMBA: hot-swap daemon's LLM backend over IPC so the running listener picks
|
||||
// the new backend immediately. Returns false if daemon not connected.
|
||||
export function switchDaemonLlm(backend: "groq" | "ollama"): boolean {
|
||||
return sendAction("switch_llm", { backend })
|
||||
}
|
||||
|
||||
// Tell daemon to re-read llm_backend from settings DB. Use after GUI changes
|
||||
// the DB independently.
|
||||
export function reloadDaemonLlm(): boolean {
|
||||
return sendAction("reload_llm")
|
||||
}
|
||||
|
||||
// Ask daemon for a runtime snapshot. Daemon will respond with a
|
||||
// "health_snapshot" event which fills the `daemonHealth` store.
|
||||
export function queryDaemonHealth(): boolean {
|
||||
return sendAction("query_health")
|
||||
}
|
||||
|
||||
async function revealWindow() {
|
||||
try {
|
||||
const window = getCurrentWindow()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue