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.

Part-by-part videos report cancel, resume and finished states after refresh and say why they fail

Bowen Xue888e54e48d8d
diff --git a/web/studio.js b/web/studio.js
index 3e021ce..83c9ec7 100644
--- a/web/studio.js
+++ b/web/studio.js
@@ -881,6 +881,7 @@ export function openStudio(node, {extendFrom = null} = {}) {
},
}));
const queueController = studioQueues.get(node);
+ let chainWasActive = false;
chainController = createStudioChain({api, node, onProgress: (message, chain) => {
const position = chainPosition(chain, message);
const joining = readChainResult(chain).joining, waiting = chain.state === 'queued' && message.phase === 'prepare';
@@ -892,6 +893,11 @@ export function openStudio(node, {extendFrom = null} = {}) {
},
onState: chain => {
const active = chainController.active, position = chainPosition(chain), outcome = readChainResult(chain);
+ if (active && !chainWasActive) {
+ failure.clear(); node.freevideoFailure = ''; node.freevideoFailureReport = null;
+ lastQueueError = null; status.textContent = ''; status.dataset.error = 'false';
+ }
+ chainWasActive = active;
busy = active || Boolean(queueState?.running || queueState?.pending.length); queued = chain?.state === 'queued';
chainLine.hidden = !active;
chainLine.textContent = outcome?.joining ? t('Joining the parts.', '正在接合各段。')
@@ -976,6 +982,8 @@ export function openStudio(node, {extendFrom = null} = {}) {
loop_stopped: t('The last request did not complete. The loop has stopped.', '上一条任务未完成,循环已停止。'),
linked_seed: t('Use the seed in this panel for batch or loop generation.', '批量和循环生成需使用面板内的种子,请先断开种子输入的连接。'),
missing_node: t('This node is disabled or no longer in the workflow.', '该节点已禁用或已从工作流移除。'),
+ chain_cancel_failed: t('Could not cancel. Refresh the page and try again.', '没有取消成功,请刷新页面后再试。'),
+ chain_resume_failed: t('Could not continue. Refresh the page and try again.', '没有继续生成,请刷新页面后再试。'),
}[error?.message] || (error?.said ? t(error.said[0], error.said[1]) : null) || error?.message || String(error));
let lastQueueError = null;
function showQueueError(error) {
@@ -989,6 +997,8 @@ export function openStudio(node, {extendFrom = null} = {}) {
? t('Submission failed. See the details below.', '提交失败,具体原因见下方。')
: extensionCause(error) ? t('A browser extension is interfering with FreeVideo. See details below.', '浏览器扩展干扰了 FreeVideo,详见下方。')
: queueError(error);
+ // Recoverable chain actions need one visible sentence, not a second error card.
+ if (error?.action) { status.scrollIntoView({block: 'nearest'}); return; }
const identity = error?.schema === 'freevideo.error-report' ? error : error?.message || error;
if (lastQueueError === identity) return;
lastQueueError = identity;
@@ -1003,12 +1013,18 @@ export function openStudio(node, {extendFrom = null} = {}) {
// preference so returning to a short video and reloading show the same choice.
runMode = multiple || extension.source ? 'single'
: ['single', 'batch', 'loop'].includes(node.properties?.freevideo_run_mode) ? node.properties.freevideo_run_mode : runMode;
+ const chain = chainController?.state, position = chainPosition(chain);
+ const chainReason = !chainController?.active ? '' : readChainResult(chain)?.joining
+ ? t('Joining parts…', '正在拼接…')
+ : chain?.state === 'queued' ? t('Queued…', '排队中…')
+ : t(`Generating part ${position.index + 1}…`, `正在生成第 ${position.index + 1} 段…`);
generate.disabled = submitting || chainController?.active || lengthControl.blocked || (runMode === 'loop' && queueState?.looping);
generate.textContent = submitting ? t('Adding…', '正在添加…')
- : runMode === 'batch' ? t(`Add ${count.value || '…'} videos`, `添加 ${count.value || '…'} 条任务`)
+ : chainReason || (runMode === 'batch' ? t(`Add ${count.value || '…'} videos`, `添加 ${count.value || '…'} 条任务`)
: runMode === 'loop' ? (queueState?.looping ? t('Looping', '循环中') : t('Start loop', '开始循环'))
: busy ? t('Add to queue', '添加到队列')
- : previewFirst.checked && !previewFirst.disabled ? t('Generate preview', '生成预览') : t('Generate video', '生成视频');
+ : previewFirst.checked && !previewFirst.disabled ? t('Generate preview', '生成预览') : t('Generate video', '生成视频'));
+ generate.title = (lengthControl.blocked ? lengthControl.message : submitting ? t('Adding…', '正在添加…') : '');
for (const b of modeButtons) b.setAttribute('aria-pressed', String(b.dataset.mode === runMode));
for (const b of modeButtons) if (b.dataset.mode !== 'single') b.disabled = multiple;
countField.hidden = runMode !== 'batch'; count.disabled = runMode !== 'batch';
@@ -1024,7 +1040,10 @@ export function openStudio(node, {extendFrom = null} = {}) {
}
function updateExtendButton() {
const button = links.querySelector('.fv-action-extend');
- if (button) button.disabled = busy || queued || capturing || Boolean(chainController?.active);
+ if (button) {
+ button.disabled = capturing;
+ button.title = capturing ? t('Adding…', '正在添加…') : '';
+ }
}
function renderQueue(state) {
if (disposed) return;
@@ -1227,7 +1246,14 @@ export function openStudio(node, {extendFrom = null} = {}) {
busy = cancelling = false; activePrompt = null; updateRunButton(); hideProgress();
failure.clear(); node.freevideoFailure = ''; node.freevideoFailureReport = null; status.dataset.error = 'false'; status.textContent = t('Cancelled', '已取消');
});
- const escape = e => { if ((e.ctrlKey || e.metaKey) && e.key === 'Enter') { e.preventDefault(); generate.click(); } }; dialog.addEventListener('keydown', escape);
+ const escape = e => { if ((e.ctrlKey || e.metaKey) && e.key === 'Enter') {
+ e.preventDefault();
+ if (generate.disabled) {
+ generate.scrollIntoView({block: 'center'});
+ return;
+ }
+ generate.click();
+ } }; dialog.addEventListener('keydown', escape);
dialog.addEventListener('cancel', e => { e.preventDefault(); closeDialog(dialog); });
dialog.onclose = () => { disposed = true; for (const f of cleanup) f(); stage.querySelector('video')?.pause(); dialog.remove(); if (current?.dialog === dialog) { current = null; viewChanged('nodes', node); } };
capabilityView = createCapabilityView({node, api, t, getState: () => ({ratio,
diff --git a/web/studio_chain.js b/web/studio_chain.js
index c3e8d72..7168c41 100644
--- a/web/studio_chain.js
+++ b/web/studio_chain.js
@@ -52,16 +52,16 @@ export function createStudioChain({api, node, onState = () => {}, onProgress = (
function clearPolls() { for (const id of timers) clearTimeout(id); timers.clear(); }
function refresh() { clearPolls(); return poller?.poll(); }
const active = () => submitting || activeStates.has(chain?.state) || chain?.output_state === 'joining';
- async function json(path, options) {
+ async function json(path, options, allowMissing = false) {
const response = await api.fetchApi(path, options);
- if (response.status === 404) return null;
- const value = await response.json();
+ if (response.status === 404 && allowMissing) return null;
+ const value = await response.json().catch(() => ({}));
if (!response.ok) throw Object.assign(new Error(value.error || 'chain_request_failed'), {code: value.code, status: response.status,
...(value.error_zh ? {said: [value.error, value.error_zh]} : {})});
return value;
}
function progress(message = {}, fresh = false) {
- if (!chain || disposed) return;
+ if (!chain || disposed || (!activeStates.has(chain.state) && chain.output_state !== 'joining')) return;
if (message.chain?.id && message.chain.id !== chain.id) return;
const position = chainPosition(chain, message);
if (position.index !== lastIndex) { lastMessage = {}; lastIndex = position.index; }
@@ -122,17 +122,48 @@ export function createStudioChain({api, node, onState = () => {}, onProgress = (
const version = epoch;
try {
const known = node.properties?.[CHAIN_PROPERTY]?.id;
- const reply = await json('/freevideo/chains');
+ const reply = await json('/freevideo/chains', undefined, true);
if (disposed || version !== epoch || chain) return;
const found = reply?.chains?.find(row => String(row.node) === String(node.id) && (known ? row.id === known
: activeStates.has(row.state) && row.client_id && row.client_id === api.clientId));
if (!found) return;
- const value = (await json(chainRoute(found.id)))?.chain;
+ const value = (await json(chainRoute(found.id), undefined, true))?.chain;
if (disposed || version !== epoch || chain || !value) return;
adopt(value);
if (node.freevideoProgress?.chain?.id === value.id) progress(node.freevideoProgress);
} catch {} // Recovery must never enqueue a request or block ordinary generation.
}
+ function acceptAction(value, restarted) {
+ epoch++; poller?.dispose(); clearPolls();
+ if (restarted) {
+ previous = {}; lastMessage = {}; lastIndex = -1; corrected = false; etaAt = 0;
+ delivered = errorShown = null;
+ }
+ deliver(value, restarted); if (active()) watch();
+ }
+ async function changeState(action, body) {
+ const id = chain.id, version = epoch;
+ try {
+ const value = (await json(chainRoute(id, action), post(body)))?.chain;
+ if (!value?.id) throw new Error('chain_missing');
+ if (version === epoch && !disposed) acceptAction(value, action === 'resume');
+ } catch (cause) {
+ // The action may have reached the server even if its reply failed.
+ // Read directly: a stopped chain has no active poller to refresh.
+ if (version === epoch && !disposed) {
+ try {
+ const latest = (await json(chainRoute(id), {cache: 'no-store'}))?.chain;
+ if (latest?.id === id && version === epoch && !disposed) {
+ const confirmed = action === 'cancel' ? ['cancelling', 'cancelled'].includes(latest.state)
+ : ['queued', 'running'].includes(latest.state) || (latest.state === 'done' && latest.output_state !== 'failed');
+ acceptAction(latest, action === 'resume' && confirmed);
+ if (confirmed) return;
+ }
+ } catch {} // Keep the last known state; the action still fails visibly.
+ }
+ throw Object.assign(new Error(`chain_${action}_failed`), {cause, action, status: cause.status});
+ }
+ }
recover();
return {
get active() { return active(); }, get state() { return chain; },
@@ -142,7 +173,7 @@ export function createStudioChain({api, node, onState = () => {}, onProgress = (
try {
const body = buildChainRequest(options, {node: node.id, prompt: snapshot.output,
extra_data: {extra_pnginfo: {workflow: snapshot.workflow || {}}}, ...(api.clientId ? {client_id: api.clientId} : {})});
- const value = (await json(chainRoute(), post(body)))?.chain;
+ const value = (await json(chainRoute(), post(body), true))?.chain;
if (!value) return null;
if (!value.id) throw new Error('chain_missing');
const inputs = snapshot.output[String(node.id)].inputs;
@@ -153,15 +184,11 @@ export function createStudioChain({api, node, onState = () => {}, onProgress = (
refresh,
async cancel() {
if (!chain) return;
- const id = chain.id, version = epoch;
- const value = (await json(chainRoute(id, 'cancel'), post({})))?.chain;
- if (version === epoch && !disposed && value) { epoch++; poller?.dispose(); clearPolls(); deliver(value); if (active()) watch(); }
+ await changeState('cancel', {});
},
async resume() {
if (!chain || active()) return;
- const id = chain.id, version = epoch;
- const value = (await json(chainRoute(id, 'resume'), post({client_id: api.clientId})))?.chain;
- if (version === epoch && !disposed && value) { epoch++; poller?.dispose(); clearPolls(); previous = {}; corrected = false; etaAt = 0; delivered = errorShown = null; deliver(value, true); if (active()) watch(); }
+ await changeState('resume', {client_id: api.clientId});
},
progress(message) { if (!chain || message.chain?.id !== chain.id) return false; progress(message);
if (message.result || ['complete', 'failed', 'cancelled'].includes(message.phase)) refresh(); return true; },