fix: Reactive focus review crashed on projects with $variables; failures now show a notice

This commit is contained in:
digital-garbage
2026-09-30 20:30:51 +03:00
parent 92bccd3375
commit 13e2001f47
3 changed files with 11 additions and 0 deletions
+4
View File
@@ -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()
+2
View File
@@ -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 : {});
+5
View File
@@ -192,6 +192,11 @@ def test_focus_scene_texts_and_options_follow_the_generation_path(monkeypatch):
assert "touches <Subject 1>'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 ─────────────────────────────────────────────────────────