From 186cb52f31976f77cfbc8df503b283f93f943cd0 Mon Sep 17 00:00:00 2001 From: Roo Code Date: Fri, 25 Jul 2025 18:39:13 +0000 Subject: [PATCH 1/2] fix: hide Test ErrorBoundary button in production mode - Added NODE_ENV environment variable to vite config - Conditionally render the Test ErrorBoundary button only in development mode - This prevents users from accidentally triggering test errors in production Fixes #6215 --- webview-ui/src/components/settings/About.tsx | 10 ++++++---- webview-ui/vite.config.ts | 1 + 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/webview-ui/src/components/settings/About.tsx b/webview-ui/src/components/settings/About.tsx index 01979060c31..83c87b1abb2 100644 --- a/webview-ui/src/components/settings/About.tsx +++ b/webview-ui/src/components/settings/About.tsx @@ -110,10 +110,12 @@ export const About = ({ telemetrySetting, setTelemetrySetting, className, ...pro {/* Test button for ErrorBoundary - only visible in development */} - + {process.env.NODE_ENV === "development" && ( + + )} diff --git a/webview-ui/vite.config.ts b/webview-ui/vite.config.ts index 0579344a22c..c0328efce84 100644 --- a/webview-ui/vite.config.ts +++ b/webview-ui/vite.config.ts @@ -59,6 +59,7 @@ export default defineConfig(({ mode }) => { const define: Record = { "process.platform": JSON.stringify(process.platform), + "process.env.NODE_ENV": JSON.stringify(mode), "process.env.VSCODE_TEXTMATE_DEBUG": JSON.stringify(process.env.VSCODE_TEXTMATE_DEBUG), "process.env.PKG_NAME": JSON.stringify(pkg.name), "process.env.PKG_VERSION": JSON.stringify(pkg.version), From a0402df4eb451095244d1573c47d15abbbeb7793 Mon Sep 17 00:00:00 2001 From: Roo Code Date: Mon, 28 Jul 2025 15:11:10 +0000 Subject: [PATCH 2/2] fix: remove Test ErrorBoundary button completely and revert vite config changes - Removed Test ErrorBoundary button and all related code from About.tsx - Reverted NODE_ENV changes in vite.config.ts as requested by @daniel-lxs --- webview-ui/src/components/settings/About.tsx | 34 +------------------- webview-ui/vite.config.ts | 1 - 2 files changed, 1 insertion(+), 34 deletions(-) diff --git a/webview-ui/src/components/settings/About.tsx b/webview-ui/src/components/settings/About.tsx index 83c87b1abb2..5075643e6e1 100644 --- a/webview-ui/src/components/settings/About.tsx +++ b/webview-ui/src/components/settings/About.tsx @@ -1,4 +1,4 @@ -import { HTMLAttributes, useState } from "react" +import { HTMLAttributes } from "react" import { useAppTranslation } from "@/i18n/TranslationContext" import { Trans } from "react-i18next" import { Info, Download, Upload, TriangleAlert } from "lucide-react" @@ -22,33 +22,9 @@ type AboutProps = HTMLAttributes & { export const About = ({ telemetrySetting, setTelemetrySetting, className, ...props }: AboutProps) => { const { t } = useAppTranslation() - const [shouldThrowError, setShouldThrowError] = useState(false) - - // Function to trigger error for testing ErrorBoundary - const triggerTestError = () => { - setShouldThrowError(true) - } - - // Named function to make it easier to identify in stack traces - function throwTestError() { - // Intentionally cause a type error by accessing a property on undefined - const obj: any = undefined - obj.nonExistentMethod() - } - - // Test component that throws an error when shouldThrow is true - const ErrorThrower = ({ shouldThrow = false }) => { - if (shouldThrow) { - // Use a named function to make it easier to identify in stack traces - throwTestError() - } - return null - } return (
- {/* Test component that throws an error when shouldThrow is true */} - {t("settings:footer.settings.reset")} - - {/* Test button for ErrorBoundary - only visible in development */} - {process.env.NODE_ENV === "development" && ( - - )}
diff --git a/webview-ui/vite.config.ts b/webview-ui/vite.config.ts index c0328efce84..0579344a22c 100644 --- a/webview-ui/vite.config.ts +++ b/webview-ui/vite.config.ts @@ -59,7 +59,6 @@ export default defineConfig(({ mode }) => { const define: Record = { "process.platform": JSON.stringify(process.platform), - "process.env.NODE_ENV": JSON.stringify(mode), "process.env.VSCODE_TEXTMATE_DEBUG": JSON.stringify(process.env.VSCODE_TEXTMATE_DEBUG), "process.env.PKG_NAME": JSON.stringify(pkg.name), "process.env.PKG_VERSION": JSON.stringify(pkg.version),