From 75e961d2819d429a8c38f0610d9d2ec123a4403b Mon Sep 17 00:00:00 2001 From: Chad Curtis Date: Thu, 25 Sep 2025 05:12:18 +0000 Subject: [PATCH] Simplify error handling and fix message. --- src/components/Quilly.tsx | 15 +-------------- src/components/Shakespeare/ChatPane.tsx | 18 ++---------------- 2 files changed, 3 insertions(+), 30 deletions(-) diff --git a/src/components/Quilly.tsx b/src/components/Quilly.tsx index cbdf7c7b..ffb746a0 100644 --- a/src/components/Quilly.tsx +++ b/src/components/Quilly.tsx @@ -37,21 +37,8 @@ export function Quilly({ error, onDismiss, onNewChat, onOpenModelSelector, onReq const renderBody = (error: Error): ErrorBody => { // Handle Project Preview Console Errors if (error instanceof ProjectPreviewConsoleError) { - const errorCount = error.logs.filter(log => log.level === 'error').length; - const warningCount = error.logs.filter(log => log.level === 'warn').length; - - let message = 'I noticed some console errors in your project preview.'; - - if (errorCount > 1) { - message = `I noticed ${errorCount} console errors in your project preview.`; - } else if (errorCount === 1 && warningCount > 0) { - message = `I noticed ${errorCount} console error and ${warningCount} warning${warningCount > 1 ? 's' : ''} in your project preview.`; - } else if (warningCount > 0) { - message = `I noticed ${warningCount} console warning${warningCount > 1 ? 's' : ''} in your project preview.`; - } - return { - message: message + ' Would you like me to take a look and help fix them?', + message: 'I noticed some console errors in your project preview. Would you like me to take a look and help fix them?', action: { label: 'Help fix errors', onClick: () => { diff --git a/src/components/Shakespeare/ChatPane.tsx b/src/components/Shakespeare/ChatPane.tsx index b12cda7c..efcb6cd1 100644 --- a/src/components/Shakespeare/ChatPane.tsx +++ b/src/components/Shakespeare/ChatPane.tsx @@ -203,22 +203,8 @@ export const ChatPane = forwardRef(({ }); // Handle console error help requests - const handleConsoleErrorHelp = useCallback((error: ProjectPreviewConsoleError) => { - const errorMessages = error.logs.filter(log => log.level === 'error').map(log => log.message); - const warningMessages = error.logs.filter(log => log.level === 'warn').map(log => log.message); - - let consoleOutput = ''; - if (errorMessages.length > 0) { - consoleOutput += `Console Errors:\n${errorMessages.map(msg => `- ${msg}`).join('\n')}\n\n`; - } - if (warningMessages.length > 0) { - consoleOutput += `Console Warnings:\n${warningMessages.map(msg => `- ${msg}`).join('\n')}\n\n`; - } - - const helpMessage = `I noticed some console issues in the project preview:\n\n${consoleOutput}Could you help me understand what's causing these issues and how to fix them?`; - - // Send the console error information as a user message - sendMessage(helpMessage, providerModel); + const handleConsoleErrorHelp = useCallback(() => { + sendMessage('Read the console messages and fix any errors present.', providerModel); }, [sendMessage, providerModel]); // Use external loading state if provided, otherwise use internal state