From 71f43978803c08934cdb2adacf271e5b4e305026 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Wed, 24 Sep 2025 00:25:47 -0500 Subject: [PATCH] Make clicking "Fix error" send the message automatically --- src/components/Shakespeare/ChatPane.tsx | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/components/Shakespeare/ChatPane.tsx b/src/components/Shakespeare/ChatPane.tsx index 641544ec..0fd5dc39 100644 --- a/src/components/Shakespeare/ChatPane.tsx +++ b/src/components/Shakespeare/ChatPane.tsx @@ -266,12 +266,6 @@ export const ChatPane = forwardRef(({ } }, [aiModelAlert.hasError, consoleAlert.hasError, scrollToBottom]); - const suggestErrorFix = useCallback((errorMessage: string, errorCount: number) => { - const errorText = errorCount === 1 ? 'this error' : 'these errors'; - setInput(`The user gets ${errorText} in the app now: ${errorMessage}\n\nCan you identify the problem and create a concise fix.`); - }, []); - - // Check for autostart parameter and trigger AI generation useEffect(() => { const autostart = searchParams.get('autostart'); @@ -401,7 +395,7 @@ export const ChatPane = forwardRef(({ setAttachedFiles(prev => [...prev, ...files]); }; - const handleSend = async () => { + const send = useCallback(async (input: string, attachedFiles: File[]) => { if ((!input.trim() && attachedFiles.length === 0) || isLoading) return; // If AI is not configured, show onboarding dialog @@ -463,7 +457,11 @@ export const ChatPane = forwardRef(({ console.error('AI chat error:', error); // Error handling is done in the useAIChat hook and SessionManager } - }; + }, [addRecentlyUsedModel, fs, isConfigured, isLoading, providerModel, sendMessage]); + + const handleSend = useCallback(async () => { + await send(input, attachedFiles); + }, [input, attachedFiles, send]); const handleKeyDown = (e: React.KeyboardEvent) => { if (e.key === 'Enter' && !e.shiftKey) { @@ -527,7 +525,9 @@ export const ChatPane = forwardRef(({ } }), [internalStartNewSession]); - + const suggestErrorFix = useCallback(async (errorMessage: string) => { + await send(errorMessage, attachedFiles); + }, [send, attachedFiles]); return (
@@ -625,7 +625,7 @@ export const ChatPane = forwardRef(({ onDismiss={consoleAlert.dismiss} action={{ label: `Fix ${consoleAlert.errorCount === 1 ? 'error' : 'errors'}`, - onClick: () => suggestErrorFix(consoleAlert.errorSummary || '', consoleAlert.errorCount) + onClick: () => suggestErrorFix(consoleAlert.errorSummary || '') }} /> )}