From 222b27183fd9603637df2c31459dc74cc988ade9 Mon Sep 17 00:00:00 2001 From: Anish Sarkar <104695310+AnishSarkar22@users.noreply.github.com> Date: Wed, 29 Apr 2026 22:01:28 +0530 Subject: [PATCH] feat(chat): improve error handling and logging for premium quota exhaustion in chat operations --- .../new-chat/[[...chat_id]]/page.tsx | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/surfsense_web/app/dashboard/[search_space_id]/new-chat/[[...chat_id]]/page.tsx b/surfsense_web/app/dashboard/[search_space_id]/new-chat/[[...chat_id]]/page.tsx index 6ec587f91..a2985ab0c 100644 --- a/surfsense_web/app/dashboard/[search_space_id]/new-chat/[[...chat_id]]/page.tsx +++ b/surfsense_web/app/dashboard/[search_space_id]/new-chat/[[...chat_id]]/page.tsx @@ -1018,8 +1018,12 @@ export default function NewChatPage() { } return; } - console.error("[NewChatPage] Chat error:", error); const premiumQuotaAlertMessage = getPinnedPremiumQuotaErrorMessage(error); + if (premiumQuotaAlertMessage) { + console.info("[NewChatPage] Premium quota exhausted:", error); + } else { + console.error("[NewChatPage] Chat error:", error); + } // Track chat error trackChatError( @@ -1329,8 +1333,12 @@ export default function NewChatPage() { if (error instanceof Error && error.name === "AbortError") { return; } - console.error("[NewChatPage] Resume error:", error); const premiumQuotaAlertMessage = getPinnedPremiumQuotaErrorMessage(error); + if (premiumQuotaAlertMessage) { + console.info("[NewChatPage] Premium quota exhausted during resume:", error); + } else { + console.error("[NewChatPage] Resume error:", error); + } if (premiumQuotaAlertMessage) { setPremiumAlertForThread({ threadId: resumeThreadId, @@ -1357,6 +1365,7 @@ export default function NewChatPage() { pendingInterrupt, messages, searchSpaceId, + currentUser?.id, tokenUsageStore, toolsWithUI, setPremiumAlertForThread, @@ -1683,8 +1692,12 @@ export default function NewChatPage() { return; } batcher.dispose(); - console.error("[NewChatPage] Regeneration error:", error); const premiumQuotaAlertMessage = getPinnedPremiumQuotaErrorMessage(error); + if (premiumQuotaAlertMessage) { + console.info("[NewChatPage] Premium quota exhausted during regeneration:", error); + } else { + console.error("[NewChatPage] Regeneration error:", error); + } trackChatError( searchSpaceId, threadId, @@ -1717,6 +1730,7 @@ export default function NewChatPage() { searchSpaceId, messages, disabledTools, + currentUser?.id, tokenUsageStore, toolsWithUI, setPremiumAlertForThread,