fix
Browse filesFiles changed (2)
1164 unmodified lines1165116611671168116911709 unmodified lines118011811182118311841185118611871188118911901191119211931164 unmodified linesuser_info = api.whoami()username = user_info.get("name") or user_info.get("preferred_username") or "user"# If no destination name provided, use original nameif not to_space_name:# Extract original space name9 unmodified linesprint(f"[Duplicate] Duplicating {from_space_id} to {to_space_id}")# Duplicate the spaceduplicated_repo = duplicate_space(from_id=from_space_id,to_id=to_space_name, # Just the name, not full IDtoken=token,private=private,exist_ok=True)# Extract space URLspace_url = f"https://huggingface.co/spaces/{to_space_id}"1164 unmodified lines11651166116711681169117011711172117311741175117611771178117911809 unmodified lines119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121164 unmodified linesuser_info = api.whoami()username = user_info.get("name") or user_info.get("preferred_username") or "user"# Get original space info to detect hardwareprint(f"[Duplicate] Fetching info for {from_space_id}")try:original_space_info = api.space_info(from_space_id)original_hardware = getattr(original_space_info, 'hardware', None)print(f"[Duplicate] Original space hardware: {original_hardware}")except Exception as e:print(f"[Duplicate] Could not fetch space info: {e}")original_hardware = None# If no destination name provided, use original nameif not to_space_name:# Extract original space name9 unmodified linesprint(f"[Duplicate] Duplicating {from_space_id} to {to_space_id}")# Prepare duplicate_space parametersduplicate_params = {"from_id": from_space_id,"to_id": to_space_name, # Just the name, not full ID"token": token,"private": private,"exist_ok": True}# Add hardware if the original space has itif original_hardware and original_hardware != 'cpu-basic':# Use the same hardware as original, or fallback to cpu-basicduplicate_params["hardware"] = original_hardwareprint(f"[Duplicate] Using hardware: {original_hardware}")# Duplicate the spaceduplicated_repo = duplicate_space(**duplicate_params)# Extract space URLspace_url = f"https://huggingface.co/spaces/{to_space_id}"
330 unmodified lines3313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843854 unmodified lines390391392393394395396397398399400401402403404405406407408330 unmodified linesreturn;}if (createPR) {// Option 1: Create a PR on the original space// Import code and let AI redesign itif (onImport && onStart) {onImport(result.code, result.language || 'html', redesignUrl);// Send redesign prompt with code contextsetTimeout(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.Current code:\`\`\`${result.language || 'html'}${result.code}\`\`\`Please redesign this with:- Minimal, clean components- Mobile-first responsive design- Modern UI/UX best practices- Better visual hierarchy and spacing`;if (onStart) {onStart(redesignPrompt, result.language || 'html', selectedModel);}console.log('[Redesign] Will create PR after code generation completes');}, 100);setShowRedesignDialog(false);setRedesignUrl('');} else {setRedesignError('Missing required callbacks. Please try again.');}} else {// Option 2: Duplicate the space and then apply redesignconsole.log('[Redesign] Duplicating space for redesign:', repoId);const duplicateResult = await apiClient.duplicateSpace(repoId);if (duplicateResult.success) {// Show success messagealert(`✅ Space duplicated successfully!\n\nYour space: ${duplicateResult.space_url}\n\nNow generating redesign...`);// Load the code and trigger redesignif (onImport && onStart) {onImport(result.code, result.language || 'html', duplicateResult.space_url);setTimeout(() => {const redesignPrompt = `I have existing code in the editor that I duplicated from ${redesignUrl}. Please redesign it to make it look better with minimal components needed, mobile friendly, and modern design.Current code:\`\`\`${result.language || 'html'}4 unmodified lines- Minimal, clean components- Mobile-first responsive design- Modern UI/UX best practices- Better visual hierarchy and spacing`;if (onStart) {onStart(redesignPrompt, result.language || 'html', selectedModel);}}, 100);}setShowRedesignDialog(false);setRedesignUrl('');} else {setRedesignError(duplicateResult.message || 'Failed to duplicate space');}}} catch (error: any) {console.error('Redesign error:', error);330 unmodified lines3313323333343353363373383393403413423434 unmodified lines348349350351352353354355356357358359360361362363364365366367368369370371372330 unmodified linesreturn;}// Import code and trigger AI redesign (don't duplicate yet)if (onImport && onStart) {onImport(result.code, result.language || 'html', redesignUrl);// Send redesign prompt with code contextsetTimeout(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.Current code:\`\`\`${result.language || 'html'}4 unmodified lines- Minimal, clean components- Mobile-first responsive design- Modern UI/UX best practices- Better visual hierarchy and spacing${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) {onStart(redesignPrompt, result.language || 'html', selectedModel);}if (createPR) {console.log('[Redesign] Will create PR after code generation completes');} else {console.log('[Redesign] Code will be generated. User can deploy/duplicate after.');}}, 100);setShowRedesignDialog(false);setRedesignUrl('');} else {setRedesignError('Missing required callbacks. Please try again.');}} catch (error: any) {console.error('Redesign error:', error);
backend_deploy.py+26-7
frontend/src/components/LandingPage.tsx+23-59