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:
James Pine
2026-04-23 21:20:50 -07:00
parent c7cd7fd0fd
commit 271ecd924b
+12 -2
View File
@@ -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