mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-16 07:13:29 +00:00
fix(ai): refresh the account's AI answer after every change to its inputs
Every AI surface reads its capability from the ai block on /api/auth/me, but setting up or removing a provider, signing in to or out of Codex, saving the fallback chain, the central-Codex opt-in, the local-OCR switch, a minted consent receipt, the admin's server key and central Codex, and a guardian's save inside a managed record evicted only their own reads. The surfaces stayed on the old answer until a reload. All of these writes, and the ones that already refreshed the payload (consent, modules, Hide Coach, the operator's switches), now evict one bundle, aiInputDependentKeys. A structural test holds every client write to those endpoints to it.
This commit is contained in:
1 parent
03ecb5bd52
commit
676bb2eff7
23 files changed
+260
-62
No files matched your search
@@ -16,7 +16,11 @@ import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
||||
|
||||
import { apiFetch, apiGet, apiPatch, apiPost } from "@/lib/api/api-fetch";
|
||||
import { ocrImageToText } from "@/lib/labs/local-ocr";
|
||||
import { queryKeys } from "@/lib/query-keys";
|
||||
import {
|
||||
aiInputDependentKeys,
|
||||
invalidateKeys,
|
||||
queryKeys,
|
||||
} from "@/lib/query-keys";
|
||||
import type {
|
||||
OcrCapabilityDto,
|
||||
OcrCommitResponseDto,
|
||||
@@ -149,6 +153,8 @@ export function useUpdateLabsLocalOcr() {
|
||||
queryClient.setQueryData(queryKeys.labsLocalOcr(), data);
|
||||
// The toggle changes whether text-mode scanning is available.
|
||||
queryClient.invalidateQueries({ queryKey: queryKeys.ocrCapability() });
|
||||
// It is also a provider input of the `labsOcr` capability on `/me`.
|
||||
void invalidateKeys(queryClient, aiInputDependentKeys);
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user