fix(KB): silent maybe-later error + redundant prompt-state refetches (PR #899 review)

- KbPolicyPromptBanner: add onError toast to maybeLaterMutation so a
    failed policy save surfaces to the user instead of looking like a
    broken button (banner would otherwise reappear on next chat open
    with no explanation).
  - KbPolicyPromptBanner: set staleTime: Infinity on the prompt-state
    query. For users who already picked a policy (the vast majority),
    the result is effectively immutable per session — the mutations
    invalidate the key when it actually changes.
This commit is contained in:
Jake Turner 2026-05-17 06:03:30 +00:00 committed by Jake Turner
parent fd153b46b8
commit 9a684a5e62
1 changed files with 7 additions and 0 deletions

View File

@ -37,6 +37,7 @@ export default function KbPolicyPromptBanner() {
const { data: promptState } = useQuery({
queryKey: ['kbPolicyPromptState'],
queryFn: () => api.getKbPolicyPromptState(),
staleTime: Infinity,
})
const indexNowMutation = useMutation({
@ -72,6 +73,12 @@ export default function KbPolicyPromptBanner() {
queryClient.invalidateQueries({ queryKey: ['kbPolicyPromptState'] })
queryClient.invalidateQueries({ queryKey: ['ingestPolicy'] })
},
onError: (error: any) => {
addNotification({
type: 'error',
message: error?.message || 'Could not save your choice. Try again.',
})
},
})
if (!promptState?.shouldPrompt) return null