update
Browse files186 unmodified lines1871881891901911921931941951961971981992002012022032042052062072082094 unmodified lines21421521621721821922022122222322434 unmodified lines2592602612622632642652662672689 unmodified lines2782792802812822832841 unmodified line286287288289290291292293294295296297298299186 unmodified linesreturn;}// CRITICAL: Wait for username to be loaded from authif (!username) {console.warn('[Deploy] Username not loaded yet, checking auth...');// Try to get username from auth statustry {const authStatus = await apiClient.getAuthStatus();if (authStatus.username) {setUsername(authStatus.username);// Retry deployment after setting usernamesetTimeout(() => handleDeploy(), 100);return;} else {alert('Please log in to deploy your app');return;}} catch (e) {alert('Please log in to deploy your app');return;}}4 unmodified lines// Look for previous deployment or imported space in historyconsole.log('[Deploy] ========== DEBUG START ==========');console.log('[Deploy] Total messages in history:', messages.length);console.log('[Deploy] Current username:', username);console.log('[Deploy] Auth status:', isAuthenticated ? 'authenticated' : 'not authenticated');console.log('[Deploy] Messages:', JSON.stringify(messages, null, 2));if (messages.length > 0 && username) {console.log('[Deploy] Scanning message history FORWARD (oldest first) - MATCHING GRADIO LOGIC...');console.log('[Deploy] Total messages to scan:', messages.length);34 unmodified linesif (match) {const importedSpace = match[1];console.log('[Deploy] Extracted imported space:', importedSpace);console.log('[Deploy] Checking ownership - user:', username, 'space:', importedSpace);// Only use if user owns it (EXACT GRADIO LOGIC)if (importedSpace.startsWith(`${username}/`)) {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] ========== DEBUG END ==========');1 unmodified lineconsole.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);// Auto-generate space name (never prompt user)let spaceName = undefined; // undefined = backend will auto-generatetry {console.log('[Deploy] ========== DEPLOY START (Gradio-style history parsing) ==========');console.log('[Deploy] Username:', username);console.log('[Deploy] Existing space from history:', existingSpace);console.log('[Deploy] Will create new space?', !existingSpace);console.log('[Deploy] =================================================================');186 unmodified lines1871881891901911921931941951961971981992002012022032042052062072082092102112122132144 unmodified lines21922022122222322422522622722822934 unmodified lines2642652662672682692702712722739 unmodified lines2832842852862872882891 unmodified line291292293294295296297298299300301302303304186 unmodified linesreturn;}// Check authentication statusif (!isAuthenticated) {alert('Please log in to deploy your app. Click the "Sign in with Hugging Face" button in the header.');return;}// Ensure username is loadedlet 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);} else {alert('Could not get username. Please try logging out and back in.');return;}} catch (e) {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 historyconsole.log('[Deploy] ========== DEBUG START ==========');console.log('[Deploy] Total messages in history:', messages.length);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 && currentUsername) {console.log('[Deploy] Scanning message history FORWARD (oldest first) - MATCHING GRADIO LOGIC...');console.log('[Deploy] Total messages to scan:', messages.length);34 unmodified linesif (match) {const importedSpace = match[1];console.log('[Deploy] Extracted imported space:', importedSpace);console.log('[Deploy] Checking ownership - user:', currentUsername, 'space:', importedSpace);// Only use if user owns it (EXACT GRADIO LOGIC)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:', currentUsername);}console.log('[Deploy] ========== DEBUG END ==========');1 unmodified lineconsole.log('[Deploy] π ABOUT TO DEPLOY:');console.log('[Deploy] - Language:', selectedLanguage);console.log('[Deploy] - existing_repo_id:', existingSpace || 'None (new deployment)');console.log('[Deploy] - Username:', currentUsername);// Auto-generate space name (never prompt user)let spaceName = undefined; // undefined = backend will auto-generatetry {console.log('[Deploy] ========== DEPLOY START (Gradio-style history parsing) ==========');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