From ceed060c6f5da15a32feebaace26e0b5124f9e90 Mon Sep 17 00:00:00 2001 From: Will Chen Date: Mon, 3 Nov 2025 09:34:18 -0800 Subject: [PATCH] Don't show upgrade button for non AI streaming errors (#1680) > [!NOTE] > Show the upgrade button only for AI streaming errors by checking a shared error prefix; introduce and use a shared constant for consistent error messages. > > - **Chat UI** > - Update `ChatErrorBox.tsx` to display "Upgrade to Dyad Pro" only when `error` includes `AI_STREAMING_ERROR_MESSAGE_PREFIX` and user is not Pro (still hides on `TypeError: terminated`). > - **IPC/Streaming** > - In `chat_stream_handlers.ts`, prefix emitted streaming errors with `AI_STREAMING_ERROR_MESSAGE_PREFIX` instead of hardcoded text for consistency. > - **Shared** > - Add `AI_STREAMING_ERROR_MESSAGE_PREFIX` in `src/shared/texts.ts` and import where needed. > > Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 83b1aa3555a3c1e710ee644f7bfb64cabc0ff5e6. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot). --- src/components/chat/ChatErrorBox.tsx | 19 +++++++++++-------- src/ipc/handlers/chat_stream_handlers.ts | 3 ++- src/shared/texts.ts | 2 ++ 3 files changed, 15 insertions(+), 9 deletions(-) create mode 100644 src/shared/texts.ts diff --git a/src/components/chat/ChatErrorBox.tsx b/src/components/chat/ChatErrorBox.tsx index 0a65921..e7d7eb4 100644 --- a/src/components/chat/ChatErrorBox.tsx +++ b/src/components/chat/ChatErrorBox.tsx @@ -1,4 +1,5 @@ import { IpcClient } from "@/ipc/ipc_client"; +import { AI_STREAMING_ERROR_MESSAGE_PREFIX } from "@/shared/texts"; import { X, ExternalLink as ExternalLinkIcon, @@ -99,14 +100,16 @@ export function ChatErrorBox({ {error}
- {!isDyadProEnabled && !error.includes("TypeError: terminated") && ( - - Upgrade to Dyad Pro - - )} + {!isDyadProEnabled && + error.includes(AI_STREAMING_ERROR_MESSAGE_PREFIX) && + !error.includes("TypeError: terminated") && ( + + Upgrade to Dyad Pro + + )} Read docs diff --git a/src/ipc/handlers/chat_stream_handlers.ts b/src/ipc/handlers/chat_stream_handlers.ts index 0c196c9..4b73965 100644 --- a/src/ipc/handlers/chat_stream_handlers.ts +++ b/src/ipc/handlers/chat_stream_handlers.ts @@ -80,6 +80,7 @@ import { replacePromptReference } from "../utils/replacePromptReference"; import { mcpManager } from "../utils/mcp_manager"; import z from "zod"; import { isTurboEditsV2Enabled } from "@/lib/schemas"; +import { AI_STREAMING_ERROR_MESSAGE_PREFIX } from "@/shared/texts"; type AsyncIterableStream = AsyncIterable & ReadableStream; @@ -853,7 +854,7 @@ This conversation includes one or more image attachments. When the user uploads : ""; event.sender.send("chat:response:error", { chatId: req.chatId, - error: `Sorry, there was an error from the AI: ${requestIdPrefix}${message}`, + error: `${AI_STREAMING_ERROR_MESSAGE_PREFIX}${requestIdPrefix}${message}`, }); // Clean up the abort controller activeStreams.delete(req.chatId); diff --git a/src/shared/texts.ts b/src/shared/texts.ts new file mode 100644 index 0000000..689d351 --- /dev/null +++ b/src/shared/texts.ts @@ -0,0 +1,2 @@ +export const AI_STREAMING_ERROR_MESSAGE_PREFIX = + "Sorry, there was an error from the AI: ";