Skip to content

Comments

Refactor (gradio part3) mode wiring decomposition#654

Merged
ChuxiJ merged 1 commit intoace-step:mainfrom
1larity:sync/pr3-independent-20260220
Feb 21, 2026
Merged

Refactor (gradio part3) mode wiring decomposition#654
ChuxiJ merged 1 commit intoace-step:mainfrom
1larity:sync/pr3-independent-20260220

Conversation

@1larity
Copy link
Contributor

@1larity 1larity commented Feb 20, 2026

Summary

  • Functional decomposition of Gradio generation mode/simple-mode event wiring.
  • Extracts mode-related wiring from events/init.py into a focused helper module.
  • Keeps behaviour unchanged while further thinning the event facade.

Scope

  • Added Acestep/ui/gradio/events/wiring/generation_mode_wiring.py with:

register_generation_mode_handlers(...)

  • Updated Acestep/ui/gradio/events/init.py to delegate mode/simple-mode registration.

  • Updated Acestep/ui/gradio/events/wiring/init.py exports.

  • Updated Acestep/ui/gradio/events/wiring/decomposition_contract_test.py to verify PR3 delegation and mode-output binding at AST level.

  • No handler behaviour changes.

  • No interface signature changes for:

    • setup_event_handlers(...)
    • setup_training_event_handlers(...)
  • No cross-path runtime/hardware changes.

Validation

Code review by GLM5 with no issues.

Unit tests introduced/updated

  • Updated Acestep/ui/gradio/events/wiring/decomposition_contract_test.py
    • verifies setup_event_handlers delegates to
      egister_generation_mode_handlers
    • verifies mode wiring binds outputs=mode_ui_outputs for generation-mode change

Unit tests run

  • python -m unittest discover -s acestep/ui/gradio/events/wiring -p *_test.py (pass)

Manual UI tests passed

  • Generation mode switching across Custom/Simple/Remix/Repaint/Extract/Complete remains correct.
  • Extract-mode handlers remain correct:
    • track name auto-fill for caption
    • source audio validation
    • source-audio duration auto-fill for extract/lego flow
  • Simple-mode handlers remain correct:
    • instrumental toggle updates simple vocal language
    • random description fills expected controls
  • Create Sample flow remains correct, including auto-checkbox sync chain.
  • Downstream generation sanity remains correct after mode/simple-mode interactions.

Conflict checks

  • Upstream merge check: no conflict.
  • Outstanding Part 2 compatibility check: Part 3 commit cherry-picks cleanly on top of PR2 branch (no conflict).

Risk

  • Low. This is a code-move decomposition with preserved wiring chains and contract tests.
  • Residual risk remains runtime integration-level event behavior (pre-existing gap).

Summary by CodeRabbit

  • Refactor

    • Consolidated event handling logic for generation mode and UI interactions into a dedicated centralized handler.
    • Reorganized internal event wiring to improve code maintainability and separation of concerns.
  • Tests

    • Updated test suite to reflect the new event handler structure and wiring organization.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 20, 2026

📝 Walkthrough

Walkthrough

This pull request extracts mode-related event wiring logic from the main event setup module into a dedicated register_generation_mode_handlers function and new generation_mode_wiring module. The main events module now delegates mode wiring instead of handling it inline, consolidating and organizing event handler registration.

Changes

Cohort / File(s) Summary
Event Wiring Extraction
acestep/ui/gradio/events/__init__.py, acestep/ui/gradio/events/wiring/__init__.py
Extracted mode-related wiring into a dedicated register_generation_mode_handlers function; main events module now delegates mode wiring via function call instead of inline code blocks.
Generation Mode Wiring Module
acestep/ui/gradio/events/wiring/generation_mode_wiring.py
New module implementing register_generation_mode_handlers that wires event handlers for generation mode changes, track name extraction, source audio validation/extraction, simple instrumental checkbox, and random description/sample generation buttons.
Decomposition Contract Tests
acestep/ui/gradio/events/wiring/decomposition_contract_test.py
Added test helpers and test cases to verify the generation mode wiring extraction, including assertions for register_generation_mode_handlers delegation and mode UI outputs usage.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • ChuxiJ

Poem

🐰 The wires were tangled, the handlers spread thin,
So we gathered them up in a module, begin!
Mode wiring extracted, the logic now clean,
A delegation dance—the cleanest we've seen! ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Refactor (gradio part3) mode wiring decomposition' accurately describes the main change: extracting mode-related wiring into a dedicated module as part of a larger gradio refactoring series.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Comment @coderabbitai help to get the list of available commands and usage tips.

@1larity 1larity force-pushed the sync/pr3-independent-20260220 branch from 954a799 to 0bcdee3 Compare February 20, 2026 16:54
@1larity 1larity marked this pull request as ready for review February 20, 2026 16:56
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (2)
acestep/ui/gradio/events/__init__.py (1)

195-201: Consider iterable unpacking for output list construction.

The list concatenation [...] + mode_ui_outputs works but iterable unpacking is more idiomatic.

♻️ Optional: Use iterable unpacking
             outputs=[
                 generation_section["src_audio"],
                 generation_section["generation_mode"],
                 generation_section["lyrics"],
                 generation_section["captions"],
-            ] + mode_ui_outputs,
+                *mode_ui_outputs,
+            ],

