From 9a684a5e6288174e272f806131f2f94b0b1299f0 Mon Sep 17 00:00:00 2001 From: Jake Turner Date: Sun, 17 May 2026 06:03:30 +0000 Subject: [PATCH] fix(KB): silent maybe-later error + redundant prompt-state refetches (PR #899 review) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 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. --- admin/inertia/components/chat/KbPolicyPromptBanner.tsx | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/admin/inertia/components/chat/KbPolicyPromptBanner.tsx b/admin/inertia/components/chat/KbPolicyPromptBanner.tsx index 3daa654..b2fd99b 100644 --- a/admin/inertia/components/chat/KbPolicyPromptBanner.tsx +++ b/admin/inertia/components/chat/KbPolicyPromptBanner.tsx @@ -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