Fit prompt builder node to rendered panel
tests / test (push) Canceled after 0s
tests / windows-storage (push) Canceled after 0s

This commit is contained in:
2026-10-15 09:28:20 +00:00
parent 0eb571b16e
commit fee851698d
+8 -2
View File
@@ -257,8 +257,14 @@ function configure(node) {
const add = el("button", "@ Add shot"); add.type = "button"; add.onclick = () => { clip.prompt = prompt.value; syncPrompt(clip, clip.prompt); addSlot(clip); rebuildPromptAfterStructureChange(clip); setState(); render(); }; actions.append(add);
if (clip.slots.length > 1) { const remove = el("button", "Remove last shot"); remove.type = "button"; remove.onclick = () => { clip.prompt = prompt.value; syncPrompt(clip, clip.prompt); clip.slots.pop(); clip.slots.at(-1).end = clip.duration; rebuildPromptAfterStructureChange(clip); setState(); render(); }; actions.append(remove); }
panel.append(actions);
display.computeSize = (width) => [Math.max(360, Number(width) || 360), Math.min(620, 160 + clip.slots.length * 42)];
node.setSize?.([Math.max(360, Number(node.size?.[0]) || 360), Number(node.computeSize?.()[1]) || 420]);
// The editor now contains chips, the prompt check and encoder summary;
// the old slot-count estimate left a large blank tail in the node.
// Measure the actual DOM panel instead of guessing from slot count.
const panelHeight = Math.ceil(panel.getBoundingClientRect().height || panel.scrollHeight || 0);
display.computeSize = (width) => [Math.max(420, Number(width) || 420), panelHeight + 2];
const fittedWidth = Math.max(420, Number(node.size?.[0]) || 420);
const fittedHeight = Number(node.computeSize?.()[1]) || panelHeight + 180;
node.setSize?.([fittedWidth, fittedHeight]);
};
const refresh = () => { state = readState(stateWidget, Number(countWidget.value) || 2, Number(secondsWidget.value) || 4); render(); setState(); };
countWidget.callback = ((previous) => function(...args) { const result = previous?.apply(this, args); refresh(); return result; })(countWidget.callback);