Apply the same pattern to line 217.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@acestep/ui/gradio/events/__init__.py` around lines 195 - 201, Change the
outputs list construction to use iterable unpacking instead of list
concatenation: build the outputs argument as a single list literal that unpacks
mode_ui_outputs (e.g., outputs=[generation_section["src_audio"],
generation_section["generation_mode"], generation_section["lyrics"],
generation_section["captions"], *mode_ui_outputs]) and apply the same change at
the other occurrence referenced around line 217; locate the call that passes
outputs= and replace the existing "[...] + mode_ui_outputs" pattern with the
unpacking form using generation_section and mode_ui_outputs.
acestep/ui/gradio/events/wiring/generation_metadata_wiring.py (1)

85-103: Tuple concatenation on line 86 works but could use unpacking.

The + (True,) appends the is_format_caption_state value. This works correctly since load_random_example returns an 8-tuple and the outputs list expects 9 values.

♻️ Optional: Use tuple unpacking for clarity
     generation_section["sample_btn"].click(
-        fn=lambda task: gen_h.load_random_example(task, llm_handler) + (True,),
+        fn=lambda task: (*gen_h.load_random_example(task, llm_handler), True),
         inputs=[generation_section["task_type"]],
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@acestep/ui/gradio/events/wiring/generation_metadata_wiring.py` around lines
85 - 103, The lambda passed to generation_section["sample_btn"].click appends
(True,) to the tuple returned by gen_h.load_random_example using + (True,),
which is correct but unclear; change the lambda to use tuple unpacking so it
returns (*gen_h.load_random_example(task, llm_handler), True) instead
(referencing generation_section["sample_btn"].click and
gen_h.load_random_example) so the returned values clearly match the nine
expected outputs including is_format_caption_state.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@acestep/ui/gradio/events/__init__.py`:
- Around line 195-201: Change the outputs list construction to use iterable
unpacking instead of list concatenation: build the outputs argument as a single
list literal that unpacks mode_ui_outputs (e.g.,
outputs=[generation_section["src_audio"], generation_section["generation_mode"],
generation_section["lyrics"], generation_section["captions"], *mode_ui_outputs])
and apply the same change at the other occurrence referenced around line 217;
locate the call that passes outputs= and replace the existing "[...] +
mode_ui_outputs" pattern with the unpacking form using generation_section and
mode_ui_outputs.

In `@acestep/ui/gradio/events/wiring/generation_metadata_wiring.py`:
- Around line 85-103: The lambda passed to
generation_section["sample_btn"].click appends (True,) to the tuple returned by
gen_h.load_random_example using + (True,), which is correct but unclear; change
the lambda to use tuple unpacking so it returns
(*gen_h.load_random_example(task, llm_handler), True) instead (referencing
generation_section["sample_btn"].click and gen_h.load_random_example) so the
returned values clearly match the nine expected outputs including
is_format_caption_state.

@1larity
Copy link
Contributor Author

1larity commented Feb 20, 2026

@ChuxiJ Codex got it's knickers in a right twist with the commits on this, I've tried to repair it, but I wouldn't be surprised if there are conflicts for me to resolve once part 2 is applied.

@1larity 1larity force-pushed the sync/pr3-independent-20260220 branch from 0bcdee3 to ea7b286 Compare February 21, 2026 10:55
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
acestep/ui/gradio/events/wiring/generation_mode_wiring.py (1)

13-19: Consider expanding the docstring to include key inputs/outputs.

The docstring is minimal. Per coding guidelines, docstrings should include "purpose plus key inputs/outputs." Consider briefly describing what each parameter represents.

📝 Suggested docstring expansion
 def register_generation_mode_handlers(
     context: GenerationWiringContext,
     mode_ui_outputs: Sequence[Any],
     auto_checkbox_inputs: Sequence[Any],
     auto_checkbox_outputs: Sequence[Any],
 ) -> None:
-    """Register generation mode and simple-mode handlers."""
+    """Register generation mode and simple-mode event handlers.
+
+    Args:
+        context: Wiring context with handlers and component maps.
+        mode_ui_outputs: Output components for mode-change events.
+        auto_checkbox_inputs: Inputs for auto-checkbox unchecking logic.
+        auto_checkbox_outputs: Outputs for auto-checkbox unchecking logic.
+    """
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@acestep/ui/gradio/events/wiring/generation_mode_wiring.py` around lines 13 -
19, Update the minimal docstring for register_generation_mode_handlers to
include its purpose and brief descriptions of each parameter: explain that
context (GenerationWiringContext) provides wiring state and callbacks,
mode_ui_outputs is the sequence of UI elements updated when generation mode
changes, auto_checkbox_inputs are input widgets representing "auto" toggles, and
auto_checkbox_outputs are the corresponding outputs or handlers triggered; also
mention return value (None) and side effects (registers event handlers). Keep it
short and consistent with other docstrings.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@acestep/ui/gradio/events/wiring/generation_mode_wiring.py`:
- Around line 13-19: Update the minimal docstring for
register_generation_mode_handlers to include its purpose and brief descriptions
of each parameter: explain that context (GenerationWiringContext) provides
wiring state and callbacks, mode_ui_outputs is the sequence of UI elements
updated when generation mode changes, auto_checkbox_inputs are input widgets
representing "auto" toggles, and auto_checkbox_outputs are the corresponding
outputs or handlers triggered; also mention return value (None) and side effects
(registers event handlers). Keep it short and consistent with other docstrings.

@ChuxiJ ChuxiJ merged commit 0b42513 into ace-step:main Feb 21, 2026
3 checks passed
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.

2 participants