update
Browse filesFiles changed (2)
231 unmodified lines23223323423523523623723839 unmodified lines2782792802812822832842852862872882892902912921 unmodified line294295296288297298299300363 unmodified lines66466566666766865966967067167267334 unmodified lines708709710700711712713714715704716717718719231 unmodified lines } };
const handleSendMessage = async (message: string, overrideLanguage?: Language, overrideModel?: string) => { const handleSendMessage = async (message: string, overrideLanguage?: Language, overrideModel?: string, overrideRepoId?: string) => { if (!isAuthenticated) { alert('Please sign in with HuggingFace first! Click the "Sign in with Hugging Face" button in the header.'); return;39 unmodified lines setGeneratedCode('');
// Prepare request with enhanced query that includes current code // Use overrideRepoId if provided (from import/duplicate), otherwise use currentRepoId from state const effectiveRepoId = overrideRepoId || currentRepoId || undefined; console.log('[SendMessage] ========== GENERATION REQUEST =========='); console.log('[SendMessage] overrideRepoId:', overrideRepoId); console.log('[SendMessage] currentRepoId:', currentRepoId); console.log('[SendMessage] effectiveRepoId (will use):', effectiveRepoId); console.log('[SendMessage] =========================================='); const request: CodeGenerationRequest = { query: enhancedMessage, language: language,1 unmodified line provider: 'auto', history: messages.map((m) => [m.role, m.content]), agent_mode: false, existing_repo_id: currentRepoId || undefined, // Pass duplicated/imported space ID for auto-deploy existing_repo_id: effectiveRepoId, // Pass duplicated/imported space ID for auto-deploy };
const assistantMessage: Message = {363 unmodified lines // Only set as current repo if user owns it if (username && importedRepoId.startsWith(`${username}/`)) { console.log('[Import] β
β
β
BEFORE setCurrentRepoId - currentRepoId was:', currentRepoId); setCurrentRepoId(importedRepoId); console.log('[Import] β
β
β
SETTING currentRepoId to:', importedRepoId); console.log('[Import] β
β
β
CALLED setCurrentRepoId with:', importedRepoId); console.log('[Import] β
β
β
Note: State update is async, currentRepoId will update later'); } else { // User doesn't own the imported space, clear current repo setCurrentRepoId(null);34 unmodified lines };
// Handle landing page prompt submission const handleLandingPageStart = async (prompt: string, language: Language, modelId: string) => { const handleLandingPageStart = async (prompt: string, language: Language, modelId: string, repoId?: string) => { // Hide landing page immediately for smooth transition setShowLandingPage(false); // Send the message with the selected language and model // Pass repoId if provided (for imported/duplicated spaces) await handleSendMessage(prompt, language, modelId); await handleSendMessage(prompt, language, modelId, repoId); };
// Resize handlers for chat sidebar (desktop only)14 unmodified lines1516171818192021312 unmodified lines33433533633733833934034134234334411 unmodified lines35635735835936036136235736336436536614 unmodified linesimport type { OAuthUserInfo } from '@/lib/auth';
interface LandingPageProps { onStart: (prompt: string, language: Language, modelId: string) => void; onStart: (prompt: string, language: Language, modelId: string, repoId?: string) => void; onImport?: (code: string, language: Language, importUrl?: string) => void; isAuthenticated: boolean; initialLanguage?: Language;312 unmodified lines // Import code and trigger AI redesign (don't duplicate yet) if (onImport && onStart) { // First import the code (this will set currentRepoId in the parent) onImport(result.code, result.language || 'html', redesignUrl); // Send redesign prompt with code context // Pass the repoId directly to avoid React state timing issues setTimeout(async () => { const redesignPrompt = `I have existing code in the editor that I imported from ${redesignUrl}. Please redesign it to make it look better with minimal components needed, mobile friendly, and modern design.
11 unmodified lines${createPR ? '\n\nNote: After generating the redesign, I will create a Pull Request on the original space.' : '\n\nNote: After generating the redesign, I can deploy to a new space or duplicate the original space.'}`; if (onStart) { // Extract repo ID from URL to pass directly (avoids state timing issues) const spaceMatch = redesignUrl.match(/huggingface\.co\/spaces\/([^\/\s\)]+\/[^\/\s\)]+)/); const extractedRepoId = spaceMatch ? spaceMatch[1] : undefined; console.log('[Redesign] Passing repoId to onStart:', extractedRepoId); onStart(redesignPrompt, result.language || 'html', selectedModel); onStart(redesignPrompt, result.language || 'html', selectedModel, extractedRepoId); } if (createPR) {frontend/src/app/page.tsx+17-5
frontend/src/components/LandingPage.tsx+8-2