Skip to content

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.

Cover the host-graph copy fallback in the creation panel, editor entry, queue and launcher tests

Bowen Xue686b516e2ac8
diff --git a/web/editor.js b/web/editor.js
index e89323c..ffcb436 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} from './optional_inputs.js';
+import {optionalText, clonePrompt} from './optional_inputs.js';
import {outputNotWritable} from './error_panel.js';
import {repairAction} from './repair_hint.js';
import {expandCast} from './cast_mention.js';
@@ -504,7 +504,7 @@ export function openEditor({api, app, from = null, panel = {}, components: given
exportButton.disabled = false; exportButton.title = '';
}
async function snapshot() {
- let value = panel.snapshot ? structuredClone(await panel.snapshot()) : structuredClone(await app.graphToPrompt());
+ let value = panel.snapshot ? clonePrompt(await panel.snapshot()) : clonePrompt(await app.graphToPrompt());
if (value.output) {
const node = String(panel.node?.id || panel.node || Object.keys(value.output).find(id => value.output[id].class_type === 'FreeVideoGenerate') || '');
value = {node, prompt: value.output, extra_data: {extra_pnginfo: {workflow: value.workflow || {}}}};
diff --git a/web/editor_entry.js b/web/editor_entry.js
index 0a576e2..e976249 100644
--- a/web/editor_entry.js
+++ b/web/editor_entry.js
@@ -3,7 +3,7 @@ import {openEditor} from './editor.js';
import {api} from '../../scripts/api.js';
import {app} from '../../scripts/app.js';
import {openStudio, showNodes} from './studio.js';
-import {cleanOptionalPrompt} from './optional_inputs.js';
+import {cleanOptionalPrompt, clonePrompt} from './optional_inputs.js';
import {openAutopilot, viewChanged} from './view_navigation.js';
import {mediaReferences} from './editor_media_references.js';
import {turnNodeOn} from './studio_queue.js';
@@ -18,7 +18,7 @@ function editorPanel(node) {
// A muted or bypassed node would be left out of the request; if no request comes out, it stays as it was.
const held = turnNodeOn(node);
let value;
- try { value = cleanOptionalPrompt(structuredClone(await app.graphToPrompt())); } catch (error) { held?.restore(); throw error; }
+ try { value = cleanOptionalPrompt(clonePrompt(await app.graphToPrompt())); } catch (error) { held?.restore(); throw error; }
held?.done();
return {node: String(node.id), prompt: value.output, extra_data: {extra_pnginfo: {workflow: value.workflow || {}}}};
}};
diff --git a/web/launcher.js b/web/launcher.js
index 5fa5841..ed1eafa 100644
--- a/web/launcher.js
+++ b/web/launcher.js
@@ -3,6 +3,7 @@ import { api } from '../../scripts/api.js';
import { restorePromptDraft } from './prompt_draft.js';
import { takePortMarker } from './port_notice.js';
import { launcherRestoreFinished } from './workspace_restore.js';
+import { clonePrompt } from './optional_inputs.js';
// health.js names what failed; files loaded before it queue their reports.
const health = item => (window.__freevideoHealth ||= []).push(item);
@@ -93,7 +94,7 @@ async function existingStudioWorkflow(target, bundled) {
// Only the shared tab is ours to replace; a workflow the user saved under another name stays.
const current = target.path === 'workflows/FreeVideo.json' ? currentStudioWorkflow(saved, bundled) : null;
if (current) return restorePromptDraft(api, current, target.path);
- const graph = structuredClone(saved);
+ const graph = clonePrompt(saved);
if (!graph.nodes?.some(node => node.type === 'FreeVideoGenerate')) {
const node = structuredClone(bundled.nodes.find(node => node.type === 'FreeVideoGenerate'));
node.id = Math.max(graph.last_node_id || 0, ...graph.nodes.map(node => Number(node.id) || 0)) + 1;
@@ -154,7 +155,7 @@ async function keepInFront(workflow, opened) {
if (studioWorkflow(app.graph)) {
const current = app.graph.serialize(), target = store?.activeWorkflow;
const replaced = target?.path === 'workflows/FreeVideo.json' ? currentStudioWorkflow(current, workflow) : null;
- const restored = await restorePromptDraft(api, replaced || structuredClone(current), target?.path || '__existing__');
+ const restored = await restorePromptDraft(api, replaced || clonePrompt(current), target?.path || '__existing__');
if (JSON.stringify(restored) !== JSON.stringify(current))
await app.loadGraphData(restored, true, true, target || 'FreeVideo');
return;
diff --git a/web/optional_inputs.js b/web/optional_inputs.js
index 7f3404a..0cbd4f1 100644
--- a/web/optional_inputs.js
+++ b/web/optional_inputs.js
@@ -52,3 +52,14 @@ export function cleanOptionalPrompt(prompt) {
}
return prompt;
}
+
+// A graph taken from the host can carry a value structuredClone refuses, such as a reactive proxy another
+// extension left in the workflow's extra data. The request is JSON on the wire, so when the native copy
+// fails the JSON copy stands in for it; a graph that clones natively is copied exactly as before.
+export function clonePrompt(value) {
+ try { return structuredClone(value); }
+ catch (error) {
+ if (error?.name !== 'DataCloneError') throw error;
+ return JSON.parse(JSON.stringify(value));
+ }
+}
diff --git a/web/studio.js b/web/studio.js
index 0e68618..ee0248b 100644
--- a/web/studio.js
+++ b/web/studio.js
@@ -2,7 +2,7 @@ import {createLanAccess} from './lan_access.js';
import { createErrorPanel, errorText, createErrorReport } from './error_panel.js';
import {topDialog} from './dialog_keys.js';
import {createExpandButton} from './editor_expand.js';
-import {cleanOptionalPrompt} from './optional_inputs.js';
+import {cleanOptionalPrompt, clonePrompt} from './optional_inputs.js';
import { app } from '../../scripts/app.js';
import { api } from '../../scripts/api.js';
import { openSetup } from './setup.js';
@@ -1697,7 +1697,7 @@ 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(structuredClone(await app.graphToPrompt())), node.id, source,
+ const snapshot = singleRunSnapshot(extendSnapshot(cleanOptionalPrompt(clonePrompt(await app.graphToPrompt())), 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');
diff --git a/web/studio_queue.js b/web/studio_queue.js
index 7580237..3d3ffad 100644
--- a/web/studio_queue.js
+++ b/web/studio_queue.js
@@ -1,7 +1,8 @@
// ComfyUI owns execution. This controller only submits frozen workflows and
// replenishes a loop after its previous request has actually completed.
import {fetchQueueRead, detectBrowserExtension, isNetworkTypeError} from './browser_extension.js';
-const clone = value => structuredClone(value);
+import {clonePrompt} from './optional_inputs.js';
+const clone = clonePrompt;
// One dropped read is usually a connection reset or an engine restart. Only this many
// polls failing in a row are shown; the next successful read clears the notice.