Refactor for readability: declare state attrs, extract helpers, deduplicate

- Declare dynamic attributes (_render_main, _load_file, etc.) in AppState
  dataclass instead of monkey-patching at runtime
- Extract max_main_seq_number() and FRAME_TO_SKIP_DEFAULT in batch tab
- Add commit() closure in _render_sequence_card to deduplicate save/notify/refresh
- Add default param to dict_number(), replace hand-rolled CFG/VACE/custom bindings
- Extract _delete_nodes() helper in timeline to deduplicate single/batch delete
- Split 230-line render_timeline refreshable into 4 focused section helpers

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-26 16:56:40 +01:00
parent a8c9a0376d
commit b0125133f1
4 changed files with 258 additions and 263 deletions

View File

@@ -1,5 +1,6 @@
from dataclasses import dataclass, field
from pathlib import Path
from typing import Any, Callable
@dataclass
@@ -15,3 +16,10 @@ class AppState:
timeline_selected_nodes: set = field(default_factory=set)
live_toggles: dict = field(default_factory=dict)
show_comfy_monitor: bool = True
# Set at runtime by main.py / tab_comfy_ng.py
_render_main: Any = None
_load_file: Callable | None = None
_main_rendered: bool = False
_live_checkboxes: dict = field(default_factory=dict)
_live_refreshables: dict = field(default_factory=dict)