fix: use gr.State for task_type to prevent stale repaint task leaking into Custom mode#1137
Draft
fix: use gr.State for task_type to prevent stale repaint task leaking into Custom mode#1137
Conversation
2 tasks
…le repaint mode on Custom switch The `task_type` UI component was a `gr.Textbox(visible=False)`. In Gradio 6.2.0, hidden textbox component state is not reliably propagated across mode-switch event handlers, leaving a stale `task_type=\"repaint\"` value when the user switches from Repaint back to Custom mode. This caused the backend to raise \"Task 'repaint' requires source audio, but none was provided\" even in Custom (text2music) mode. Fixes: - `generation_tab_primary_controls.py`: Change `task_type` from `gr.Textbox(visible=False)` to `gr.State(value=\"text2music\")`. - `mode_ui.py`: Return the raw string value for `task_type` in `compute_mode_ui_updates` instead of `gr.update(value=..., elem_classes=[...])`. `gr.State` requires a raw value, not a `gr.update()` wrapper, to properly update its stored state. - `model_config.py`: Change the no-op task_type update from `gr.update()` to `gr.skip()` — the idiomatic Gradio 6 way to leave a `gr.State` unchanged when model config changes. Tests: - Add `ModeUiTaskTypeTests` class to `mode_ui_test.py` with regression tests verifying the Repaint→Custom switch resets `task_type` to `\"text2music\"` and that all mode switches return plain string values (not `gr.update()` dicts). Agent-Logs-Url: https://github.com/ace-step/ACE-Step-1.5/sessions/4972b767-1a18-446f-8dda-656273fa21b4 Co-authored-by: ChuxiJ <30956809+ChuxiJ@users.noreply.github.com>
Agent-Logs-Url: https://github.com/ace-step/ACE-Step-1.5/sessions/4972b767-1a18-446f-8dda-656273fa21b4 Co-authored-by: ChuxiJ <30956809+ChuxiJ@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix backend issue when switching from repaint to custom
fix: use gr.State for task_type to prevent stale repaint task leaking into Custom mode
Apr 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
After using Repaint mode, switching back to Custom mode and generating fails with "Task 'repaint' requires source audio, but none was provided" —
task_typestill holds"repaint"even though the mode radio shows Custom.Root cause:
task_typewas agr.Textbox(visible=False). In Gradio 6.2.0, mode-switch event outputs targeting hidden textboxes are not reliably applied, leaving stale values from the previous mode visible to the generate button's input read.Changes
generation_tab_primary_controls.py— Replacegr.Textbox(visible=False, value="text2music")withgr.State(value="text2music"), which is reliably managed server-side independent of render state.mode_ui.py—compute_mode_ui_updatesnow returns the rawtask_typestring at index 5 instead ofgr.update(value=task_type, elem_classes=[...]).gr.Staterequires a raw value, not agr.update()wrapper.model_config.py— Change the no-optask_typeupdate inget_model_type_ui_settingsfromgr.update()togr.skip(), the correct Gradio 6 idiom for leaving agr.Stateunchanged.mode_ui_test.py— AddModeUiTaskTypeTestswith regression tests confirming Repaint→Custom resetstask_typeto"text2music"and that all mode switches return a plainstr(not agr.update()dict).