Fix the behavior of the create project textarea

This commit is contained in:
Alex Gleason committed 2025-08-25 16:59:51 -05:00
1 parent 857bea336a
commit 53e07d1f26
6 files changed
+315 -50

No files matched your search

+23
View File
@@ -1,4 +1,5 @@
import { useState, useRef, useEffect } from 'react';
import { useSearchParams } from 'react-router-dom';
import { Button } from '@/components/ui/button';
import { Input } from '@/components/ui/input';
import { Textarea } from '@/components/ui/textarea';
@@ -40,6 +41,7 @@ export function ChatPane({ projectId, projectName }: ChatPaneProps) {
const { isConfigured } = useAISettings();
const { fs: browserFS } = useFS();
const { runtime } = useJSRuntime();
const [searchParams, setSearchParams] = useSearchParams();
// Initialize AI chat with tools
const cwd = `/projects/${projectId}`;
@@ -94,6 +96,7 @@ When creating new components or pages, follow the existing patterns in the codeb
streamingMessage,
isLoading,
sendMessage,
startGeneration,
stopGeneration,
startNewSession,
} = useAIChat({
@@ -107,6 +110,26 @@ When creating new components or pages, follow the existing patterns in the codeb
}
});
// Check for autostart parameter and trigger AI generation
useEffect(() => {
const autostart = searchParams.get('autostart');
if (autostart === 'true' && isConfigured && messages.length > 0 && !isLoading) {
const lastMessage = messages[messages.length - 1];
// If the last message is from the user, auto-start the AI
if (lastMessage.role === 'user') {
// Clear the autostart parameter so it doesn't trigger again
const newSearchParams = new URLSearchParams(searchParams);
newSearchParams.delete('autostart');
setSearchParams(newSearchParams, { replace: true });
// Start AI generation
startGeneration(providerModel.trim() || undefined);
}
}
}, [searchParams, setSearchParams, isConfigured, messages, isLoading, startGeneration, providerModel]);
// Keep-alive functionality to prevent tab throttling during AI processing
const { updateMetadata } = useKeepAlive({
enabled: isLoading || isBuildLoading || isDeployLoading,