From 25e5cc8de0696d1e50844d449912d9d8181b92c2 Mon Sep 17 00:00:00 2001 From: digital-garbage <133010426+digital-garbage@users.noreply.github.com> Date: Sun, 20 Sep 2026 00:49:16 +0300 Subject: [PATCH] feat: timed phrases use square brackets so shortcut parentheses can sit inside Co-Authored-By: Claude Opus 5 --- conditioning.py | 2 +- h3_token_weights.py | 10 +++++----- movie_editor/frontend/composer.js | 6 +++--- tests/test_h3_token_weights.py | 12 ++++++------ 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/conditioning.py b/conditioning.py index ac0aec63..b192ff49 100644 --- a/conditioning.py +++ b/conditioning.py @@ -4456,7 +4456,7 @@ class FunPackVideoRefinerV2(FunPackVideoRefiner): self._v2_tally_encode(purpose, 0.0, cached=True) return cached _encode_started = time.perf_counter() - # Timed phrases `(walks left@2.0-3.5)` are a sampler instruction, not prompt text. + # Timed phrases `[walks left@2.0-3.5]` are a sampler instruction, not prompt text. # Stripped for EVERY encoder (Qwen or Gemma would read them as punctuation); only H3 # can act on them, and the sampler says so when it cannot. try: diff --git a/h3_token_weights.py b/h3_token_weights.py index 10e68a7a..697bf5db 100644 --- a/h3_token_weights.py +++ b/h3_token_weights.py @@ -66,11 +66,11 @@ def parse(text: str): return "".join(out), spans -# (phrase@2.0-3.5) / (phrase:1.5@2.0-3.5): a TIMED phrase. Seconds from the scene start. -# The phrase may contain `:` and `@` (shortcut replacements do): only a `:number` directly -# before the `@t0-t1)` tail is a weight. Parentheses inside the phrase are still not allowed. +# [phrase@2.0-3.5] / [phrase:1.5@2.0-3.5]: a TIMED phrase. Seconds from the scene start. +# Square brackets so a shortcut replacement's parentheses and colons can sit inside; only a +# `:number` directly before the `@t0-t1]` tail is a weight. _TIMED = re.compile( - r"(? (clean_text, [(start_char, end_char, weight, t0, t1)]). - The model must never see `@2.0-3.5`: Qwen would read it as punctuation. Spans index + The model must never see `[…@2.0-3.5]`: Qwen would read it as punctuation. Spans index into `clean_text` (same contract as `parse`). A window with t1 <= t0 is dropped. """ if not text or "@" not in text: diff --git a/movie_editor/frontend/composer.js b/movie_editor/frontend/composer.js index a28e08a8..3fb7d039 100644 --- a/movie_editor/frontend/composer.js +++ b/movie_editor/frontend/composer.js @@ -256,7 +256,7 @@ let composeTextarea = null; let varsOpen = false; // Variables panel expanded? let varHintEl = null; // undeclared / cycle hint line under the prompt - let timedHintEl = null; // timed phrases `(walks left@2.0-3.5)` found in the prompt + let timedHintEl = null; // timed phrases `[walks left@2.0-3.5]` found in the prompt // ── templates bar (above the global prompt) ───────────────────────────────────── const TPL_NONE = "__none__"; @@ -438,9 +438,9 @@ return cycles; } - // Timed phrases: `(phrase@t0-t1)` / `(phrase:w@t0-t1)`, seconds from the scene start. Mirrors + // Timed phrases: `[phrase@t0-t1]` / `[phrase:w@t0-t1]`, seconds from the scene start. Mirrors // h3_token_weights._TIMED — the phrase is only allowed to shape the video inside its window. - const TIMED_RE = /(?