Skip to content

Comments

refactor(gradio-events): extract generation run and batch navigation wiring modules (PR5)#655

Open
1larity wants to merge 5 commits intoace-step:mainfrom
1larity:sync/pr4-results-aux-wiring-20260220
Open

refactor(gradio-events): extract generation run and batch navigation wiring modules (PR5)#655
1larity wants to merge 5 commits intoace-step:mainfrom
1larity:sync/pr4-results-aux-wiring-20260220

Conversation

@1larity
Copy link
Contributor

@1larity 1larity commented Feb 20, 2026

Summary

This PR continues the event-wiring decomposition by extracting generation run and batch navigation wiring from acestep/ui/gradio/events/__init__.py into focused wiring modules.

Behavior is intended to be unchanged. This is a structural refactor to reduce facade size/risk and keep wiring contracts explicit.

What Changed

  • Added acestep/ui/gradio/events/wiring/generation_run_wiring.py
    • Moved generate_btn click chain:
      • clear outputs
      • stream generation
      • schedule background next-batch generation
  • Added acestep/ui/gradio/events/wiring/generation_batch_navigation_wiring.py
    • Moved prev_batch_btn and next_batch_btn chains
    • Centralized navigation output/input list construction to preserve ordering contracts
  • Updated acestep/ui/gradio/events/wiring/__init__.py exports for new wiring registrars
  • Updated acestep/ui/gradio/events/__init__.py to delegate to:
    • register_generation_run_handlers(...)
    • register_generation_batch_navigation_handlers(...)
  • Extended acestep/ui/gradio/events/wiring/decomposition_contract_test.py for new delegation/contracts
  • Fixed mojibake in comment text in acestep/ui/gradio/events/wiring/results_aux_wiring.py

Validation

  • Unit tests:
    • python -m unittest discover -s acestep/ui/gradio/events/wiring -p "*_test.py"
    • Result: Ran 8 tests ... OK
  • Module size policy:
    • generation_run_wiring.py: 169 LOC
    • generation_batch_navigation_wiring.py: 180 LOC
    • Both under 200 LOC hard cap
  • Docstrings:
    • Verified module/class/function docstring coverage for modified/new files

Manual UI Tests Passed

  • Single-batch generate flow (autogen off)
  • Multi-batch generate flow (autogen on)
  • Next Batch navigation updates outputs/state correctly
  • Previous Batch navigation restores prior batch correctly
  • Restore Params repopulates generation inputs correctly

Risk

Low. This is wiring extraction with no intended behavior changes; ordering contracts were preserved and validated.

Summary by CodeRabbit

  • Refactor

    • Replaced many inline event bindings with centralized registration-based wiring for generation, metadata, mode, run, navigation, and results to simplify and standardize UI flows.
    • Generation pipeline now uses registration points for batched and background generation orchestration.
  • New Features

    • Expanded results controls (remix/repaint, scoring, LRC generation/saving, audio→codes conversion) across result slots.
    • Improved subtitle (LRC) update handling.
  • Tests

    • Added AST-based regression tests to validate event-delegation contracts.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 20, 2026

No actionable comments were generated in the recent review. 🎉


📝 Walkthrough

Walkthrough

Refactors Gradio event wiring into modular registration helpers (service, metadata, mode, run, batch navigation, text-format, results aux), replaces inline wiring in the main events module with these registrations, and adds AST-based tests to verify delegation contracts.

Changes

