diff --git a/conditioning.py b/conditioning.py index e6280754..91143214 100644 --- a/conditioning.py +++ b/conditioning.py @@ -10668,9 +10668,10 @@ class FunPackVideoRefinerV2(FunPackVideoRefiner): "splits into scenes and each scene is enhanced instead.") if _enhance_base: _before = prompt_to_encode + _ref = self._v2_enhancer_reference(prompt_to_encode, _enhance_sources) prompt_to_encode, _enhance_status = self._v2_enhance_prompt( _enhance_clip, prompt_to_encode, _enhance_system, cache=_enhance_cache, - reference=self._v2_enhancer_reference(prompt_to_encode, _enhance_sources), + reference=_ref, seed=_enhance_seed, temperature=prompt_enhance_temperature, top_p=prompt_enhance_top_p, max_length=prompt_enhance_max_length, thinking=prompt_enhance_thinking, image=prompt_enhance_image, @@ -10679,7 +10680,8 @@ class FunPackVideoRefinerV2(FunPackVideoRefiner): print(f"[FunPackVideoRefinerV2] {_enhance_status}") self._v2_enhanced_prompts.append({ "scene": None, "before": _before, "after": prompt_to_encode, - "status": _enhance_status, "image": prompt_enhance_image is not None}) + "status": _enhance_status, "image": prompt_enhance_image is not None, + "reference": _ref.strip()}) # Studio's `enhanced_prompt` output, for a node encoding on its own (Editor link # "Enhanced prompt, fallback to prompt + postfix"). The same text that link's @@ -10688,9 +10690,10 @@ class FunPackVideoRefinerV2(FunPackVideoRefiner): if prompt_enhance_output: _whole = str((_link_texts or {}).get("full_prompt") or "").strip() if prompt_enhance and _whole: + _ref = self._v2_enhancer_reference(_whole, _enhance_sources) _after, _st = self._v2_enhance_prompt( _enhance_clip, _whole, _enhance_system, cache=_enhance_cache, - reference=self._v2_enhancer_reference(_whole, _enhance_sources), + reference=_ref, seed=_enhance_seed, temperature=prompt_enhance_temperature, top_p=prompt_enhance_top_p, max_length=prompt_enhance_max_length, thinking=prompt_enhance_thinking, image=prompt_enhance_image, @@ -10698,7 +10701,7 @@ class FunPackVideoRefinerV2(FunPackVideoRefiner): print(f"[FunPackVideoRefinerV2] Enhanced prompt output: {_st}") self._v2_enhanced_prompts.append({ "scene": None, "before": _whole, "after": _after, "status": _st, - "image": prompt_enhance_image is not None}) + "image": prompt_enhance_image is not None, "reference": _ref.strip()}) _whole = _after self._v2_enhanced_output = _whole @@ -10938,9 +10941,10 @@ class FunPackVideoRefinerV2(FunPackVideoRefiner): if _enhance_own and split_scene_texts: _enhanced_texts = [] for _i, t in enumerate(split_scene_texts): + _ref = self._v2_enhancer_reference(t, _enhance_sources) _after, _st = self._v2_enhance_prompt( _enhance_clip, t, _enhance_system, cache=_enhance_cache, - reference=self._v2_enhancer_reference(t, _enhance_sources), + reference=_ref, seed=_enhance_seed, temperature=prompt_enhance_temperature, top_p=prompt_enhance_top_p, max_length=prompt_enhance_max_length, @@ -10949,7 +10953,8 @@ class FunPackVideoRefinerV2(FunPackVideoRefiner): print(f"[FunPackVideoRefinerV2] Scene {_i + 1}: {_st}") self._v2_enhanced_prompts.append({ "scene": _i, "before": t, "after": _after, "status": _st, - "image": prompt_enhance_image is not None}) + "image": prompt_enhance_image is not None, + "reference": _ref.strip()}) _enhanced_texts.append(_after) split_scene_texts = _enhanced_texts scene_refinement_keys = [set(s.get("keys") or set()) for s in canon_scenes] diff --git a/movie_editor/frontend/composer.js b/movie_editor/frontend/composer.js index 5b4b6d81..5073b6d1 100644 --- a/movie_editor/frontend/composer.js +++ b/movie_editor/frontend/composer.js @@ -1060,6 +1060,15 @@ det.append(el("summary", null, "What went in"), el("div", "enh-before-text", before)); card.append(det); } + // What was appended after the prompt (Enhance ▸ Reference) — the model read it too. + const ref = String(it.reference || "").trim(); + if (ref) { + const n = (ref.match(/^\[(Shortcut|Lore)\] /gm) || []).length; + const det = el("details", "enh-before"); + det.append(el("summary", null, `Reference sent (${n} ${n === 1 ? "entry" : "entries"})`), + el("div", "enh-before-text enh-ref-sent", ref)); + card.append(det); + } if (it.status) card.append(el("div", "enh-status", String(it.status))); return card; } diff --git a/movie_editor/frontend/styles.css b/movie_editor/frontend/styles.css index 2189fa85..a4ec0d67 100644 --- a/movie_editor/frontend/styles.css +++ b/movie_editor/frontend/styles.css @@ -2133,6 +2133,7 @@ body.tour-mode { overflow: hidden; } .enh-before summary { font-size: 11px; color: var(--muted); cursor: pointer; } .enh-before-text { margin-top: 4px; padding-left: 8px; border-left: 2px solid var(--line); font-size: 12px; line-height: 1.5; color: var(--muted); white-space: pre-wrap; overflow-wrap: anywhere; user-select: text; } +.enh-ref-sent { max-height: 260px; overflow-y: auto; } .enh-status { margin-top: 8px; font-size: 10.5px; line-height: 1.4; color: var(--faint); } .eng-enhance-host { margin-top: 16px; } diff --git a/tests/test_v2_category_alignment.py b/tests/test_v2_category_alignment.py index e09028f8..b5973548 100644 --- a/tests/test_v2_category_alignment.py +++ b/tests/test_v2_category_alignment.py @@ -2329,3 +2329,16 @@ def test_studio_skips_its_own_enhancement_when_told_nothing_reads_it(tmp_path): out, clip = _enhanced_output(tmp_path, prompt_enhance=True, prompt_enhance_scenes=False, prompt_enhance_output=True) assert out == "a vivid cat on a sunlit sill" + + +def test_last_run_readout_shows_the_reference_that_was_sent(tmp_path, monkeypatch): + import templates + monkeypatch.setattr(templates, "load_shortcut_db", lambda: {"shortcuts": { + "k1": {"name": "Mira", "replacements": ["red coat"], "triggers": ["/mira"]}}}) + refiner = FunPackVideoRefinerV2() + refiner._v2_state_path = lambda refinement_key: str(tmp_path / "state.json") + refiner.refine_v2("a cat", GeneratingClip("a vivid cat"), "Unrated", "ref-readout", + link_texts={"full_prompt": "a cat"}, prompt_enhance=True, + prompt_enhance_output=True, prompt_enhance_shortcuts=["k1"]) + item = refiner._v2_enhanced_prompts[-1] + assert item["before"] == "a cat" and item["reference"].count("[Shortcut] Mira\nred coat") == 1