From 08d53b4520e615608b997107059523ccb5f06f53 Mon Sep 17 00:00:00 2001 From: Chris Dumas Date: Thu, 15 Oct 2026 08:44:22 +0000 Subject: [PATCH] Sync prompt text on every edit --- web/sequence_prompt_builder.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/web/sequence_prompt_builder.js b/web/sequence_prompt_builder.js index ddc80c9..635b35a 100644 --- a/web/sequence_prompt_builder.js +++ b/web/sequence_prompt_builder.js @@ -142,6 +142,15 @@ function configure(node) { panel.append(timeline); const sliderHint = el("div", "Drag the white handles on the bar to resize shots. The bar always represents the complete chunk duration."); sliderHint.style.cssText = "color:#b7d6bf;margin-bottom:4px"; panel.append(sliderHint); prompt = el("textarea"); prompt.rows = 9; prompt.value = promptFor(clip); prompt.placeholder = "[Shot 1] At 00:00.000, describe the opening action...\n\nType @ at the start of a new line to add the next shot."; prompt.style.cssText = "width:100%;box-sizing:border-box;color:#111;font:12px monospace;margin-top:6px"; + // Keep the serializable state current while typing, but do not render + // on every keypress: rendering would replace the textarea and lose the + // caret/selection. This also means a track interaction cannot see a + // stale copy of the script. + prompt.oninput = () => { + syncPrompt(clip, prompt.value); + stateWidget.value = JSON.stringify(state); + node.setDirtyCanvas?.(true, true); + }; prompt.onchange = () => { syncPrompt(clip, prompt.value); setState(); render(); }; prompt.onkeydown = (event) => { if (event.key !== "@") return; const cursor = prompt.selectionStart || 0; if (cursor !== 0 && prompt.value[cursor - 1] !== "\n") return; event.preventDefault(); addSlot(clip); setState(); render(); }; panel.append(prompt);