Spaces:
Running
Running
update
Browse files- frontend/src/app/page.tsx +21 -16
frontend/src/app/page.tsx
CHANGED
|
@@ -187,23 +187,28 @@ export default function Home() {
|
|
| 187 |
return;
|
| 188 |
}
|
| 189 |
|
| 190 |
-
//
|
| 191 |
-
if (!
|
| 192 |
-
|
| 193 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 194 |
try {
|
| 195 |
const authStatus = await apiClient.getAuthStatus();
|
| 196 |
if (authStatus.username) {
|
|
|
|
| 197 |
setUsername(authStatus.username);
|
| 198 |
-
// Retry deployment after setting username
|
| 199 |
-
setTimeout(() => handleDeploy(), 100);
|
| 200 |
-
return;
|
| 201 |
} else {
|
| 202 |
-
alert('Please
|
| 203 |
return;
|
| 204 |
}
|
| 205 |
} catch (e) {
|
| 206 |
-
|
|
|
|
| 207 |
return;
|
| 208 |
}
|
| 209 |
}
|
|
@@ -214,11 +219,11 @@ export default function Home() {
|
|
| 214 |
// Look for previous deployment or imported space in history
|
| 215 |
console.log('[Deploy] ========== DEBUG START ==========');
|
| 216 |
console.log('[Deploy] Total messages in history:', messages.length);
|
| 217 |
-
console.log('[Deploy] Current username:',
|
| 218 |
console.log('[Deploy] Auth status:', isAuthenticated ? 'authenticated' : 'not authenticated');
|
| 219 |
console.log('[Deploy] Messages:', JSON.stringify(messages, null, 2));
|
| 220 |
|
| 221 |
-
if (messages.length > 0 &&
|
| 222 |
console.log('[Deploy] Scanning message history FORWARD (oldest first) - MATCHING GRADIO LOGIC...');
|
| 223 |
console.log('[Deploy] Total messages to scan:', messages.length);
|
| 224 |
|
|
@@ -259,10 +264,10 @@ export default function Home() {
|
|
| 259 |
if (match) {
|
| 260 |
const importedSpace = match[1];
|
| 261 |
console.log('[Deploy] Extracted imported space:', importedSpace);
|
| 262 |
-
console.log('[Deploy] Checking ownership - user:',
|
| 263 |
|
| 264 |
// Only use if user owns it (EXACT GRADIO LOGIC)
|
| 265 |
-
if (importedSpace.startsWith(`${
|
| 266 |
existingSpace = importedSpace;
|
| 267 |
console.log('[Deploy] β
β
β
USER OWNS - Will update:', existingSpace);
|
| 268 |
break;
|
|
@@ -278,7 +283,7 @@ export default function Home() {
|
|
| 278 |
} else {
|
| 279 |
console.log('[Deploy] Skipping scan - no messages or no username');
|
| 280 |
console.log('[Deploy] Messages length:', messages.length);
|
| 281 |
-
console.log('[Deploy] Username:',
|
| 282 |
}
|
| 283 |
console.log('[Deploy] ========== DEBUG END ==========');
|
| 284 |
|
|
@@ -286,14 +291,14 @@ export default function Home() {
|
|
| 286 |
console.log('[Deploy] π ABOUT TO DEPLOY:');
|
| 287 |
console.log('[Deploy] - Language:', selectedLanguage);
|
| 288 |
console.log('[Deploy] - existing_repo_id:', existingSpace || 'None (new deployment)');
|
| 289 |
-
console.log('[Deploy] - Username:',
|
| 290 |
|
| 291 |
// Auto-generate space name (never prompt user)
|
| 292 |
let spaceName = undefined; // undefined = backend will auto-generate
|
| 293 |
|
| 294 |
try {
|
| 295 |
console.log('[Deploy] ========== DEPLOY START (Gradio-style history parsing) ==========');
|
| 296 |
-
console.log('[Deploy] Username:',
|
| 297 |
console.log('[Deploy] Existing space from history:', existingSpace);
|
| 298 |
console.log('[Deploy] Will create new space?', !existingSpace);
|
| 299 |
console.log('[Deploy] =================================================================');
|
|
|
|
| 187 |
return;
|
| 188 |
}
|
| 189 |
|
| 190 |
+
// Check authentication status
|
| 191 |
+
if (!isAuthenticated) {
|
| 192 |
+
alert('Please log in to deploy your app. Click the "Sign in with Hugging Face" button in the header.');
|
| 193 |
+
return;
|
| 194 |
+
}
|
| 195 |
+
|
| 196 |
+
// Ensure username is loaded
|
| 197 |
+
let currentUsername = username;
|
| 198 |
+
if (!currentUsername) {
|
| 199 |
+
console.warn('[Deploy] Username not loaded yet, fetching...');
|
| 200 |
try {
|
| 201 |
const authStatus = await apiClient.getAuthStatus();
|
| 202 |
if (authStatus.username) {
|
| 203 |
+
currentUsername = authStatus.username;
|
| 204 |
setUsername(authStatus.username);
|
|
|
|
|
|
|
|
|
|
| 205 |
} else {
|
| 206 |
+
alert('Could not get username. Please try logging out and back in.');
|
| 207 |
return;
|
| 208 |
}
|
| 209 |
} catch (e) {
|
| 210 |
+
console.error('[Deploy] Error getting username:', e);
|
| 211 |
+
alert('Could not get username. Please try logging out and back in.');
|
| 212 |
return;
|
| 213 |
}
|
| 214 |
}
|
|
|
|
| 219 |
// Look for previous deployment or imported space in history
|
| 220 |
console.log('[Deploy] ========== DEBUG START ==========');
|
| 221 |
console.log('[Deploy] Total messages in history:', messages.length);
|
| 222 |
+
console.log('[Deploy] Current username:', currentUsername);
|
| 223 |
console.log('[Deploy] Auth status:', isAuthenticated ? 'authenticated' : 'not authenticated');
|
| 224 |
console.log('[Deploy] Messages:', JSON.stringify(messages, null, 2));
|
| 225 |
|
| 226 |
+
if (messages.length > 0 && currentUsername) {
|
| 227 |
console.log('[Deploy] Scanning message history FORWARD (oldest first) - MATCHING GRADIO LOGIC...');
|
| 228 |
console.log('[Deploy] Total messages to scan:', messages.length);
|
| 229 |
|
|
|
|
| 264 |
if (match) {
|
| 265 |
const importedSpace = match[1];
|
| 266 |
console.log('[Deploy] Extracted imported space:', importedSpace);
|
| 267 |
+
console.log('[Deploy] Checking ownership - user:', currentUsername, 'space:', importedSpace);
|
| 268 |
|
| 269 |
// Only use if user owns it (EXACT GRADIO LOGIC)
|
| 270 |
+
if (importedSpace.startsWith(`${currentUsername}/`)) {
|
| 271 |
existingSpace = importedSpace;
|
| 272 |
console.log('[Deploy] β
β
β
USER OWNS - Will update:', existingSpace);
|
| 273 |
break;
|
|
|
|
| 283 |
} else {
|
| 284 |
console.log('[Deploy] Skipping scan - no messages or no username');
|
| 285 |
console.log('[Deploy] Messages length:', messages.length);
|
| 286 |
+
console.log('[Deploy] Username:', currentUsername);
|
| 287 |
}
|
| 288 |
console.log('[Deploy] ========== DEBUG END ==========');
|
| 289 |
|
|
|
|
| 291 |
console.log('[Deploy] π ABOUT TO DEPLOY:');
|
| 292 |
console.log('[Deploy] - Language:', selectedLanguage);
|
| 293 |
console.log('[Deploy] - existing_repo_id:', existingSpace || 'None (new deployment)');
|
| 294 |
+
console.log('[Deploy] - Username:', currentUsername);
|
| 295 |
|
| 296 |
// Auto-generate space name (never prompt user)
|
| 297 |
let spaceName = undefined; // undefined = backend will auto-generate
|
| 298 |
|
| 299 |
try {
|
| 300 |
console.log('[Deploy] ========== DEPLOY START (Gradio-style history parsing) ==========');
|
| 301 |
+
console.log('[Deploy] Username:', currentUsername);
|
| 302 |
console.log('[Deploy] Existing space from history:', existingSpace);
|
| 303 |
console.log('[Deploy] Will create new space?', !existingSpace);
|
| 304 |
console.log('[Deploy] =================================================================');
|