diff --git a/src/components/Shakespeare/ChatPane.tsx b/src/components/Shakespeare/ChatPane.tsx index 60452679..fa2bf03a 100644 --- a/src/components/Shakespeare/ChatPane.tsx +++ b/src/components/Shakespeare/ChatPane.tsx @@ -235,14 +235,6 @@ BASE_DOMAIN=nostrdeploy.com`); // Reset auto-fix attempts on successful completion autoFixAttemptsRef.current = 0; - // Add a system message to indicate auto-build is starting - const autoBuildMessage: AIMessage = { - id: generateId(), - role: 'assistant', - content: '✅ Agent completed successfully. Auto-building project and checking deployment preview...', - }; - addMessage(autoBuildMessage); - // Auto-build the project after a short delay setTimeout(async () => { try { @@ -267,14 +259,6 @@ BASE_DOMAIN=nostrdeploy.com`); window.dispatchEvent(buildCompleteEvent); console.log('Dispatched buildComplete event for project:', projectId); - // Add success message - const buildSuccessMessage: AIMessage = { - id: generateId(), - role: 'assistant', - content: '🎉 Project built successfully! Checking deployment preview...', - }; - addMessage(buildSuccessMessage); - // Switch to preview tab to show the updated deployment setTimeout(() => { try { @@ -291,14 +275,14 @@ BASE_DOMAIN=nostrdeploy.com`); previewButton.click(); console.log('Switched to preview tab'); - // Add final success message + // Add single consolidated success message setTimeout(() => { - const finalMessage: AIMessage = { + const successMessage: AIMessage = { id: generateId(), role: 'assistant', - content: '👀 Preview updated! Your changes are now visible in the preview pane.', + content: '✅ Agent completed successfully. Project built and preview updated!', }; - addMessage(finalMessage); + addMessage(successMessage); }, 1000); } else { console.log('Preview tab button not found'); @@ -306,7 +290,7 @@ BASE_DOMAIN=nostrdeploy.com`); const manualSwitchMessage: AIMessage = { id: generateId(), role: 'assistant', - content: '📱 Project built successfully! Switch to the "Preview" tab to see your changes.', + content: '✅ Agent completed successfully. Project built! Switch to the "Preview" tab to see your changes.', }; addMessage(manualSwitchMessage); } @@ -373,7 +357,7 @@ Please fix this issue and ensure the project builds successfully.`, // Get the current messages state using ref to ensure we have the latest const currentMessages = messagesRef.current; - const aiMessages: AIMessage[] = [...currentMessages, autoBuildMessage, buildErrorMessage, errorFixRequest]; + const aiMessages: AIMessage[] = [...currentMessages, buildErrorMessage, errorFixRequest]; await createAIChat(projectId, aiMessages); } catch (fixError) { console.error('Failed to get AI to fix build error:', fixError); @@ -388,7 +372,7 @@ Please fix this issue and ensure the project builds successfully.`, } }, 1000); } - }, 1000); // Small delay to show the auto-build message first + }, 1000); // Small delay before starting auto-build } }, tools: { diff --git a/src/components/ai/AssistantContent.test.tsx b/src/components/ai/AssistantContent.test.tsx index d1427da1..de80f30e 100644 --- a/src/components/ai/AssistantContent.test.tsx +++ b/src/components/ai/AssistantContent.test.tsx @@ -9,7 +9,7 @@ describe('AssistantContent', () => { describe('Build Action Detection', () => { it('should render build action for string content with auto-build message', () => { - const content = '✅ Agent completed successfully. Auto-building project and checking deployment preview...'; + const content = '✅ Agent completed successfully. Project built and preview updated!'; render( @@ -22,7 +22,7 @@ describe('AssistantContent', () => { }); it('should render build action for string content with build success message', () => { - const content = '🎉 Project built successfully! Checking deployment preview...'; + const content = '✅ Agent completed successfully. Project built! Switch to the "Preview" tab to see your changes.'; render( @@ -35,7 +35,7 @@ describe('AssistantContent', () => { }); it('should render build action for string content with preview updated message', () => { - const content = '👀 Preview updated! Your changes are now visible in the preview pane.'; + const content = '✅ Agent completed successfully. Project built and preview updated!'; render( @@ -62,7 +62,7 @@ describe('AssistantContent', () => { it('should render build action for array content with auto-build message', () => { const content = [ - { type: 'text' as const, text: '✅ Agent completed successfully. Auto-building project and checking deployment preview...' } + { type: 'text' as const, text: '✅ Agent completed successfully. Project built and preview updated!' } ]; render( diff --git a/src/components/ai/AssistantContent.tsx b/src/components/ai/AssistantContent.tsx index 9a60816a..1500cdd2 100644 --- a/src/components/ai/AssistantContent.tsx +++ b/src/components/ai/AssistantContent.tsx @@ -81,7 +81,7 @@ export const AssistantContent = memo(({ content, toolResults = [] }: AssistantCo let isLoading = false; // Determine action type and status based on full text content - if (fullText.includes('Auto-build') || fullText.includes('Auto-building')) { + if (fullText.includes('Auto-build') || fullText.includes('Auto-building') || (fullText.includes('Agent completed successfully') && fullText.includes('built'))) { actionType = 'auto-build'; } else if (fullText.includes('Auto-fix') || fullText.includes('Fixing')) { actionType = 'auto-fix';