From 7eee0386ff81a709b323ce06e147c93b7416e13b Mon Sep 17 00:00:00 2001 From: Eduard Ruzga Date: Tue, 24 Dec 2024 23:35:44 +0200 Subject: [PATCH] feat: catch errors from web container preview and show in actionable alert so user can send them to AI for fixing (#856) * Catch errors from web container * Show fix error popup on errors in preview * Remove unneeded action type * PR comments * Cleanup urls in stacktrace --------- Co-authored-by: Anirban Kar --- README.md | 1 + app/components/chat/ChatAlert.tsx | 22 ++++++++++++++-------- app/lib/webcontainer/index.ts | 28 ++++++++++++++++++++++++++-- app/types/actions.ts | 1 + app/utils/stacktrace.ts | 27 +++++++++++++++++++++++++++ 5 files changed, 69 insertions(+), 10 deletions(-) create mode 100644 app/utils/stacktrace.ts diff --git a/README.md b/README.md index 5a4896e..c50f427 100644 --- a/README.md +++ b/README.md @@ -62,6 +62,7 @@ bolt.diy was originally started by [Cole Medin](https://www.youtube.com/@ColeMed - ✅ Detect package.json and commands to auto install & run preview for folder and git import (@wonderwhy-er) - ✅ Selection tool to target changes visually (@emcconnell) - ✅ Detect terminal Errors and ask bolt to fix it (@thecodacus) +- ✅ Detect preview Errors and ask bolt to fix it (@wonderwhy-er) - ✅ Add Starter Template Options (@thecodacus) - ⬜ **HIGH PRIORITY** - Prevent bolt from rewriting files as often (file locking and diffs) - ⬜ **HIGH PRIORITY** - Better prompting for smaller LLMs (code window sometimes doesn't start) diff --git a/app/components/chat/ChatAlert.tsx b/app/components/chat/ChatAlert.tsx index 21c12b7..674bbc8 100644 --- a/app/components/chat/ChatAlert.tsx +++ b/app/components/chat/ChatAlert.tsx @@ -9,7 +9,13 @@ interface Props { } export default function ChatAlert({ alert, clearAlert, postMessage }: Props) { - const { description, content } = alert; + const { description, content, source } = alert; + + const isPreview = source === 'preview'; + const title = isPreview ? 'Preview Error' : 'Terminal Error'; + const message = isPreview + ? 'We encountered an error while running the preview. Would you like Bolt to analyze and help resolve this issue?' + : 'We encountered an error while running terminal commands. Would you like Bolt to analyze and help resolve this issue?'; return ( @@ -38,8 +44,7 @@ export default function ChatAlert({ alert, clearAlert, postMessage }: Props) { transition={{ delay: 0.1 }} className={`text-sm font-medium text-bolt-elements-textPrimary`} > - {/* {title} */} - Opps There is an error + {title} -

- We encountered an error while running terminal commands. Would you like Bolt to analyze and help resolve - this issue? -

+

{message}

{description && (
Error: {description} @@ -67,7 +69,11 @@ export default function ChatAlert({ alert, clearAlert, postMessage }: Props) { >