From 3e89b06f25d60811e85d336cb3123c8fba7d3b2a Mon Sep 17 00:00:00 2001 From: KJ7LNW <93454819+KJ7LNW@users.noreply.github.com> Date: Wed, 23 Jul 2025 05:45:35 -0700 Subject: [PATCH] debug: Add ErrorBoundary component for better error handling (#5085) Co-authored-by: Eric Wheeler --- pnpm-lock.yaml | 14 ++ src/.vscodeignore | 2 +- src/core/webview/ClineProvider.ts | 4 +- .../webview/__tests__/ClineProvider.spec.ts | 4 +- src/esbuild.mjs | 2 +- webview-ui/package.json | 2 + webview-ui/src/App.tsx | 36 +++- webview-ui/src/__tests__/App.spec.tsx | 84 ++++++++ .../src/__tests__/ErrorBoundary.spec.tsx | 88 ++++++++ webview-ui/src/components/ErrorBoundary.tsx | 98 +++++++++ .../__tests__/ErrorBoundary.spec.tsx | 97 +++++++++ webview-ui/src/components/settings/About.tsx | 32 ++- webview-ui/src/i18n/locales/ca/common.json | 8 + webview-ui/src/i18n/locales/de/common.json | 8 + webview-ui/src/i18n/locales/en/common.json | 8 + webview-ui/src/i18n/locales/es/common.json | 8 + webview-ui/src/i18n/locales/fr/common.json | 8 + webview-ui/src/i18n/locales/hi/common.json | 8 + webview-ui/src/i18n/locales/id/common.json | 8 + webview-ui/src/i18n/locales/it/common.json | 8 + webview-ui/src/i18n/locales/ja/common.json | 8 + webview-ui/src/i18n/locales/ko/common.json | 8 + webview-ui/src/i18n/locales/nl/common.json | 8 + webview-ui/src/i18n/locales/pl/common.json | 8 + webview-ui/src/i18n/locales/pt-BR/common.json | 8 + webview-ui/src/i18n/locales/ru/common.json | 8 + webview-ui/src/i18n/locales/tr/common.json | 8 + webview-ui/src/i18n/locales/vi/common.json | 8 + webview-ui/src/i18n/locales/zh-CN/common.json | 8 + webview-ui/src/i18n/locales/zh-TW/common.json | 8 + .../utils/__tests__/sourceMapUtils.spec.ts | 88 ++++++++ webview-ui/src/utils/sourceMapInitializer.ts | 180 +++++++++++++++++ webview-ui/src/utils/sourceMapUtils.ts | 190 ++++++++++++++++++ .../src/vite-plugins/sourcemapPlugin.ts | 116 +++++++++++ webview-ui/vite.config.ts | 10 +- 35 files changed, 1175 insertions(+), 16 deletions(-) create mode 100644 webview-ui/src/__tests__/ErrorBoundary.spec.tsx create mode 100644 webview-ui/src/components/ErrorBoundary.tsx create mode 100644 webview-ui/src/components/__tests__/ErrorBoundary.spec.tsx create mode 100644 webview-ui/src/utils/__tests__/sourceMapUtils.spec.ts create mode 100644 webview-ui/src/utils/sourceMapInitializer.ts create mode 100644 webview-ui/src/utils/sourceMapUtils.ts create mode 100644 webview-ui/src/vite-plugins/sourcemapPlugin.ts diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 5030055fea..0b94b47a1e 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1036,6 +1036,9 @@ importers: source-map: specifier: ^0.7.4 version: 0.7.4 + stacktrace-js: + specifier: ^2.0.2 + version: 2.0.2 styled-components: specifier: ^6.1.13 version: 6.1.18(react-dom@18.3.1(react@18.3.1))(react@18.3.1) @@ -1097,6 +1100,9 @@ importers: '@types/shell-quote': specifier: ^1.7.5 version: 1.7.5 + '@types/stacktrace-js': + specifier: ^2.0.3 + version: 2.0.3 '@types/vscode-webview': specifier: ^1.57.5 version: 1.57.5 @@ -3888,6 +3894,10 @@ packages: '@types/stack-utils@2.0.3': resolution: {integrity: sha512-9aEbYZ3TbYMznPdcdr3SmIrLXwC/AKZXQeCf9Pgao5CKb8CyHuEX5jzWPTkvregvhRJHcpRO6BFoGW9ycaOkYw==} + '@types/stacktrace-js@2.0.3': + resolution: {integrity: sha512-B6JnMic4NAZ4mLWmRi4RvayCN2HZQvpcVF0MkoqubtuZx1AQB0/kRlrngGiocEPyO7R+TFocTEoLKQ0HzmEOPw==} + deprecated: This is a stub types definition. stacktrace-js provides its own type definitions, so you do not need this installed. + '@types/stream-chain@2.1.0': resolution: {integrity: sha512-guDyAl6s/CAzXUOWpGK2bHvdiopLIwpGu8v10+lb9hnQOyo4oj/ZUQFOvqFjKGsE3wJP1fpIesCcMvbXuWsqOg==} @@ -13090,6 +13100,10 @@ snapshots: '@types/stack-utils@2.0.3': {} + '@types/stacktrace-js@2.0.3': + dependencies: + stacktrace-js: 2.0.2 + '@types/stream-chain@2.1.0': dependencies: '@types/node': 20.19.1 diff --git a/src/.vscodeignore b/src/.vscodeignore index 8eed90df07..9695b185a6 100644 --- a/src/.vscodeignore +++ b/src/.vscodeignore @@ -14,7 +14,7 @@ !dist # Include the built webview -**/*.map +!**/*.map !webview-ui/audio !webview-ui/build/assets/*.js !webview-ui/build/assets/*.ttf diff --git a/src/core/webview/ClineProvider.ts b/src/core/webview/ClineProvider.ts index 6231f08167..96d42ec3d1 100644 --- a/src/core/webview/ClineProvider.ts +++ b/src/core/webview/ClineProvider.ts @@ -682,7 +682,7 @@ export class ClineProvider `img-src ${webview.cspSource} https://storage.googleapis.com https://img.clerk.com data:`, `media-src ${webview.cspSource}`, `script-src 'unsafe-eval' ${webview.cspSource} https://* https://*.posthog.com http://${localServerUrl} http://0.0.0.0:${localPort} 'nonce-${nonce}'`, - `connect-src https://* https://*.posthog.com ws://${localServerUrl} ws://0.0.0.0:${localPort} http://${localServerUrl} http://0.0.0.0:${localPort}`, + `connect-src ${webview.cspSource} https://* https://*.posthog.com ws://${localServerUrl} ws://0.0.0.0:${localPort} http://${localServerUrl} http://0.0.0.0:${localPort}`, ] return /*html*/ ` @@ -764,7 +764,7 @@ export class ClineProvider - +