fix issue
Browse files8576 unmodified lines857785788579858085818582858385848585858685876 unmodified lines85948595859685978598859922 unmodified lines862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708112 unmodified lines88218822882388248825882631 unmodified lines8858885988608861886288638576 unmodified linesgr.update(), gr.update(), gr.update(), gr.update(), gr.update(), gr.update(), gr.update(), gr.update(), gr.update(), gr.update() # 5-file group]files = parse_multipage_html_output(code_text or "")files = validate_and_autofix_files(files)if not isinstance(files, dict) or len(files) <= 1:# No multi-file content; keep single editorreturn [gr.update(visible=True), # code_outputgr.update(visible=False), # static_group_26 unmodified linesgr.update(), gr.update(), gr.update(), gr.update(), gr.update(), gr.update(), gr.update(), gr.update(), # 4-file groupgr.update(), gr.update(), gr.update(), gr.update(), gr.update(), gr.update(), gr.update(), gr.update(), gr.update(), gr.update() # 5-file group]# We have multi-file static output: hide single editor, show appropriate static group# Order: index.html first, then others sorted by path22 unmodified linesnum_files = len(ordered_paths)# Hide single editor, show appropriate group based on file countupdates = [gr.update(visible=False)] # code_outputif num_files == 2:updates.extend([gr.update(visible=True), # static_group_2gr.update(visible=False), # static_group_3gr.update(visible=False), # static_group_4gr.update(visible=False), # static_group_5plus])# Populate 2-file group (tab labels + code content)path1, path2 = ordered_paths[0], ordered_paths[1]updates.extend([gr.update(label=path1), gr.update(value=files.get(path1, ''), label=path1, language=_lang_for(path1)),gr.update(label=path2), gr.update(value=files.get(path2, ''), label=path2, language=_lang_for(path2)),# Empty updates for unused groupsgr.update(), gr.update(), gr.update(), gr.update(), gr.update(), gr.update(),gr.update(), gr.update(), gr.update(), gr.update(), gr.update(), gr.update(), gr.update(), gr.update(),gr.update(), gr.update(), gr.update(), gr.update(), gr.update(), gr.update(), gr.update(), gr.update(), gr.update(), gr.update()])elif num_files == 3:updates.extend([gr.update(visible=False), # static_group_2gr.update(visible=True), # static_group_3gr.update(visible=False), # static_group_4gr.update(visible=False), # static_group_5plus])# Populate 3-file group (tab labels + code content)path1, path2, path3 = ordered_paths[0], ordered_paths[1], ordered_paths[2]updates.extend([# Empty updates for 2-file groupgr.update(), gr.update(), gr.update(), gr.update(),# Populate 3-file groupgr.update(label=path1), gr.update(value=files.get(path1, ''), label=path1, language=_lang_for(path1)),gr.update(label=path2), gr.update(value=files.get(path2, ''), label=path2, language=_lang_for(path2)),gr.update(label=path3), gr.update(value=files.get(path3, ''), label=path3, language=_lang_for(path3)),# Empty updates for unused groupsgr.update(), gr.update(), gr.update(), gr.update(), gr.update(), gr.update(), gr.update(), gr.update(),gr.update(), gr.update(), gr.update(), gr.update(), gr.update(), gr.update(), gr.update(), gr.update(), gr.update(), gr.update()])elif num_files == 4:updates.extend([gr.update(visible=False), # static_group_2gr.update(visible=False), # static_group_3gr.update(visible=True), # static_group_4gr.update(visible=False), # static_group_5plus])# Populate 4-file group (tab labels + code content)paths = ordered_paths[:4]updates.extend([# Empty updates for 2-file and 3-file groupsgr.update(), gr.update(), gr.update(), gr.update(), gr.update(), gr.update(), gr.update(), gr.update(), gr.update(), gr.update(),# Populate 4-file groupgr.update(label=paths[0]), gr.update(value=files.get(paths[0], ''), label=paths[0], language=_lang_for(paths[0])),gr.update(label=paths[1]), gr.update(value=files.get(paths[1], ''), label=paths[1], language=_lang_for(paths[1])),gr.update(label=paths[2]), gr.update(value=files.get(paths[2], ''), label=paths[2], language=_lang_for(paths[2])),gr.update(label=paths[3]), gr.update(value=files.get(paths[3], ''), label=paths[3], language=_lang_for(paths[3])),# Empty updates for 5+ groupgr.update(), gr.update(), gr.update(), gr.update(), gr.update(), gr.update(), gr.update(), gr.update(), gr.update(), gr.update()])else: # 5+ filesupdates.extend([gr.update(visible=False), # static_group_2gr.update(visible=False), # static_group_3gr.update(visible=False), # static_group_4gr.update(visible=True), # static_group_5plus])# Populate 5+ file group (show first 5) (tab labels + code content)paths = ordered_paths[:5]updates.extend([# Empty updates for 2-file, 3-file, and 4-file groupsgr.update(), gr.update(), gr.update(), gr.update(), gr.update(), gr.update(), gr.update(), gr.update(), gr.update(), gr.update(),gr.update(), gr.update(), gr.update(), gr.update(), gr.update(), gr.update(), gr.update(), gr.update(),# Populate 5+ file groupgr.update(label=paths[0]), gr.update(value=files.get(paths[0], ''), label=paths[0], language=_lang_for(paths[0])),gr.update(label=paths[1]), gr.update(value=files.get(paths[1], ''), label=paths[1], language=_lang_for(paths[1])),gr.update(label=paths[2]), gr.update(value=files.get(paths[2], ''), label=paths[2], language=_lang_for(paths[2])),gr.update(label=paths[3]), gr.update(value=files.get(paths[3], ''), label=paths[3], language=_lang_for(paths[3])),gr.update(label=paths[4]), gr.update(value=files.get(paths[4], ''), label=paths[4], language=_lang_for(paths[4]))])return updates# Respond to language change to show/hide static multi-file editors appropriately112 unmodified linesstatic_tab_4_1, static_code_4_1, static_tab_4_2, static_code_4_2, static_tab_4_3, static_code_4_3, static_tab_4_4, static_code_4_4,static_tab_5_1, static_code_5_1, static_tab_5_2, static_code_5_2, static_tab_5_3, static_code_5_3, static_tab_5_4, static_code_5_4, static_tab_5_5, static_code_5_5,]).then(show_deploy_components,None,31 unmodified linesstatic_tab_4_1, static_code_4_1, static_tab_4_2, static_code_4_2, static_tab_4_3, static_code_4_3, static_tab_4_4, static_code_4_4,static_tab_5_1, static_code_5_1, static_tab_5_2, static_code_5_2, static_tab_5_3, static_code_5_3, static_tab_5_4, static_code_5_4, static_tab_5_5, static_code_5_5,]).then(show_deploy_components,None,8576 unmodified lines85778578857985808581858285838584858585868587858885896 unmodified lines85968597859885998600860186028603860422 unmodified lines86278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652112 unmodified lines8765876687678768876987708771877287738774877587768777877887798780878131 unmodified lines881388148815881688178818881988208821882288238824882588268827882888298576 unmodified linesgr.update(), gr.update(), gr.update(), gr.update(), gr.update(), gr.update(), gr.update(), gr.update(), gr.update(), gr.update() # 5-file group]# Parse multi-file output firstoriginal_files = parse_multipage_html_output(code_text or "")# Check if we actually have multi-file content BEFORE validation# (validate_and_autofix_files can create additional files from single-file HTML)if not isinstance(original_files, dict) or len(original_files) <= 1:# No genuine multi-file content; keep single editorreturn [gr.update(visible=True), # code_outputgr.update(visible=False), # static_group_26 unmodified linesgr.update(), gr.update(), gr.update(), gr.update(), gr.update(), gr.update(), gr.update(), gr.update(), # 4-file groupgr.update(), gr.update(), gr.update(), gr.update(), gr.update(), gr.update(), gr.update(), gr.update(), gr.update(), gr.update() # 5-file group]# We have genuine multi-file content - now validate and proceed with multi-file displayfiles = validate_and_autofix_files(original_files)# We have multi-file static output: hide single editor, show appropriate static group# Order: index.html first, then others sorted by path22 unmodified linesnum_files = len(ordered_paths)# TEMPORARY FIX: For now, always keep single editor visible for HTML multi-file# This ensures code is always visible while we debug the multi-file editors# TODO: Remove this once multi-file editors are working properlyupdates = [gr.update(visible=True), # code_output - keep visiblegr.update(visible=False), # static_group_2 - hide multi-file editors for nowgr.update(visible=False), # static_group_3gr.update(visible=False), # static_group_4gr.update(visible=False), # static_group_5plus]# Add empty updates for all the tab and code componentsupdates.extend([# All tab and code components get empty updates (tab, code, tab, code, ...)gr.update(), gr.update(), gr.update(), gr.update(), # 2-file groupgr.update(), gr.update(), gr.update(), gr.update(), gr.update(), gr.update(), # 3-file groupgr.update(), gr.update(), gr.update(), gr.update(), gr.update(), gr.update(), gr.update(), gr.update(), # 4-file groupgr.update(), gr.update(), gr.update(), gr.update(), gr.update(), gr.update(), gr.update(), gr.update(), gr.update(), gr.update() # 5-file group])return updates# Respond to language change to show/hide static multi-file editors appropriately112 unmodified linesstatic_tab_4_1, static_code_4_1, static_tab_4_2, static_code_4_2, static_tab_4_3, static_code_4_3, static_tab_4_4, static_code_4_4,static_tab_5_1, static_code_5_1, static_tab_5_2, static_code_5_2, static_tab_5_3, static_code_5_3, static_tab_5_4, static_code_5_4, static_tab_5_5, static_code_5_5,]).then(# After generation, toggle Python multi-file editors for Gradio/Streamlittoggle_python_editors,inputs=[language_dropdown, code_output],outputs=[code_output, python_group_2, python_group_3, python_group_4, python_group_5plus,python_tab_2_1, python_code_2_1, python_tab_2_2, python_code_2_2,python_tab_3_1, python_code_3_1, python_tab_3_2, python_code_3_2, python_tab_3_3, python_code_3_3,python_tab_4_1, python_code_4_1, python_tab_4_2, python_code_4_2, python_tab_4_3, python_code_4_3, python_tab_4_4, python_code_4_4,python_tab_5_1, python_code_5_1, python_tab_5_2, python_code_5_2, python_tab_5_3, python_code_5_3, python_tab_5_4, python_code_5_4, python_tab_5_5, python_code_5_5]).then(show_deploy_components,None,31 unmodified linesstatic_tab_4_1, static_code_4_1, static_tab_4_2, static_code_4_2, static_tab_4_3, static_code_4_3, static_tab_4_4, static_code_4_4,static_tab_5_1, static_code_5_1, static_tab_5_2, static_code_5_2, static_tab_5_3, static_code_5_3, static_tab_5_4, static_code_5_4, static_tab_5_5, static_code_5_5,]).then(# After generation, toggle Python multi-file editors for Gradio/Streamlittoggle_python_editors,inputs=[language_dropdown, code_output],outputs=[code_output, python_group_2, python_group_3, python_group_4, python_group_5plus,python_tab_2_1, python_code_2_1, python_tab_2_2, python_code_2_2,python_tab_3_1, python_code_3_1, python_tab_3_2, python_code_3_2, python_tab_3_3, python_code_3_3,python_tab_4_1, python_code_4_1, python_tab_4_2, python_code_4_2, python_tab_4_3, python_code_4_3, python_tab_4_4, python_code_4_4,python_tab_5_1, python_code_5_1, python_tab_5_2, python_code_5_2, python_tab_5_3, python_code_5_3, python_tab_5_4, python_code_5_4, python_tab_5_5, python_code_5_5]).then(show_deploy_components,None,
app.py+51-85