Cohort / File(s) Summary
Main events entry
acestep/ui/gradio/events/__init__.py
Removed large inline event wiring; now calls centralized register_generation_* and register_results_aux_handlers, and uses build_mode_ui_outputs from wiring.
Wiring public API
acestep/ui/gradio/events/wiring/__init__.py
Exported new registration helpers: metadata, batch navigation, mode, run, results aux, and service handlers.
Service wiring
acestep/ui/gradio/events/wiring/generation_service_wiring.py
New registration for dataset import, service init, model/config/tier/LoRA handling, auto-checkbox wiring, and UI visibility toggles; returns auto-checkbox input/output lists.
Metadata & transcription wiring
acestep/ui/gradio/events/wiring/generation_metadata_wiring.py
New registration for codes conversion, transcription flows, sample loading, reference-audio validation, and delegation to text-format handlers.
Mode wiring
acestep/ui/gradio/events/wiring/generation_mode_wiring.py
New registration for generation-mode changes, simple-mode flows, src-audio validation, caption auto-fill, sample creation, and auto-checkbox uncheck chaining.
Run / generation pipeline wiring
acestep/ui/gradio/events/wiring/generation_run_wiring.py
New registration wiring generate button to a two-stage flow: clear/reset outputs → batched generation → then background next-batch pre-generation.
Batch navigation wiring
acestep/ui/gradio/events/wiring/generation_batch_navigation_wiring.py
New registration for prev/next batch navigation, parameter capture, navigation outputs, and triggering background batch generation.
Text-format wiring
acestep/ui/gradio/events/wiring/generation_text_format_wiring.py
New registration for caption/lyrics formatting buttons and post-action auto-checkbox syncing.
Results auxiliaries
acestep/ui/gradio/events/wiring/results_aux_wiring.py
New registration for per-result actions (send-to-remix/repaint, scoring, LRC gen/save, convert-to-codes) across result slots.
Regression tests
acestep/ui/gradio/events/wiring/decomposition_contract_test.py
AST-based tests ensuring setup_event_handlers delegates to new register_* wiring helpers and that wiring functions bind expected variables/outputs.

Sequence Diagram(s)

sequenceDiagram
    participant UI as Gradio UI
    participant GenW as GenerationWiringContext
    participant ResH as ResultsHandler
    participant DIT as DIT Handler
    participant LLM as LLM Handler

    UI->>GenW: click generate_btn (inputs...)
    GenW->>ResH: clear_audio_outputs_for_new_generation()
    GenW->>ResH: generate_with_batch_management(inputs..., DIT, LLM)
    ResH-->>UI: update generated audio, captions, status, scores...
    ResH->>DIT: schedule generate_next_batch_background(params...)
    DIT-->>GenW: update batch_queue / next_batch_status
    GenW-->>UI: update batch controls (next/prev/queue/status)
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Suggested reviewers

  • ChuxiJ

Poem

🐰 Tiny paws untie the thread,
Handlers hop where changes led,
Modules stitched, events align,
Tests nod true, registrations shine,
A rabbit cheers — code runs fed! 🥕✨

🚥 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 accurately summarizes the main change: extracting generation run and batch navigation wiring modules from the events package into focused, reusable wiring modules.
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 marked this pull request as ready for review February 20, 2026 17: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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@acestep/ui/gradio/events/wiring/results_aux_wiring.py`:
- Line 25: Replace the mojibake sequence "—" in the comment near
results_aux_wiring.py with a proper em dash (—); specifically update the comment
that references generation_mode.change (currently "# Mode-UI outputs shared with
generation_mode.change — applied atomically") to use a real em dash so it
reads "# Mode-UI outputs shared with generation_mode.change — applied
atomically".

@1larity 1larity changed the title Refactor (gradio part4) results auxiliary wiring decomposition refactor(gradio-events): extract generation run and batch navigation wiring modules (PR5) Feb 20, 2026
@1larity 1larity marked this pull request as draft February 20, 2026 18:52
@1larity 1larity marked this pull request as ready for review February 20, 2026 18:54
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.

Actionable comments posted: 5

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@acestep/ui/gradio/events/__init__.py`:
- Around line 39-54: Update the setup_event_handlers function docstring to list
its purpose and the key inputs/outputs introduced: document the wiring_context
parameter and the outputs returned/registered (auto_checkbox_inputs,
auto_checkbox_outputs from register_generation_service_handlers and
mode_ui_outputs from build_mode_ui_outputs) and note that these are forwarded to
register_generation_metadata_handlers and register_generation_mode_handlers;
keep it concise and follow existing docstring style including types and brief
descriptions for wiring_context, auto_checkbox_inputs, auto_checkbox_outputs,
and mode_ui_outputs.

