mirror of
https://github.com/jamiepine/voicebox.git
synced 2026-09-20 15:20:39 -07:00
perf(captures): stop polling readiness once both models are green
useQuery was firing GET /capture/readiness every 5s forever, and also on every window focus. Once stt.ready and llm.ready are both true the answer can only change when the user swaps a model in settings, and useSettings already invalidates the query on that path — the polling was pure noise. Gate both refetchInterval and refetchOnWindowFocus on "not fully ready" so we fall silent once the checklist is green.
This commit is contained in:
@@ -61,8 +61,18 @@ export function useDictationReadiness(): DictationReadiness {
|
||||
const { data, isLoading, refetch } = useQuery({
|
||||
queryKey: ['capture-readiness'],
|
||||
queryFn: () => apiClient.getCaptureReadiness(),
|
||||
refetchInterval: READINESS_POLL_INTERVAL_MS,
|
||||
refetchOnWindowFocus: true,
|
||||
// Poll only while a model is still missing/downloading. Once both are
|
||||
// green the endpoint's answer can't change until the user swaps models
|
||||
// in settings, and that path invalidates the query explicitly from
|
||||
// useSettings. refetchOnWindowFocus stays gated to the same condition.
|
||||
refetchInterval: (query) => {
|
||||
const d = query.state.data;
|
||||
return d && d.stt.ready && d.llm.ready ? false : READINESS_POLL_INTERVAL_MS;
|
||||
},
|
||||
refetchOnWindowFocus: (query) => {
|
||||
const d = query.state.data;
|
||||
return !(d && d.stt.ready && d.llm.ready);
|
||||
},
|
||||
});
|
||||
|
||||
// On the web build there's no TCC layer — treat both as granted so the
|
||||
|
||||
Reference in New Issue
Block a user