Simplify error handling and fix message.

This commit is contained in:
Chad Curtis committed 2025-09-25 05:12:18 +00:00
1 parent 93e992f128
commit 75e961d281
2 files changed
+3 -30

No files matched your search

+1 -14
View File
@@ -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: () => {
+2 -16
View File
@@ -203,22 +203,8 @@ export const ChatPane = forwardRef<ChatPaneRef, ChatPaneProps>(({
});
// 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