In `@acestep/ui/gradio/events/wiring/generation_batch_navigation_wiring.py`:
- Around line 131-133: Update the docstring for
register_generation_batch_navigation_handlers to include a one-line purpose plus
clear inputs/outputs: state that it registers previous/next batch navigation
handlers and pre-generation chain; document the input parameter "context" of
type GenerationWiringContext and describe any important fields used from it
(e.g., UI components or event buses); specify the return value (None) and any
exceptions it may raise (if any). Keep it concise, follow existing docstring
style in the file, and ensure the function signature name
register_generation_batch_navigation_handlers and type GenerationWiringContext
are mentioned for discoverability.
- Around line 13-128: Update the two helper docstrings to explicitly document
parameters, return values and key elements of the returned lists: for
_build_navigation_outputs(results_section: dict[str, Any], include_next_status:
bool) state that results_section is a mapping of output component keys (list the
main groups: generated_audio_1..8, generated_audio_batch, generation_info,
current_batch_index, batch_indicator, prev/next buttons, status_output and
optional next_batch_status, followed by score_display_1..8, codes_display_1..8,
lrc_display_1..8, details_accordion_1..8 and restore_params_btn), explain
include_next_status controls presence of next_batch_status, and specify the
return type list[Any]; for
_build_capture_current_params_inputs(generation_section: dict[str, Any])
document that generation_section is a mapping of generation control keys (list
representative keys like captions, lyrics, bpm, key_scale, inference_steps,
guidance_scale, random_seed_checkbox, seed, reference_audio, batch_size_input,
audio_format, LM/COT related keys, auto_score/auto_lrc/score_scale,
normalization flags, latent_shift/rescale, etc.) and that the function returns
an ordered list[Any] of those control values for restoring generation state.
Ensure concise “Args:” and “Returns:” sections follow project docstring style.

In `@acestep/ui/gradio/events/wiring/generation_run_wiring.py`:
- Around line 11-23: The docstrings for register_generation_run_handlers and the
inner generation_wrapper are missing concise input/output and yield details;
update register_generation_run_handlers to document the GenerationWiringContext
parameter and that it registers handlers for batched audio inference, and update
generation_wrapper to state its args (proxy passthrough to
res_h.generate_with_batch_management), what it yields (streamed generation
results/frames or iterator of result objects), and any exceptions propagated
from res_h.generate_with_batch_management; refer to
register_generation_run_handlers, GenerationWiringContext, generation_wrapper,
dit_handler, llm_handler, and res_h.generate_with_batch_management when adding
these inputs/outputs/yield descriptions.

In `@acestep/ui/gradio/events/wiring/results_aux_wiring.py`:
- Around line 13-99: The exported registration helper
register_results_aux_handlers and the inner builders make_score_handler and
make_lrc_handler lack docstrings that describe their purpose and the key
inputs/outputs; update register_results_aux_handlers' docstring to briefly state
its role (registers remix/repaint, scoring, LRC and codes handlers) and
enumerate the main parameters and UI components it wires
(GenerationWiringContext, mode_ui_outputs, generation_section outputs like
src_audio/lyrics/captions, results_section buttons and generated_audio_N,
lm_metadata_state, generation_mode, score_display_N, details_accordion_N,
batch_queue), and add concise docstrings to make_score_handler and
make_lrc_handler that say they return a callable bound to an index and list the
callback signature and what res_h.calculate_score_handler_with_selection and
res_h.generate_lrc_handler expect/return (e.g., inputs: scale, batch_idx, queue
for scoring; batch_idx, queue, vocal_lang, infer_steps for LRC, and outputs: UI
elements updated). Ensure wording is brief and follows docstring style
guidelines.

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.

1 participant