Spaces:
Sleeping
Sleeping
Add manual Go to Challenge button - workaround for yield+Tabs bug
Browse files202 unmodified lines20320420520620720854 unmodified lines2632642652662672682691 unmodified line27127227327427527627711 unmodified lines28929029129229329429529623 unmodified lines320321322323324325326165 unmodified lines492493494495496497498202 unmodified linesdebug_check = gr.Checkbox(label="π Debug Mode", value=False)start_btn = gr.Button("Start Challenge β‘οΈ", variant="primary", size="lg")status_md = gr.Markdown("")# Tab 2: Challengewith gr.Tab("π» Challenge", id=2):54 unmodified lines# Ensure API key is setif not api_key:logger.warning("No API key provided!")yield gr.Tabs(selected=1), "β No API key! Please login again.", "", "", ""returnif api_key:1 unmodified linelogger.info(f"Using API key: {api_key[:10]}...")logger.info(f"Starting: {url}, bugs={bugs}, nesting={nesting}, refactoring={refactoring}, debug={debug}")yield gr.Tabs(selected=1), "β³ Creating challenge... (this may take 1-2 minutes)", "", "", ""try:logger.info("Running pipeline...")11 unmodified linesreadme = cs.readme()logger.info(f"Loading challenge from {cs.target_file}")yield gr.Tabs(selected=2), f"β Ready! File: {cs.target_file}", readme, code, workspacelogger.info("Successfully moved to Challenge tab!")except Exception as exc:logger.error(f"Pipeline failed: {exc}", exc_info=True)error_msg = str(exc)23 unmodified lineselse:error_msg = f"β **Error creating challenge:**\n\n{exc}"yield gr.Tabs(selected=1), error_msg, "", "", ""def on_submit(workspace, code, hints_used, submit_count):logger.info(f"Submit clicked (hints={hints_used}, attempt={submit_count+1})")165 unmodified lines# ββ Wire events βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββlogin_btn.click(on_login, inputs=[name_input, api_input], outputs=[tabs, user_api_key_state, login_status])start_btn.click(on_start, inputs=[url_input, num_bugs, nesting_slider, refactoring_check, debug_check, user_api_key_state], outputs=[tabs, status_md, readme_md, code_box, workspace_state])# Code Editor Toolsrun_tests_btn.click(on_run_tests, inputs=[code_box, workspace_state], outputs=[test_output_box])202 unmodified lines20320420520620720820954 unmodified lines2642652662672682692701 unmodified line27227327427527627727811 unmodified lines29029129229329429529629729829930030130230330423 unmodified lines328329330331332333334335336337338339165 unmodified lines505506507508509510511512202 unmodified linesdebug_check = gr.Checkbox(label="π Debug Mode", value=False)start_btn = gr.Button("Start Challenge β‘οΈ", variant="primary", size="lg")status_md = gr.Markdown("")go_to_challenge_btn = gr.Button("π Go to Challenge β", variant="primary", size="lg", visible=False)# Tab 2: Challengewith gr.Tab("π» Challenge", id=2):54 unmodified lines# Ensure API key is setif not api_key:logger.warning("No API key provided!")yield gr.Tabs(selected=1), "β No API key! Please login again.", "", "", "", gr.Button(visible=False)returnif api_key:1 unmodified linelogger.info(f"Using API key: {api_key[:10]}...")logger.info(f"Starting: {url}, bugs={bugs}, nesting={nesting}, refactoring={refactoring}, debug={debug}")yield gr.Tabs(selected=1), "β³ Creating challenge... (this may take 1-2 minutes)", "", "", "", gr.Button(visible=False)try:logger.info("Running pipeline...")11 unmodified linesreadme = cs.readme()logger.info(f"Loading challenge from {cs.target_file}")# Don't change tab automatically - show button insteadsuccess_msg = f"""β **Challenge Ready!****File:** `{cs.target_file}`Click the button below to start solving the challenge! π"""yield gr.Tabs(selected=1), success_msg, readme, code, workspace, gr.Button("π Go to Challenge β", visible=True, variant="primary", size="lg")logger.info("Challenge ready - waiting for user to click button")except Exception as exc:logger.error(f"Pipeline failed: {exc}", exc_info=True)error_msg = str(exc)23 unmodified lineselse:error_msg = f"β **Error creating challenge:**\n\n{exc}"yield gr.Tabs(selected=1), error_msg, "", "", "", gr.Button(visible=False)def go_to_challenge():"""Simple function to switch to Challenge tab."""logger.info("User clicked Go to Challenge button")return gr.Tabs(selected=2)def on_submit(workspace, code, hints_used, submit_count):logger.info(f"Submit clicked (hints={hints_used}, attempt={submit_count+1})")165 unmodified lines# ββ Wire events βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββlogin_btn.click(on_login, inputs=[name_input, api_input], outputs=[tabs, user_api_key_state, login_status])start_btn.click(on_start, inputs=[url_input, num_bugs, nesting_slider, refactoring_check, debug_check, user_api_key_state], outputs=[tabs, status_md, readme_md, code_box, workspace_state, go_to_challenge_btn])go_to_challenge_btn.click(go_to_challenge, inputs=[], outputs=[tabs])# Code Editor Toolsrun_tests_btn.click(on_run_tests, inputs=[code_box, workspace_state], outputs=[test_output_box])
minimal_test.py+20-6