Skip to content

fix: use gr.State for task_type to prevent stale repaint task leaking into Custom mode#1137

Draft
Copilot wants to merge 3 commits intomainfrom
copilot/fix-repaint-custom-backend-issue
Draft

fix: use gr.State for task_type to prevent stale repaint task leaking into Custom mode#1137
Copilot wants to merge 3 commits intomainfrom
copilot/fix-repaint-custom-backend-issue

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 24, 2026

After using Repaint mode, switching back to Custom mode and generating fails with "Task 'repaint' requires source audio, but none was provided"task_type still holds "repaint" even though the mode radio shows Custom.

Root cause: task_type was a gr.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 — Replace gr.Textbox(visible=False, value="text2music") with gr.State(value="text2music"), which is reliably managed server-side independent of render state.

  • mode_ui.pycompute_mode_ui_updates now returns the raw task_type string at index 5 instead of gr.update(value=task_type, elem_classes=[...]). gr.State requires a raw value, not a gr.update() wrapper.

    # Before
    gr.update(value=task_type, elem_classes=["has-info-container"]),  # 5: task_type
    # After
    task_type,  # 5: task_type (gr.State — raw value)
  • model_config.py — Change the no-op task_type update in get_model_type_ui_settings from gr.update() to gr.skip(), the correct Gradio 6 idiom for leaving a gr.State unchanged.

  • mode_ui_test.py — Add ModeUiTaskTypeTests with regression tests confirming Repaint→Custom resets task_type to "text2music" and that all mode switches return a plain str (not a gr.update() dict).

Copilot AI linked an issue Apr 24, 2026 that may be closed by this pull request
2 tasks
Copilot AI and others added 2 commits April 24, 2026 00:55
…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>
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
Copilot AI requested a review from ChuxiJ April 24, 2026 00:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Going from repaint to custom break the backend

2 participants