mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-17 23:52:24 +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
@@ -302,6 +302,29 @@ export const vaccinationDependentKeys = [
|
||||
queryKeys.measurementReminders(),
|
||||
];
|
||||
|
||||
/**
|
||||
* Keys invalidated when an input of the `ai` block on `GET /api/auth/me`
|
||||
* changes: the account's own provider (key, local model, compatible endpoint,
|
||||
* Codex sign-in), the fallback chain, the central-Codex opt-in, a consent
|
||||
* receipt granted or withdrawn, a module switch, Hide Coach, and, for the
|
||||
* admin's own session, the operator's assistant switches, server key, central
|
||||
* Codex and module availability.
|
||||
*
|
||||
* Every AI surface reads its capability from that block, so a write that
|
||||
* changes an input without evicting `authMe()` leaves the surface on the old
|
||||
* answer: a freshly configured provider stays "not set up" until a reload, a
|
||||
* removed one keeps offering AI work the server then refuses. The provider and
|
||||
* insights roots ride along because they render the same state in detail.
|
||||
*
|
||||
* `ai-input-invalidation-guard.test.ts` holds every client write to one of
|
||||
* those endpoints to this bundle.
|
||||
*/
|
||||
export const aiInputDependentKeys = [
|
||||
queryKeys.authMe(),
|
||||
queryKeys.userAiProvider(),
|
||||
queryKeys.insightsRoot(),
|
||||
];
|
||||
|
||||
/**
|
||||
* Invalidate every key in the bundle in parallel. Use this from mutation
|
||||
* `onSuccess` handlers so the call site stays a one-liner instead of repeating
|
||||
|
||||
Reference in new issue
Block a user