Make videos on the computer you already own. FreeVideo runs MiniMax H3 in as little as 8 GB of VRAM and 16 GB of RAM, and adapts its acceleration path to your hardware.
Ask before generating from an empty prompt: one notice with a Generate anyway button
Bowen Xueed43b98502bf
diff --git a/freevideo_engine/cli.py b/freevideo_engine/cli.pyindex 6787168..7e15b6b 100644--- a/freevideo_engine/cli.py+++ b/freevideo_engine/cli.py@@ -96,6 +96,7 @@ def main():source = generate.add_mutually_exclusive_group(required=True)source.add_argument('--prompt-file', type=Path)source.add_argument('--conditioning', type=Path)+ generate.add_argument('--allow-empty-prompt', action='store_true', help='Generate from an empty prompt file')generate.add_argument('--cache', type=Path, required=True)generate.add_argument('--base', type=Path)generate.add_argument('--checkpoint', type=Path)diff --git a/freevideo_engine/comfy_bridge.py b/freevideo_engine/comfy_bridge.pyindex 395c2c8..b8cb150 100644--- a/freevideo_engine/comfy_bridge.py+++ b/freevideo_engine/comfy_bridge.py@@ -856,8 +856,10 @@ def installation(source=None, environ=None):def validate_request(prompt, width, height, seconds, seed, *, continue_from=None, frames=None,- two_pass=True, preview=False, refine_from=None, media=None, original_audio=False):- if not isinstance(prompt, str) or not prompt.strip():+ two_pass=True, preview=False, refine_from=None, media=None, original_audio=False,+ allow_empty_prompt=False):+ # Only a request the user sent on purpose without a description may leave it empty.+ if not isinstance(prompt, str) or not (prompt.strip() or allow_empty_prompt is True):raise ValueError('Enter a prompt describing the video and its audio.')if type(seed) is not int or not 0 <= seed <= 2**53 - 1:raise ValueError('Seed must be an integer between 0 and 9007199254740991.')@@ -1181,7 +1183,7 @@ def generate(prompt, width, height, seconds, seed, output_directory, *,force_regenerate=False, base_steps=8, refine_steps=3, comfy_metadata=None,prompt_rewrite_report=None, preview=False, refine_from=None, report_extra=None,continue_from=None, frames=None, first_frame_reference=False, voice_reference=False, hide_tail=False,- step_cache=None, upscale_factor=2):+ step_cache=None, upscale_factor=2, allow_empty_prompt=False):from .tiers import STEP_CACHESfrom .two_pass import SCALESif upscale_factor not in SCALES:@@ -1223,6 +1225,8 @@ def generate(prompt, width, height, seconds, seed, output_directory, *,refine_steps = int(argument(arguments, '--refine-steps', 3))# The second pass never uses a step cache; the preview's own command keeps its flag.step_cache = argument(arguments, '--step-cache')+ # The preview's own permission for an empty prompt travels with its saved request.+ allow_empty_prompt = allow_empty_prompt or '--allow-empty-prompt' in argumentsif preview or upscale:# A preview stays the quick half-size first pass, and its upscale continues that same pass.upscale_factor = 2@@ -1230,7 +1234,8 @@ def generate(prompt, width, height, seconds, seed, output_directory, *,validate_flags(preview, upscale, two_pass, base_steps)from .two_pass import validate_stepsvalidate_steps(base_steps, refine_steps, two_pass)- canvas = validate_request(prompt, width, height, seconds, seed, continue_from=continue_from, frames=frames)+ canvas = validate_request(prompt, width, height, seconds, seed, continue_from=continue_from, frames=frames,+ allow_empty_prompt=allow_empty_prompt)source = Path(source or source_root()).resolve()root, machine = installation(source, environ)continuation = None@@ -1292,6 +1297,8 @@ def generate(prompt, width, height, seconds, seed, output_directory, *,'--width', str(width), '--height', str(height), '--seconds', str(seconds), '--seed', str(seed),'--two-pass' if two_pass else '--no-two-pass','--base-steps', str(base_steps), '--refine-steps', str(refine_steps)]+ if allow_empty_prompt is True:+ command.append('--allow-empty-prompt')if step_cache is not None:command += ['--step-cache', step_cache]if two_pass and upscale_factor != 2:diff --git a/freevideo_engine/comfy_nodes.py b/freevideo_engine/comfy_nodes.pyindex 3ee95e3..4e85d2c 100644--- a/freevideo_engine/comfy_nodes.py+++ b/freevideo_engine/comfy_nodes.py@@ -136,6 +136,8 @@ class FreeVideoGenerate(io.ComfyNode):io.Combo.Input('upscale_factor', display_name='Upscale factor', options=list(UPSCALE_OPTIONS), default='2',optional=True, advanced=True,tooltip='Two-pass only: a smaller factor starts from a larger first pass, for more detail and a longer run.'),+ io.Boolean.Input('allow_empty_prompt', display_name='Allow empty prompt', default=False,+ optional=True, advanced=True, tooltip='Generates from an empty prompt instead of asking for one.'),],outputs=[io.Video.Output('video'), io.String.Output('report', display_name='Report JSON')],hidden=[io.Hidden.unique_id, io.Hidden.prompt, io.Hidden.extra_pnginfo],@@ -145,7 +147,7 @@ class FreeVideoGenerate(io.ComfyNode):@classmethoddef validate_inputs(cls, text, width, height, seconds, seed, continue_from='', frames=0, two_pass=True,preview=False, refine_from='', base_steps=8, refine_steps=3, step_cache='none',- upscale_factor='2'):+ upscale_factor='2', allow_empty_prompt=False):# ComfyUI marks every input named here when a check fails, so only the checked widgets are# listed. Linked pictures, media and conditioning have no value before the run anyway.# step_cache and upscale_factor are named so ComfyUI skips their option lists: an older saved@@ -159,7 +161,8 @@ class FreeVideoGenerate(io.ComfyNode):base_steps, refine_steps = part_steps(base_steps, refine_steps, step_cache)[:2]options.update(two_pass=True, preview=False, refine_from=refine_from or None,media=dict(first=False, last=False, conditioning_info=False))- comfy_bridge.validate_request(text, width, height, seconds, seed, **options)+ comfy_bridge.validate_request(text, width, height, seconds, seed, **options,+ allow_empty_prompt=allow_empty_prompt is True)if not refine_from:from .two_pass import validate_stepsvalidate_steps(base_steps, refine_steps, two_pass)@@ -186,7 +189,7 @@ class FreeVideoGenerate(io.ComfyNode):references=None, loras=None, conditioning=None, media=None, two_pass=True,force_regenerate=False, base_steps=8, refine_steps=3, preview=False, refine_from='',continue_from='', frames=0, first_frame_reference=False, voice_reference=False, hide_tail=False,- step_cache='none', upscale_factor='2'):+ step_cache='none', upscale_factor='2', allow_empty_prompt=False):from server import PromptServerfrom .comfy_chain import block_context, block_finished, report_fieldsrefine_from, continue_from = optional_text(refine_from), optional_text(continue_from)@@ -334,6 +337,7 @@ class FreeVideoGenerate(io.ComfyNode):**({'first_frame_reference': True} if first_frame_reference is True and options.get('continue_from') else {}),**({'voice_reference': True} if voice_reference is True and options.get('continue_from') else {}),**({'hide_tail': True} if hide_tail is True else {}),+ **({'allow_empty_prompt': True} if allow_empty_prompt is True else {}),**step_cache_option(step_cache),**upscale_option(upscale_factor),**({'report_extra': {'chain': report_fields(chain)}} if chain is not None else {}))diff --git a/freevideo_engine/encode_worker.py b/freevideo_engine/encode_worker.pyindex 6f17358..fc3a534 100644--- a/freevideo_engine/encode_worker.py+++ b/freevideo_engine/encode_worker.py@@ -239,7 +239,7 @@ def _encode(args, request, resident, trace):if idle and resident is None:raise ValueError('GPU preloading requires the managed resident worker')prompt = request.get('prompt', 'library check')- if not isinstance(prompt, str) or not prompt.strip():+ if not isinstance(prompt, str) or not (prompt.strip() or request.get('allow_empty_prompt') is True):raise ValueError('A nonempty prompt is required')started = time.perf_counter()import torchdiff --git a/freevideo_engine/generate.py b/freevideo_engine/generate.pyindex 3e0dfd8..85489c8 100644--- a/freevideo_engine/generate.py+++ b/freevideo_engine/generate.py@@ -784,6 +784,9 @@ def _run(args):shutil.copyfile(args.conditioning, condition)if args.prompt_file and not refine_source:prompt_text = args.prompt_file.read_text(encoding='utf-8')+ # Checked before any cache lookup: a cached conditioning never stands in for the explicit permission.+ if not prompt_text.strip() and getattr(args, 'allow_empty_prompt', False) is not True:+ raise ValueError('A nonempty prompt is required')if first_frame is not None and first_frame['used']:# The saved prompt stays the user's own; the model is also told what the picture is.from .continuation import first_frame_prompt@@ -795,6 +798,8 @@ def _run(args):'ram_budget_bytes': round(profile['inference_ram_budget_gb'] * 1e9),'metrics': str(destination.with_suffix('.encoding.json')),'diagnostic_output': str(destination)}+ if getattr(args, 'allow_empty_prompt', False):+ encoding['allow_empty_prompt'] = Trueif media:from .paths import base_pathencoding.update(media=media, geometry=canvas, base=profile['engine'].get('base') or str(base_path()),diff --git a/freevideo_engine/macos_encoder.py b/freevideo_engine/macos_encoder.pyindex 20bc20c..1c0e017 100644--- a/freevideo_engine/macos_encoder.py+++ b/freevideo_engine/macos_encoder.py@@ -127,10 +127,10 @@ def install_weight_reader(clip, backend, checkpoint, *, decoder=nvfp4_weight, podef encode(prompt, output, *, root, budget_bytes=3 * 2**30, reserve_bytes=2 * 2**30,library=None, checkpoint=None, weight_decoder='cpu', media=None, canvas=None, base=None,- media_budget_bytes=None):+ media_budget_bytes=None, allow_empty_prompt=False):if sys.platform != 'darwin' or os.environ.get('PYTORCH_ENABLE_MPS_FALLBACK', '0') not in ('', '0'):raise RuntimeError('This encoder requires native Mac with CPU fallback disabled')- if not isinstance(prompt, str) or not prompt.strip():+ if not isinstance(prompt, str) or not (prompt.strip() or allow_empty_prompt is True):raise ValueError('A nonempty prompt is required')if media_budget_bytes is not None and (type(media_budget_bytes) is not int or media_budget_bytes <= 0):raise ValueError('Native media encoding requires a positive byte allowance')diff --git a/freevideo_engine/macos_generate.py b/freevideo_engine/macos_generate.pyindex 4b305b5..7f3400e 100644--- a/freevideo_engine/macos_generate.py+++ b/freevideo_engine/macos_generate.py@@ -275,7 +275,7 @@ def run(args):report['phase'] = 'encoding'save(output.with_suffix('.request.json'), report)prompt = Path(args.prompt_file).read_text(encoding='utf-8')- if not prompt.strip():+ if not prompt.strip() and not getattr(args, 'allow_empty_prompt', False):raise ValueError('A nonempty prompt is required')prompt_file = Path(args.prompt_file).resolve()if report.get('first_frame_reference', {}).get('used'):@@ -292,7 +292,8 @@ def run(args):report['encoding_resources'] = execute(dict(phase='encoding', root=str(data_root()),prompt_file=str(prompt_file), output=str(conditioning),report=str(output.with_suffix('.encoding.json')), checkpoint=str(checkpoint),- library=str(library), resources=resource, media=media, canvas=canvas, base=base), 'encoding')+ library=str(library), resources=resource, media=media, canvas=canvas, base=base,+ **({'allow_empty_prompt': True} if getattr(args, 'allow_empty_prompt', False) else {})), 'encoding')metrics = json.loads(output.with_suffix('.encoding.json').read_text())if cache:try:@@ -411,6 +412,7 @@ def worker(value):budget_bytes=resource['encoder_bytes'], reserve_bytes=resource['reserve_bytes'],media_budget_bytes=resource.get('allocator_capacity_bytes', resource['encoder_bytes']),weight_decoder=resource.get('encoder_weight_decoder', 'cpu'),+ allow_empty_prompt=value.get('allow_empty_prompt') is True,media=value.get('media'), canvas=value.get('canvas'), base=value.get('base')))result['work_seconds'] = time.monotonic() - startedexcept BaseException as error:diff --git a/web/autopilot_chat.js b/web/autopilot_chat.jsindex 70da243..1698340 100644--- a/web/autopilot_chat.js+++ b/web/autopilot_chat.js@@ -13,6 +13,7 @@ import {canDeleteConversation, conversationMenu, emptyConversations, hasConversaimport {renderImageFailure} from './image_generation.js';import {issueButton} from './issue_button.js';import {about} from './request_assets.js';+import {showEmptyPrompt} from './empty_prompt_notice.js';const css = document.createElement('link'); css.rel = 'stylesheet'; css.href = new URL('./autopilot_chat.css', import.meta.url).href; document.head.append(css);@@ -1039,8 +1040,16 @@ export function agentChat(t, api, {open, edit, shown = () => true, changed = ()status.setAttribute('role', 'status');const error = el('p', 'fv-chat-error'); error.setAttribute('role', 'alert');const write = (node, text) => { if (node.textContent !== text) node.textContent = text; node.hidden = !text; };- const answer = approve => async () => {+ const answer = (approve, allowEmpty = false) => async () => {if (disabled || confirming.has(key) || !inSelectedChat() || state.session !== session || whiteboxState(entry) !== 'asked') return;+ // A card with no description at all: say so, and start only when the user chooses to go on.+ if (approve && !allowEmpty && !(entry.whitebox.summary || entry.whitebox.scene_summary || '').trim()) {+ const notice = showEmptyPrompt({t, anchor: buttons, field: input, onContinue: answer(true, true)});+ // Where Skip has wrapped to its own row, the notice sits right under the button row, before Skip.+ const skip = buttons.querySelector('.fv-chat-no'), first = buttons.firstElementChild;+ if (skip && first !== skip && skip.offsetTop > first.offsetTop + 4) { notice.classList.add('fv-empty-prompt-inline'); skip.before(notice); }+ return;+ }const requestKey = key, requestSession = session, id = entry.id;confirming.add(requestKey); confirmErrors.delete(requestKey); render();try {diff --git a/web/editor.css b/web/editor.cssindex 886a2ea..8375feb 100644--- a/web/editor.css+++ b/web/editor.css@@ -103,6 +103,8 @@.fv-ed-first-frame:has(input:disabled){opacity:.4}.fv-ed-description:disabled{opacity:.4}.fv-ed-genbar{position:relative}+.fv-ed-genbar:has(.fv-empty-prompt){flex-wrap:wrap}+.fv-ed-genbar .fv-empty-prompt{margin:0 0 0 auto;flex:0 1 auto}.fv-ed-refs{display:flex;align-items:center;gap:6px;flex:none}.fv-ed-refs[hidden],.fv-ed-ref-menu[hidden]{display:none}.fv-ed-ref-notice{position:absolute;bottom:calc(100% + 8px);max-width:min(560px,calc(100% - 24px));border:1px solid var(--fv-border);background:var(--fv-card);padding:10px 14px;border-radius:8px;z-index:9;color:var(--fv-ink);pointer-events:none}@@ -207,6 +209,7 @@.fv-ed-gen-note{order:-1;flex:1 1 100%;white-space:normal}.fv-editor .fv-ed-genbar>button{margin-left:auto;max-width:100%;height:36px;min-height:36px;font-size:12px}.fv-editor .fv-ed-genbar>button:not([hidden]) ~ button:not([hidden]){margin-left:0}+ .fv-ed-genbar .fv-empty-prompt{flex:0 0 100%;justify-content:flex-end;margin:0}.fv-ed-name-menu{position:fixed;top:120px;left:8px}/* Beside the view switch it covered "Editor"; here it sits at the foot of the picture area, in the grid. */.fv-ed-notice{position:relative;grid-column:1;grid-row:2;align-self:end;justify-self:end;margin:0 16px 8px;bottom:auto;right:auto;pointer-events:none}diff --git a/web/editor.js b/web/editor.jsindex 9c8b36c..b8eb519 100644--- a/web/editor.js+++ b/web/editor.js@@ -32,7 +32,7 @@ import {createFirstRunGuide} from './first_run_guide.js';import {SHOWCASE_SCENE} from './entry_showcase.js';import {createEditorFailures} from './editor_failure.js';import {fitEditorHeader} from './editor_header_fit.js';-import {optionalText, clonePrompt} from './optional_inputs.js';+import {optionalText, clonePrompt, allowEmptyPrompt} from './optional_inputs.js';import {outputNotWritable} from './error_panel.js';import {repairAction} from './repair_hint.js';import {expandCast} from './cast_mention.js';@@ -472,7 +472,7 @@ export function openEditor({api, app, from = null, panel = {}, components: givenprogress.set(id, value); tracks?.setProgress(id, value);} };const queuedReady = () => t('Queued. It starts once generation is ready.', '已排队,准备好后自动开始。');- function hold(selection, text, job = null, {texts = null, shown = selection === state.selection} = {}) {+ function hold(selection, text, job = null, {texts = null, shown = selection === state.selection, allowEmpty = false} = {}) {const range = selectionRange(selection), selectedIds = selectionClips(selection).map(clip => clip.id);let ids = [];if (job) ids = selectedIds;@@ -482,7 +482,7 @@ export function openEditor({api, app, from = null, panel = {}, components: givenids = next.tracks[0].clips.filter(clip => clip.start >= range.start && clip.start < range.start + range.frames && clip.pending && !generating(clip)).map(clip => clip.id);return next;}, {checkpoint: true});- if (!ids.every(isHeld)) held.push({ids, text, job});+ if (!ids.every(isHeld)) held.push({ids, text, job, allowEmpty});markHeld(ids, true);if (shown) state.select({kind: 'clip', ids});rememberView();@@ -507,7 +507,7 @@ export function openEditor({api, app, from = null, panel = {}, components: givenif (before && !before.source && before.pending && !before.job) { genbar?.say(t('The part before did not finish, so this one did not start.', '上一段没有完成,这一段没有开始。')); continue; }// Each part goes with its own description, as written while it waited.const texts = Object.fromEntries(clips.map(clip => [clip.id, clip.text.trim() || entry.text]));- try { await actions.generate({text: texts[clips[0].id], texts, selection}); }+ try { await actions.generate({text: texts[clips[0].id], texts, selection, allowEmpty: entry.allowEmpty === true}); }catch (value) { const reason = error(value, 'generate'); if (reason && !PARTS_LIMIT_CODES.includes(reason.reason)) genbar?.say(reason.say); }}} finally { startingHeld = false; }@@ -633,7 +633,7 @@ export function openEditor({api, app, from = null, panel = {}, components: giveneditorViews.set(key, value);try {// Queued parts stay queued across a reload; they are only planned drafts until sent.- const waiting = held.map(entry => ({ids: entry.ids, text: entry.text}));+ const waiting = held.map(entry => ({ids: entry.ids, text: entry.text, ...(entry.allowEmpty === true ? {allowEmpty: true} : {})}));value.held = waiting;localStorage.setItem(viewPrefix + key, JSON.stringify({selection: value.selection, text: value.text, ...(waiting.length ? {held: waiting} : {})}));if (state.record.id) localStorage.setItem('fv-editor-last', key);@@ -701,7 +701,7 @@ export function openEditor({api, app, from = null, panel = {}, components: givenif (!Array.isArray(entry?.ids) || typeof entry.text !== 'string') continue;const clips = entry.ids.map(id => model.find(state.record, id));if (!clips.length || clips.some(clip => !clip || clip.source || clip.pending !== 'draft' || clip.job) || entry.ids.some(isHeld)) continue;- held.push({ids: [...entry.ids], text: entry.text}); markHeld(entry.ids, true);+ held.push({ids: [...entry.ids], text: entry.text, allowEmpty: entry.allowEmpty === true}); markHeld(entry.ids, true);}viewReady = true;if (record.id) try { localStorage.setItem('fv-editor-last', record.id); localStorage.setItem(usedPrefix + record.id, String(Date.now())); } catch {}@@ -921,11 +921,12 @@ export function openEditor({api, app, from = null, panel = {}, components: givenreturn seconds;},// texts: a description for each planned part, by the part's picture; otherwise text is every part's.- async generate({target = 'both', text = '', texts = null, label = t('Generate', '生成'), selection = state.selection, shown = selection === state.selection} = {}) {+ async generate({target = 'both', text = '', texts = null, label = t('Generate', '生成'), selection = state.selection, shown = selection === state.selection, allowEmpty = false} = {}) {if (target !== 'both' || !actions.supportedSelection(selection)) throw new model.EditError('unsupported');// A half of a pair left by a cut or a paste is dropped; a description over the limit is said before anything is sent.text = wellFormed(text);- if (!actions.canGenerate(text, selection)) throw new model.EditError('text');+ // Only the user's own choice to go on without a description lets an empty one through.+ if (!(allowEmpty === true && !text.trim() && store.generationAvailable && actions.needsText(selection)) && !actions.canGenerate(text, selection)) throw new model.EditError('text');if (characters(text) > model.RULES.maxText) throw Object.assign(new model.EditError('text_long'), {limit: model.RULES.maxText});submissionFailure = null; genbar?.update(null);const chosen = state.selection;@@ -961,6 +962,7 @@ export function openEditor({api, app, from = null, panel = {}, components: given}const follow = continuedSize(beforeKeys, sizes), edit = capability.generationSize || generationSize(state.record);Object.assign(frozen.prompt[frozen.node].inputs, follow || {});+ if (allowEmpty === true && [text, ...Object.values(texts ?? {})].some(value => !value.trim())) allowEmptyPrompt({output: frozen.prompt}, frozen.node);// Parts made at another size than the edit's have that size's limit.const limit = (follow && (follow.width !== edit.width || follow.height !== edit.height)? await store.requestFrames(follow, state.record.settings) : null) ?? capability.maxRequestFrames;@@ -1007,7 +1009,7 @@ export function openEditor({api, app, from = null, panel = {}, components: given} finally { sendingRanges.delete(range); for (const id of ids) sending.delete(id); if (disposed && ids.length) queue.enqueue(state.record); generationBusy = false; finishGeneration?.(); generationDone = null; finishGeneration = null; updateTop(); updateTransport(); startHeld(); }},// A press on Generate always answers: what can be done for the user is done, then said in one line.- async press(text) {+ async press(text, {allowEmpty = false} = {}) {if (disposed || closing || initializing) return {say: t('Opening the edit…', '正在打开…')};text = wellFormed(text);let selection = state.selection, said = null;@@ -1047,8 +1049,8 @@ export function openEditor({api, app, from = null, panel = {}, components: givenif (!value && i && attached(clip, run[i - 1])) { value = texts[run[i - 1].id]; used ??= before; }else if (!value) {const found = nearbyText(clip.start);- if (!found) return {say: [said, t('Write a description first.', '先写一句描述。')].filter(Boolean).join(' '), focus: true};- value = found.text; used ??= found.before ? before : latest;+ if (!found && !allowEmpty) return {say: said, empty: true, focus: true};+ if (found) { value = found.text; used ??= found.before ? before : latest; }}texts[clip.id] = value;}@@ -1056,8 +1058,8 @@ export function openEditor({api, app, from = null, panel = {}, components: givenselection = clipChoice(run);} else if (!text.trim() && actions.needsText(selection)) {const found = nearbyText(selectionRange(selection).start);- if (!found) return {say: [said, t('Write a description first.', '先写一句描述。')].filter(Boolean).join(' '), focus: true};- text = found.text; used = found.before ? before : latest;+ if (!found && !allowEmpty) return {say: said, empty: true, focus: true};+ if (found) { text = found.text; used = found.before ? before : latest; }state.setRangeText(text); genbar?.setText(text);} else if (!text.trim()) {// The box was emptied; the part keeps the description it took over, as an empty one cannot be generated.@@ -1066,12 +1068,12 @@ export function openEditor({api, app, from = null, panel = {}, components: given}const waiting = waitingFor(selection);if (waiting) {- hold(selection, texts ? texts[run[0].id] : text, null, {texts, shown});+ hold(selection, texts ? texts[run[0].id] : text, null, {texts, shown, allowEmpty});return {text, say: [said, used, waiting === 'ready' ? queuedReady(): t('Queued. It starts after the previous part finishes.', '已排队,上一段完成后自动开始。')].filter(Boolean).join(' '), queued: true};}const busyBefore = jobActive();- await actions.generate({text: texts ? texts[run[0].id] : text, texts, selection, shown});+ await actions.generate({text: texts ? texts[run[0].id] : text, texts, selection, shown, allowEmpty});return {text, say: [said, used, busyBefore ? t('Queued. It starts after the part now generating.', '已排队,正在生成的那段完成后自动开始。') : null].filter(Boolean).join(' ') || null, queued: busyBefore};},selectionRunning: () => busySelection(state.selection),diff --git a/web/editor_genbar.js b/web/editor_genbar.jsindex 1e4a5b1..b6992f0 100644--- a/web/editor_genbar.js+++ b/web/editor_genbar.js@@ -5,6 +5,7 @@ import {createExpandButton} from './editor_expand.js';import {createRequestAssets} from './request_assets.js';import {issueButton} from './issue_button.js';import {waitingText} from './chain_support.js';+import {showEmptyPrompt} from './empty_prompt_notice.js';const el = (tag, cls, text) => { const e = document.createElement(tag); if (cls) e.className = cls; if (text != null) e.textContent = text; return e; };export const timeEstimate = (seconds, t) => seconds == null ? '' : seconds < 60? t(`about ${Math.max(1, Math.ceil(seconds))} s`, `约 ${Math.max(1, Math.ceil(seconds))} 秒`)@@ -229,7 +230,7 @@ export function createEditorGenbar(host, {state, t, actions, text = ''}) {// The former text input did not submit or insert a line on Enter.if (event.key === 'Enter' && !event.shiftKey && !event.isComposing && event.keyCode !== 229) event.preventDefault();};- generate.onclick = async () => {+ const press = async (allowEmpty = false) => {const key = JSON.stringify(state.selection ?? null);if (pressing.has(key)) return;pressing.add(key); say(''); render();@@ -239,10 +240,11 @@ export function createEditorGenbar(host, {state, t, actions, text = ''}) {try {// The press shows before any planning, however long that takes.await painted();- const result = actions.press ? await actions.press(input.value) : await actions.generate({target: 'both', text: input.value});+ const result = actions.press ? await actions.press(input.value, allowEmpty ? {allowEmpty} : undefined) : await actions.generate({target: 'both', text: input.value});// Never over what the user typed meanwhile, for another part.if (result?.text != null && result.text !== input.value && input.value === shown) input.value = result.text;if (result?.say) { say(result.say, !!result.queued); reason = result.say; }+ if (result?.empty) showEmptyPrompt({t, anchor: generate, field: input, onContinue: () => press(true)});if (result?.focus) { pressing.delete(key); render(); input.disabled = false; input.focus(); }}// A specific reason is said once; the planning limits are already shown above.@@ -252,6 +254,7 @@ export function createEditorGenbar(host, {state, t, actions, text = ''}) {finally { pressing.delete(key); render(); }return reason;};+ generate.onclick = () => press();const expand = createExpandButton({t, textarea: input, onGenerate: () => generate.onclick(), canGenerate: () => !generate.disabled, onDraft: text => typed(text)});description.append(expand.element);cancel.onclick = () => (!previewSelection && actions.selectionHeld?.() ? Promise.resolve(actions.unhold()).then(render) : actions.cancel()).catch(actions.error);diff --git a/web/empty_prompt_notice.css b/web/empty_prompt_notice.cssnew file mode 100644index 0000000..b68c467--- /dev/null+++ b/web/empty_prompt_notice.css@@ -0,0 +1,4 @@+.fv-empty-prompt{display:flex;flex-wrap:wrap;align-items:center;justify-content:flex-start;gap:6px 12px;margin:8px 0;font-size:var(--fv-body,14px);color:var(--fv-ink,#e8ecf3)}+.fv-empty-prompt>span:first-child{white-space:nowrap}+.fv-empty-prompt.fv-actions{justify-content:flex-start}+.fv-empty-prompt.fv-empty-prompt-inline{flex:0 0 100%;margin:0}diff --git a/web/empty_prompt_notice.js b/web/empty_prompt_notice.jsnew file mode 100644index 0000000..f50595d--- /dev/null+++ b/web/empty_prompt_notice.js@@ -0,0 +1,38 @@+// One notice for every generate button that is pressed with an empty prompt: the sentence and one button,+// right after the pressed control. Typing in the prompt box or pressing elsewhere removes it.+if (typeof document !== 'undefined') {+ for (const name of ['result_actions.css', 'empty_prompt_notice.css']) {+ const link = document.createElement('link');+ link.rel = 'stylesheet'; link.href = new URL('./' + name, import.meta.url).href; document.head.append(link);+ }+}++let shown = null;++export function dismissEmptyPrompt() { if (shown) shown.dismiss(); }++// `anchor`: the control (or its row) the notice follows. `field`: the prompt box, which takes the focus back.+// `onContinue` runs after the notice is gone.+export function showEmptyPrompt({t, anchor, field = null, onContinue}) {+ dismissEmptyPrompt();+ const doc = document;+ const box = doc.createElement('div'); box.className = 'fv-empty-prompt fv-actions'; box.setAttribute('role', 'status');+ const sentence = doc.createElement('span'); sentence.textContent = t('The prompt is empty.', '提示词为空。');+ const go = doc.createElement('button'); go.type = 'button'; go.className = 'fv-action fv-action-primary';+ const label = doc.createElement('span'); label.textContent = t('Generate anyway', '继续生成'); go.append(label);+ box.append(sentence, go);+ const gone = () => {+ doc.removeEventListener('pointerdown', outside, true);+ field?.removeEventListener('input', dismiss);+ box.remove(); if (shown?.box === box) shown = null;+ };+ const dismiss = () => gone();+ const outside = event => { if (!box.contains(event.target)) gone(); };+ go.onclick = () => { gone(); onContinue(); };+ anchor.after(box);+ doc.addEventListener('pointerdown', outside, true);+ field?.addEventListener('input', dismiss);+ field?.focus({preventScroll: true});+ shown = {box, dismiss};+ return box;+}diff --git a/web/optional_inputs.js b/web/optional_inputs.jsindex 88c4c65..f87e547 100644--- a/web/optional_inputs.js+++ b/web/optional_inputs.js@@ -69,6 +69,13 @@ export function cleanOptionalWidgets(node) {}}+// The user chose to generate without a description: this request alone says so; the node's own widgets never keep it.+export function allowEmptyPrompt(prompt, nodeId) {+ const inputs = prompt?.output?.[String(nodeId)]?.inputs;+ if (inputs) inputs.allow_empty_prompt = true;+ return prompt;+}+export function cleanOptionalPrompt(prompt) {for (const entry of Object.values(prompt?.output || {})) {if (entry?.class_type !== 'FreeVideoGenerate' || !entry.inputs) continue;diff --git a/web/studio.js b/web/studio.jsindex d12cb63..8bc9378 100644--- a/web/studio.js+++ b/web/studio.js@@ -1,7 +1,8 @@import {createLanAccess} from './lan_access.js';import { createErrorPanel, errorText, createErrorReport } from './error_panel.js';import {createExpandButton} from './editor_expand.js';-import {cleanOptionalPrompt, clonePrompt} from './optional_inputs.js';+import {allowEmptyPrompt, cleanOptionalPrompt, clonePrompt} from './optional_inputs.js';+import {showEmptyPrompt, dismissEmptyPrompt} from './empty_prompt_notice.js';import { app } from '../../scripts/app.js';import { api } from '../../scripts/api.js';import { openSetup } from './setup.js';@@ -1602,7 +1603,7 @@ export function openStudio(node, {extendFrom = null} = {}) {return removed?.apply(this, args);};}- const runrow = el('div', null, 'fv-runrow');+ const runrow = el('div', null, 'fv-runrow'); cleanup.push(dismissEmptyPrompt);const runOptions = el('details', null, 'fv-run-options');const optionsToggle = el('summary'); optionsToggle.title = t('Generation mode', '生成方式');optionsToggle.setAttribute('aria-label', optionsToggle.title);@@ -1840,7 +1841,8 @@ export function openStudio(node, {extendFrom = null} = {}) {status.textContent = reply.status === 'cancelling' ? t('Stopping generation…', '正在停止生成…') : '';} catch (error) { cancelling = false; updateRunButton(); showQueueError(error); }}- async function submitDraft() {+ async function submitDraft(options) {+ const emptyAllowed = options?.allowEmpty === true;if (capturing || queueState?.submitting) return;// Ctrl+Enter leaves focus in a field: commit its edit (change fires on blur) first.const editing = dialog.contains(document.activeElement) ? document.activeElement : null;@@ -1858,7 +1860,9 @@ export function openStudio(node, {extendFrom = null} = {}) {}invalid.focus(); invalid.reportValidity(); return;}- if (!extension.source && !prompt.disabled && !prompt.value.trim() && !untouched() && !swapState(mediaNode)) { prompt.focus(); status.textContent = t('Describe your scene first.', '请先描述画面。'); return; }+ if (!emptyAllowed && !extension.source && !prompt.disabled && !prompt.value.trim() && !untouched() && !swapState(mediaNode)) {+ showEmptyPrompt({t, anchor: runrow, field: prompt, onContinue: () => submitDraft({allowEmpty: true})}); return;+ }if (swapState(mediaNode)) {const missing = swapMissing(swapState(mediaNode));if (missing) { status.dataset.error = 'true'; status.textContent = swapMissingText(missing, t); return; }@@ -1891,7 +1895,9 @@ export function openStudio(node, {extendFrom = null} = {}) {// and all GPU execution leave the next draft fully editable.for (const section of controls.querySelectorAll('.fv-section')) section.inert = true;held = turnNodeOn(node);- const snapshot = singleRunSnapshot(extendSnapshot(cleanOptionalPrompt(clonePrompt(await app.graphToPrompt())), node.id, source,+ const graph = cleanOptionalPrompt(clonePrompt(await app.graphToPrompt()));+ if (emptyAllowed && !prompt.value.trim() && !extension.source) allowEmptyPrompt(graph, node.id);+ const snapshot = singleRunSnapshot(extendSnapshot(graph, node.id, source,{multiple: lengthPlan?.count > 1}), node.id, lengthPlan);if (!snapshot) { fault(t('Could not prepare this run. Try again.', '没能准备这次生成,请重试。')); return; }const seedIndex = node.widgets.findIndex(w => w.name === 'seed');