only app.py for redesigns
Browse filesFiles changed (2)
558 unmodified lines559560561562563564565566567568569570571572573574575576577578579580581582583584820 unmodified lines14051406140714081409141014111412141314141415141614171418141914201421142214231424142514261394139514271428142914301431558 unmodified lines print(f"[Deploy] Generated {len(files)} file(s): {list(files.keys())}") # For redesign operations, ONLY update app.py to preserve other helper files # Detect redesign from commit message OR from history (user prompt contains "redesign") is_redesign = False if commit_message and "redesign" in commit_message.lower(): is_redesign = True elif history: # Check last user message for "redesign" keyword for role, content in reversed(history): if role == "user" and content and "redesign" in content.lower(): is_redesign = True break if is_redesign: print(f"[Deploy] Redesign operation detected - filtering to ONLY app.py") app_py_content = files.get('app.py') if not app_py_content: return False, "Error: No app.py found in redesign output", None files = {'app.py': app_py_content} print(f"[Deploy] Will only update app.py ({len(app_py_content)} chars)") # Upload all generated files (the LLM is instructed to only output .py files, # but if it creates new assets/data files, we should upload those too) # This approach updates .py files and adds any new files without touching820 unmodified lines files["app.py"] = cleaned_code # For Gradio PRs, only include .py files (preserve existing requirements.txt, etc.) # For redesigns, ONLY include app.py to avoid modifying helper files if language == "gradio": print(f"[PR] Gradio app - filtering to only .py files") py_files = {fname: content for fname, content in files.items() if fname.endswith('.py')} if not py_files: print(f"[PR] Warning: No .py files found in parsed output") return False, "No Python files found in generated code for Gradio PR", None # Check if this is a redesign (pr_title contains "Redesign") is_redesign = "redesign" in pr_title.lower() if pr_title else False if is_redesign: print(f"[PR] Redesign PR detected - filtering to ONLY app.py") if 'app.py' not in py_files: print(f"[PR] Warning: No app.py found in redesign output") return False, "No app.py found in redesign output for Gradio PR", None files = {'app.py': py_files['app.py']} print(f"[PR] Will only update app.py ({len(py_files['app.py'])} chars)") else: files = py_files print(f"[PR] Will update {len(files)} Python file(s): {list(files.keys())}") files = py_files print(f"[PR] Will update {len(files)} Python file(s): {list(files.keys())}") # Write files (create subdirectories if needed) for filename, content in files.items():384 unmodified lines38538638738838838939039137 unmodified lines429430431432432433434435384 unmodified lines- Modern UI/UX best practices- Better visual hierarchy and spacing
${isGradio ? '\n\nIMPORTANT: Only output Python (.py) files. Do NOT include requirements.txt or any other non-Python files. The existing dependencies and configuration files will be preserved.' : ''}`;${isGradio ? '\n\nIMPORTANT: Only output app.py with the redesigned UI (themes, layout, styling). Do NOT modify or output any other .py files (utils.py, models.py, etc.). Do NOT include requirements.txt or README.md.' : ''}`; if (onStart) { // Pass duplicated space ID so auto-deploy updates it37 unmodified lines- Modern UI/UX best practices- Better visual hierarchy and spacing
${isGradio ? '\n\nIMPORTANT: Only output Python (.py) files. Do NOT include requirements.txt or any other non-Python files. The existing dependencies and configuration files will be preserved.' : ''}${isGradio ? '\n\nIMPORTANT: Only output app.py with the redesigned UI (themes, layout, styling). Do NOT modify or output any other .py files (utils.py, models.py, etc.). Do NOT include requirements.txt or README.md.' : ''}
Note: After generating the redesign, I will create a Pull Request on the original space.`; backend_deploy.py+35-2
frontend/src/components/LandingPage.tsx+2-2