update
Browse files186 unmodified lines1871881891901911921931901911921931941951961971981992002012022032041981992002052022062072082092062102112122132144 unmodified lines21922022121722222322422522122622722822934 unmodified lines2642652662622672682692652702712722739 unmodified lines2832842852812862872882891 unmodified line291292293289294295296297298299300296301302303304186 unmodified lines return; }
// CRITICAL: Wait for username to be loaded from auth if (!username) { console.warn('[Deploy] Username not loaded yet, checking auth...'); // Try to get username from auth status // Check authentication status if (!isAuthenticated) { alert('Please log in to deploy your app. Click the "Sign in with Hugging Face" button in the header.'); return; }
// Ensure username is loaded let currentUsername = username; if (!currentUsername) { console.warn('[Deploy] Username not loaded yet, fetching...'); try { const authStatus = await apiClient.getAuthStatus(); if (authStatus.username) { currentUsername = authStatus.username; setUsername(authStatus.username); // Retry deployment after setting username setTimeout(() => handleDeploy(), 100); return; } else { alert('Please log in to deploy your app'); alert('Could not get username. Please try logging out and back in.'); return; } } catch (e) { alert('Please log in to deploy your app'); console.error('[Deploy] Error getting username:', e); alert('Could not get username. Please try logging out and back in.'); return; } }4 unmodified lines // Look for previous deployment or imported space in history console.log('[Deploy] ========== DEBUG START =========='); console.log('[Deploy] Total messages in history:', messages.length); console.log('[Deploy] Current username:', username); console.log('[Deploy] Current username:', currentUsername); console.log('[Deploy] Auth status:', isAuthenticated ? 'authenticated' : 'not authenticated'); console.log('[Deploy] Messages:', JSON.stringify(messages, null, 2)); if (messages.length > 0 && username) { if (messages.length > 0 && currentUsername) { console.log('[Deploy] Scanning message history FORWARD (oldest first) - MATCHING GRADIO LOGIC...'); console.log('[Deploy] Total messages to scan:', messages.length); 34 unmodified lines if (match) { const importedSpace = match[1]; console.log('[Deploy] Extracted imported space:', importedSpace); console.log('[Deploy] Checking ownership - user:', username, 'space:', importedSpace); console.log('[Deploy] Checking ownership - user:', currentUsername, 'space:', importedSpace); // Only use if user owns it (EXACT GRADIO LOGIC) if (importedSpace.startsWith(`${username}/`)) { if (importedSpace.startsWith(`${currentUsername}/`)) { existingSpace = importedSpace; console.log('[Deploy] β
β
β
USER OWNS - Will update:', existingSpace); break;9 unmodified lines } else { console.log('[Deploy] Skipping scan - no messages or no username'); console.log('[Deploy] Messages length:', messages.length); console.log('[Deploy] Username:', username); console.log('[Deploy] Username:', currentUsername); } console.log('[Deploy] ========== DEBUG END ==========');
1 unmodified line console.log('[Deploy] π ABOUT TO DEPLOY:'); console.log('[Deploy] - Language:', selectedLanguage); console.log('[Deploy] - existing_repo_id:', existingSpace || 'None (new deployment)'); console.log('[Deploy] - Username:', username); console.log('[Deploy] - Username:', currentUsername);
// Auto-generate space name (never prompt user) let spaceName = undefined; // undefined = backend will auto-generate
try { console.log('[Deploy] ========== DEPLOY START (Gradio-style history parsing) =========='); console.log('[Deploy] Username:', username); console.log('[Deploy] Username:', currentUsername); console.log('[Deploy] Existing space from history:', existingSpace); console.log('[Deploy] Will create new space?', !existingSpace); console.log('[Deploy] =================================================================');frontend/src/app/page.tsx+21-16