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.

Show prompt save/load failures and tell an unchecked source video from a missing one

Bowen Xuebabd27781d34
diff --git a/web/prompt_draft.js b/web/prompt_draft.js
index f28e583..7490ef7 100644
--- a/web/prompt_draft.js
+++ b/web/prompt_draft.js
@@ -16,6 +16,15 @@ const equal = (a, b) => JSON.stringify(a) === JSON.stringify(b);
const watched = new WeakMap(), dirty = new Set();
const historyObservers = new WeakSet(), restoringHistory = new WeakSet();
let timer = null, pending = null, inFlight = null, sending = null;
+// What the page could not do with the draft file, so the prompt box can say so and retry.
+const trouble = {save: false, restore: false}, troubleWatchers = new Set();
+function setTrouble(key, value) {
+ if (trouble[key] === value) return;
+ trouble[key] = value;
+ for (const watcher of troubleWatchers) watcher({...trouble});
+}
+export function promptDraftTrouble() { return {...trouble}; }
+export function watchPromptDraftTrouble(watcher) { troubleWatchers.add(watcher); return () => troubleWatchers.delete(watcher); }
try { pending = JSON.parse(globalThis.sessionStorage?.getItem(OUTBOX) || 'null'); } catch {}
function retain() {
@@ -177,14 +186,16 @@ export async function savePromptDraft(api, keepalive = false) {
try {
const reply = await api.fetchApi(FILE, {cache: 'no-store', keepalive});
if (!reply.ok && reply.status !== 404) throw new Error('draft_read');
- const current = reply.ok ? await reply.json() : null;
+ // A damaged file can never be merged into; the next save replaces it.
+ const current = reply.ok ? await reply.json().catch(() => null) : null;
const saved = await api.fetchApi(FILE + '?overwrite=true', {method: 'POST',
headers: {'Content-Type': 'application/json'}, body: JSON.stringify(combine(current, patch)), keepalive});
if (!saved.ok) throw new Error('draft_write');
- sending = null; retain(); return true;
+ sending = null; retain(); setTrouble('save', false); return true;
} catch {
const newer = pending; pending = patch; sending = null;
if (newer) addPatch(newer); else retain();
+ setTrouble('save', true);
return false;
}
};
@@ -195,11 +206,13 @@ export async function savePromptDraft(api, keepalive = false) {
export async function restorePromptDraft(api, workflow, project = null) {
// A refreshed page retries its own unsaved patch before launcher restoration.
if (pending || inFlight || dirty.size) await savePromptDraft(api);
- let draft;
+ let draft, unread = false;
try {
const reply = await api.fetchApi(FILE, {cache: 'no-store'});
- if (reply.ok) draft = await reply.json();
- } catch { /* Keep the workflow and any local edits if the server is offline. */ }
+ // Only a missing file means there is no earlier prompt.
+ if (reply.ok) draft = await reply.json(); else unread = reply.status !== 404;
+ } catch { unread = true; /* Keep the workflow and any local edits if the server is offline. */ }
+ setTrouble('restore', unread);
// A failed retry remains authoritative over the older remote copy. Retain
// the outbox until a later explicit save succeeds, including across reloads.
const local = pending || sending ? mergePatches(sending, pending) : null;
diff --git a/web/prompt_references.css b/web/prompt_references.css
index 377bba7..faddfc1 100644
--- a/web/prompt_references.css
+++ b/web/prompt_references.css
@@ -1,6 +1,8 @@
.fv-prompt-editor{position:relative;display:flex;flex-direction:column;height:170px;min-height:148px;max-height:340px;resize:vertical;overflow:hidden;background:var(--fv-card)}
.fv-studio .fv-prompt-editor textarea{flex:1;min-height:0;height:0;max-height:none;resize:none;padding-bottom:8px;outline:none}
.fv-prompt-tools{display:flex;flex:none;align-items:center;justify-content:flex-end;height:36px;padding-right:9px}
+.fv-studio .fv-prompt-draft-note{min-height:27px;height:27px;margin:0 auto 0 9px;padding:0 9px;border:0;background:transparent;color:var(--fv-warning);font-size:12px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
+.fv-studio .fv-prompt-draft-note[hidden]{display:none}
.fv-studio .fv-reference-trigger{min-height:27px;height:27px;width:30px;padding:0;font-size:17px;border:0;background:var(--fv-raised);color:var(--fv-muted)}
@media(min-height:960px) and (min-width:681px){.fv-prompt-editor{height:clamp(170px,24dvh,340px)}}
.fv-reference-picker{box-sizing:border-box;position:fixed;inset:auto;margin:0;padding:6px;border:1px solid var(--fv-border,#3a414c);border-radius:14px;background:var(--fv-card,#1a202a);color:var(--fv-ink,#eee);box-shadow:0 14px 42px #0006;font:13px/1.4 var(--fv-font,system-ui);z-index:10000;max-height:280px;overflow:hidden;animation:fv-reference-appear .12s ease-out}
diff --git a/web/result_actions.js b/web/result_actions.js
index 2a22572..cb15dd7 100644
--- a/web/result_actions.js
+++ b/web/result_actions.js
@@ -1,7 +1,7 @@
import { api } from '../../scripts/api.js';
import { outputDownloadURL } from './output_download.js';
import { shareButton } from './share.js';
-import { canExtend, extendText, extendSourceExists } from './studio_extend.js';
+import { canExtend, extendText, extendSourceProblem, extendSourceState } from './studio_extend.js';
import { issueButton } from './issue_button.js';
const css = document.createElement('link');
@@ -74,7 +74,7 @@ export function secondPassAction(t, run) {
try { await run(); label.textContent = button.title = t('Queued', '已加入队列'); }
catch {
button.disabled = false;
- label.textContent = button.title = t('Second pass did not start · Retry', '二采没有开始 · 重试');
+ label.textContent = button.title = t('Second pass did not start · retry', '二采没有开始 · 重试');
problem = issueButton(t, () => ({where: ['Second pass', '二采'], message: label.textContent}));
button.after(problem);
} finally { button.removeAttribute('aria-busy'); }
@@ -152,20 +152,21 @@ export function resultActions(record, t, {diagnostic = null, secondPass = null,
problem = issueButton(t, () => ({where: ['Continue video', '延长视频'], message: label.textContent}));
button.after(problem);
};
- const available = exists => {
- label.textContent = exists ? extendText(t, 'action') : t('Video unavailable · retry', '视频不可用 · 重试');
+ // Only a video the server says is gone keeps the issue button; a check that could not finish just retries.
+ const available = state => {
+ label.textContent = state === 'ok' ? extendText(t, 'action') : `${extendSourceProblem(t, state)} · ${t('retry', '重试')}`;
button.title = '';
- if (exists) problem?.remove(); else fault();
+ if (state === 'missing') fault(); else problem?.remove();
+ return state === 'ok';
};
- extendSourceExists(api, record).then(available);
+ extendSourceState(api, record).then(available);
button.onclick = async () => {
if (button.disabled) return;
problem?.remove();
button.disabled = true;
button.title = t('Checking video…', '正在检查视频…');
try {
- const exists = await extendSourceExists(api, record); available(exists);
- if (!exists) return;
+ if (!available(await extendSourceState(api, record))) return;
if (await extend(record) === null) throw new Error(t('Could not open the editor. Try again.', '无法打开剪辑,请重试。'));
} catch (error) {
label.textContent = error.message || t('Could not open the editor. Try again.', '无法打开剪辑,请重试。');
diff --git a/web/studio.js b/web/studio.js
index 8b94c62..71a57c3 100644
--- a/web/studio.js
+++ b/web/studio.js
@@ -34,7 +34,7 @@ import { continuationUpscale, createSamplingEffort, effortFor, effortsFrom, pass
import { resultActions, previewBadge, icon, actionsUnavailable } from './result_actions.js';
import { createPromptEnhancer } from './prompt_enhance.js';
import { createRequestAssets, enabledLoras, referenceFiles } from './request_assets.js';
-import { rememberPromptDraft, trackPromptDraft } from './prompt_draft.js';
+import { promptDraftTrouble, rememberPromptDraft, restorePromptDraft, savePromptDraft, trackPromptDraft, watchPromptDraftTrouble } from './prompt_draft.js';
import { canvasDimensions, imageSizeSelection } from './studio_size.js';
import { createCapabilityView } from './capability_view.js';
import { openEditorView } from './editor_loader.js';
@@ -45,7 +45,7 @@ import { createStudioLength, savedSeconds } from './studio_length.js?v=20261011-
import { firstFrameRow } from './first_frame_row.js';
import { createStudioChain, chainPosition, chainParts, chainSplit, composePartText, readChainResult, sumPartEstimates, singleRunSnapshot } from './studio_chain.js?v=20261019-words';
import { waitingText } from './chain_support.js';
-import { createExtendState, extendText, extendSourceExists, readExtendRecord, extendSnapshot, mountExtendThumbnail, videoUnavailableText } from './studio_extend.js';
+import { createExtendState, extendText, extendSourceProblem, extendSourceState, readExtendRecord, extendSnapshot, mountExtendThumbnail, videoUnavailableText } from './studio_extend.js';
const languageOverride = typeof location !== 'undefined'
? new URLSearchParams(location.search).get('freevideo_lang') : null;
@@ -614,7 +614,9 @@ export function showNodes(node, dialog = null) {
const studioQueues = new WeakMap();
export async function extendVideo(record, node = current?.node || app.graph?._nodes?.find(row => row.type === 'FreeVideoGenerate')) {
- if (!node || !await extendSourceExists(api, record)) throw new Error(extendText(t, 'unavailable'));
+ if (!node) throw new Error(extendText(t, 'unavailable'));
+ const state = await extendSourceState(api, record);
+ if (state !== 'ok') throw new Error(extendSourceProblem(t, state));
return openStudio(node, {extendFrom: await readExtendRecord(api, record)});
}
@@ -725,7 +727,28 @@ export function openStudio(node, {extendFrom = null} = {}) {
mention.setAttribute('aria-label', t('Reference media (@)', '引用素材(@)'));
mention.title = mention.getAttribute('aria-label');
mention.disabled = prompt.disabled; mention.onpointerdown = e => e.preventDefault();
- const promptTools = el('div', null, 'fv-prompt-tools'); promptTools.append(mention); promptEditor.append(promptTools);
+ // The prompt file could not be written, or the last prompt could not be read at launch.
+ const draftNote = button('', async () => {
+ draftNote.disabled = true;
+ draftNote.textContent = promptDraftTrouble().save ? t('Saving…', '正在保存…') : t('Loading…', '正在读取…');
+ try {
+ if (promptDraftTrouble().save) await savePromptDraft(api);
+ else {
+ // Read again into the open project; edits not yet saved still win over the file.
+ const current = app.graph.serialize(), target = app.extensionManager?.workflow?.activeWorkflow;
+ const restored = await restorePromptDraft(api, structuredClone(current), target?.path || '__existing__');
+ if (JSON.stringify(restored) !== JSON.stringify(current)) await app.loadGraphData(restored, true, true, target || 'FreeVideo');
+ }
+ } catch { /* The note stays with its retry. */ }
+ draftNote.disabled = false; showDraftTrouble(promptDraftTrouble());
+ }, 'fv-prompt-draft-note');
+ const showDraftTrouble = ({save, restore}) => {
+ if (draftNote.disabled) return;
+ draftNote.hidden = !save && !restore;
+ draftNote.textContent = save ? t('Prompt not saved · retry', '描述没能保存 · 重试') : t('Last prompt not loaded · retry', '上次的描述没能读取 · 重试');
+ };
+ showDraftTrouble(promptDraftTrouble()); cleanup.push(watchPromptDraftTrouble(showDraftTrouble));
+ const promptTools = el('div', null, 'fv-prompt-tools'); promptTools.append(draftNote, mention); promptEditor.append(promptTools);
cleanup.push(() => references.dispose());
const terms = attachTermSuggest(prompt, {t, host: dialog, suppressed: () => !!mentionAt(prompt.value, prompt.selectionStart, prompt.selectionEnd, handleNames(castChoices()))});
cleanup.push(() => terms.dispose());
@@ -1709,7 +1732,8 @@ export function openStudio(node, {extendFrom = null} = {}) {
if (lengthPlan?.count > 1 && chosenMode !== 'single') { status.textContent = t('Videos made in parts cannot use batch or loop.', '分段视频不能批量或循环生成。'); return; }
const lengthOptions = lengthControl.options();
const source = extension.source;
- if (source && !await extendSourceExists(api, source)) throw new Error(extendText(t, 'unavailable'));
+ const sourceState = source ? await extendSourceState(api, source) : 'ok';
+ if (sourceState !== 'ok') throw new Error(extendSourceProblem(t, sourceState));
if (source && lengthPlan?.count > 1) lengthOptions.after = {work: source.video};
// Only serialization briefly locks the editor. Network submission
// and all GPU execution leave the next draft fully editable.
diff --git a/web/studio_extend.js b/web/studio_extend.js
index fa8971b..08de9da 100644
--- a/web/studio_extend.js
+++ b/web/studio_extend.js
@@ -6,6 +6,7 @@ export const EXTEND_TEXT = Object.freeze({
remove: ['Remove', '移除'],
prompt: ['Prompt', '描述'],
unavailable: ['Video unavailable', '视频不可用'],
+ unchecked: ['Could not check the video', '没能检查视频'],
});
export const extendText = (t, key) => t(...EXTEND_TEXT[key]);
@@ -24,21 +25,32 @@ export function extendVideoURL(record) {
subfolder: split < 0 ? '' : record.video.slice(0, split), type: 'output'});
}
-export async function extendSourceExists(api, record) {
- if (!canExtend(record)) return false;
- const url = extendVideoURL(record);
+// 'ok'; 'missing' only when the server answered 404 or 410; 'unknown' when offline, timed out or any other answer.
+export async function extendSourceState(api, record) {
+ if (!canExtend(record)) return 'missing';
+ const url = extendVideoURL(record), gone = status => status === 404 || status === 410;
+ let missing = false;
try {
- if ((await api.fetchApi(url, {method: 'HEAD', signal: AbortSignal.timeout(10000)})).ok) return true;
+ const head = await api.fetchApi(url, {method: 'HEAD', signal: AbortSignal.timeout(10000)});
+ if (head.ok) return 'ok';
+ missing = gone(head.status);
} catch { /* HEAD can fail even when the browser can still read the video. */ }
try {
const response = await api.fetchApi(url, {method: 'GET', headers: {Range: 'bytes=0-0'},
signal: AbortSignal.timeout(10000)});
// A server may ignore Range. Release its stream without downloading the video.
await response.body?.cancel().catch(() => {});
- return response.ok;
- } catch { return false; }
+ return response.ok ? 'ok' : gone(response.status) ? 'missing' : 'unknown';
+ } catch { return missing ? 'missing' : 'unknown'; }
}
+export async function extendSourceExists(api, record) {
+ return await extendSourceState(api, record) === 'ok';
+}
+
+// What a continuation says when its source video is not 'ok'.
+export const extendSourceProblem = (t, state) => extendText(t, state === 'missing' ? 'unavailable' : 'unchecked');
+
export const videoUnavailableText = t => t('This video cannot be opened. If you moved the file, refresh the page.',
'视频打不开,如果移动过文件,请刷新页面。');