From 13e2001f47ee076d9fbfaa4a598ee7468d1fe465 Mon Sep 17 00:00:00 2001 From: digital-garbage <133010426+digital-garbage@users.noreply.github.com> Date: Wed, 30 Sep 2026 20:30:51 +0300 Subject: [PATCH] fix: Reactive focus review crashed on projects with $variables; failures now show a notice --- conditioning.py | 4 ++++ movie_editor/frontend/reactive_focus.js | 2 ++ tests/test_focus_memory.py | 5 +++++ 3 files changed, 11 insertions(+) diff --git a/conditioning.py b/conditioning.py index f78cedf8..cc70c784 100644 --- a/conditioning.py +++ b/conditioning.py @@ -787,6 +787,10 @@ def focus_scene_texts(scene_segments, variables=None, placement="start"): placement=placement, postfix=scene_segments.get("postfix", "")) anchor = (canonical.get("anchor_expanded", "") or "").strip() postfix = (canonical.get("postfix_expanded", "") or "").strip() + try: + from .templates import resolve_variables as _resolve_variables + except ImportError: + from templates import resolve_variables as _resolve_variables texts = [] for s in canonical.get("scenes", []) or []: seg = (s.get("expanded") or "").strip() diff --git a/movie_editor/frontend/reactive_focus.js b/movie_editor/frontend/reactive_focus.js index cc526ca8..d277eda7 100644 --- a/movie_editor/frontend/reactive_focus.js +++ b/movie_editor/frontend/reactive_focus.js @@ -74,6 +74,7 @@ const r = el("div", "ov-field full"); r.appendChild(el("span", "ov-label", label)); const chips = el("div", "ov-checklist"); + chips.style.cssText = "flex-direction:row;flex-wrap:wrap;gap:6px"; const btns = options.map(([value, text]) => { const b = el("button", "btn", text); b.type = "button"; @@ -142,6 +143,7 @@ scenes = (await window.MovieEditorAPI.focusOptions(project.id, sceneIds)).scenes || []; } catch (e) { console.warn("[FunPack] reactive focus: could not list targets —", e.message); + window.Store.get().notice = `Reactive focus was skipped: ${e.message}`; return true; } const objOr = (v) => (v && typeof v === "object" ? v : {}); diff --git a/tests/test_focus_memory.py b/tests/test_focus_memory.py index dd20ce51..4a90a823 100644 --- a/tests/test_focus_memory.py +++ b/tests/test_focus_memory.py @@ -192,6 +192,11 @@ def test_focus_scene_texts_and_options_follow_the_generation_path(monkeypatch): assert "touches 's chin" in texts[0] opts = sc.focus_options(texts[0]) assert opts[0]["candidates"] and opts[0]["auto_lemma"] + # A project with $variables must resolve them, not crash the review. + with_var = conditioning.focus_scene_texts( + {"anchor": "", "scenes": ["[Shot 1] $who waves."], "postfix": ""}, + [{"name": "who", "value": "a tall man"}], "start") + assert "a tall man waves" in with_var[0] # ── rated, trait-aware views ─────────────────────────────────────────────────────────