fix(captures): refetch readiness immediately after STT/LLM model swap

useCaptureSettings updated its own cache optimistically but never
invalidated ['capture-readiness'], so for up to 5 s (the poll interval)
after switching stt_model or llm_model the checklist kept showing the
previous model's ready/missing state. The backend endpoint resolves
the model live on each call — it was just the frontend cache that
lagged. Invalidate in onSettled only when the patch touched a model
field, so unrelated updates (chord keys, toggles) don't pay for a
refetch.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
This commit is contained in:
James Pine
2026-04-23 19:41:10 -07:00
co-authored by Claude Opus 4.7
parent 66ca56bb0b
commit ef63faf33a
+8 -1
View File
@@ -42,8 +42,15 @@ export function useCaptureSettings() {
queryClient.setQueryData(CAPTURE_SETTINGS_KEY, ctx.previous);
}
},
onSettled: (data) => {
onSettled: (data, _err, patch) => {
if (data) queryClient.setQueryData(CAPTURE_SETTINGS_KEY, data);
// /capture/readiness resolves stt_model / llm_model live on each
// call, but its cached response keeps serving the previous
// model's state until the next 5 s poll. Invalidate on model
// swaps so the readiness checklist re-checks immediately.
if (patch.stt_model !== undefined || patch.llm_model !== undefined) {
queryClient.invalidateQueries({ queryKey: ['capture-readiness'] });
}
},
});