Skip to content

An AI-powered search engine with a generative UI

fix: address PR review comments

Yoshiki Miura0c26f4960285
diff --git a/components/chat.tsx b/components/chat.tsx
index a7b21556..f3220374 100644
--- a/components/chat.tsx
+++ b/components/chat.tsx
@@ -112,24 +112,33 @@ export function Chat({
},
onError: error => {
// Handle rate limiting errors from Vercel WAF
- if (
+ // Check for status codes in error message or specific rate limit indicators
+ const errorMessage = error.message?.toLowerCase() || ''
+ const isRateLimit =
error.message?.includes('429') ||
- error.message?.toLowerCase().includes('rate limit') ||
- error.message?.toLowerCase().includes('too many requests')
- ) {
+ errorMessage.includes('rate limit') ||
+ errorMessage.includes('too many requests')
+
+ if (isRateLimit) {
setErrorModal({
open: true,
type: 'rate-limit',
message: error.message,
details: undefined
})
- } else if (error.message?.includes('401')) {
+ } else if (
+ error.message?.includes('401') ||
+ errorMessage.includes('unauthorized')
+ ) {
setErrorModal({
open: true,
type: 'auth',
message: error.message
})
- } else if (error.message?.includes('403')) {
+ } else if (
+ error.message?.includes('403') ||
+ errorMessage.includes('forbidden')
+ ) {
setErrorModal({
open: true,
type: 'forbidden',
diff --git a/components/error-modal.tsx b/components/error-modal.tsx
index 2bcc81b5..1c628735 100644
--- a/components/error-modal.tsx
+++ b/components/error-modal.tsx
@@ -95,7 +95,7 @@ export function ErrorModal({
</div>
)}
</DialogHeader>
- <DialogFooter className="flex-col gap-2 sm:flex-col">
+ <DialogFooter className="flex-col gap-2">
{onRetry && error.type !== 'rate-limit' && (
<Button
onClick={() => {