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.
Notify open ComfyUI workspaces about FreeVideo updates (#19)
Bowen Xuedf433ef11c02
diff --git a/__init__.py b/__init__.pyindex b64ed3d..0a79c53 100644--- a/__init__.py+++ b/__init__.py@@ -11,6 +11,8 @@ async def comfy_entrypoint():setup_routes()from .freevideo_engine.comfy_launcher_api import register as launcher_routeslauncher_routes()+ from .freevideo_engine.comfy_updates import register as update_routes+ update_routes()from .freevideo_engine.comfy_library import register as library_routeslibrary_routes()from .freevideo_engine.comfy_nodes import FreeVideoExtensiondiff --git a/freevideo_engine/comfy_updates.py b/freevideo_engine/comfy_updates.pynew file mode 100644index 0000000..dadf3b2--- /dev/null+++ b/freevideo_engine/comfy_updates.py@@ -0,0 +1,83 @@+"""Optional browser update notices; no installation or generation side effects."""+from datetime import datetime, timezone+import json+from pathlib import Path+import re+import threading+import time++from . import launcher_update+++def installed_build(package):+ """Use the loaded engine's release stamp, never the source fallback version."""+ package = Path(package)+ try:+ return launcher_update.build_identity(json.loads(+ (package / 'build-identity.json').read_text(encoding='utf-8')))+ except (OSError, ValueError, TypeError):+ pass+ # EXEs built before browser notices only stamped this timestamp file.+ try:+ version = (package / 'build-version.txt').read_text(encoding='utf-8').strip()+ if not re.fullmatch(r'\d{4}\.\d{1,2}\.\d{1,2}\.\d{1,6}', version):+ return None+ year, month, day, clock = map(int, version.split('.'))+ stamp = datetime(year, month, day, clock // 10000, clock // 100 % 100,+ clock % 100, tzinfo=timezone.utc)+ return dict(version=version, built_at=int(stamp.timestamp()), revision=None)+ except (OSError, ValueError):+ return None+++class UpdateStatus:+ """One bounded background check per server, shared by all browser tabs."""+ def __init__(self, current):+ self.current = current+ self.state = dict(status='idle' if current else 'source',+ current_version=current['version'] if current else None,+ available=None)+ self.next_check = 0+ self.lock = threading.Lock()+ self.thread = None++ def snapshot(self):+ with self.lock:+ if (self.current and time.monotonic() >= self.next_check+ and not (self.thread and self.thread.is_alive())):+ self.state['status'] = 'checking'+ self.thread = threading.Thread(target=self._check, daemon=True,+ name='FreeVideo-update-check')+ self.thread.start()+ return dict(self.state)++ def _check(self):+ try:+ candidate = launcher_update.latest_release()+ newer = (candidate['built_at'] > self.current['built_at']+ and candidate['revision'] != self.current['revision'])+ available = {key: candidate[key] for key in ('version', 'revision', 'built_at')} if newer else None+ with self.lock:+ self.state.update(status='available' if available else 'current', available=available)+ self.next_check = time.monotonic() + 15 * 60+ except Exception:+ # Offline/rate-limited checks must not interrupt a running server.+ # Keep a previously verified notice and retry without a user action.+ with self.lock:+ self.state['status'] = 'unavailable'+ self.next_check = time.monotonic() + 60+++def register():+ from aiohttp import web+ from server import PromptServer+ server = PromptServer.instance+ if server is None or getattr(server, '_freevideo_updates', None):+ return+ # Capture once: replacing files on disk cannot update a running engine.+ status = UpdateStatus(installed_build(Path(__file__).parent))+ server._freevideo_updates = status++ @server.routes.get('/freevideo/updates')+ async def updates(request):+ return web.json_response(status.snapshot(), headers={'Cache-Control': 'no-store'})diff --git a/freevideo_engine/launcher_update.py b/freevideo_engine/launcher_update.pyindex 6d5dff3..735ab4f 100644--- a/freevideo_engine/launcher_update.py+++ b/freevideo_engine/launcher_update.py@@ -120,8 +120,8 @@ def _json(url, token, *, binary=False, limit=2**20):return json.loads(b''.join(_bytes(response, limit)))-def check(current, token=''):- build_identity(current)+def latest_release(token=''):+ """Read and validate the published build without downloading an executable."""release = _json(API + '/releases/tags/' + CHANNEL, token)if not isinstance(release, dict) or release.get('draft') or release.get('tag_name') != CHANNEL:raise ValueError('No published Windows update is available')@@ -132,6 +132,12 @@ def check(current, token=''):candidate = manifest(_json(API + '/releases/assets/' + str(metadata['id']), token, binary=True, limit=65536))if candidate['asset']['id'] != executable.get('id') or candidate['asset']['bytes'] != executable.get('size'):raise ValueError('A new release is being published; check again shortly')+ return candidate+++def check(current, token=''):+ build_identity(current)+ candidate = latest_release(token)return candidate if newer(candidate, current) else Nonediff --git a/pyproject.toml b/pyproject.tomlindex 801729b..5efe342 100644--- a/pyproject.toml+++ b/pyproject.toml@@ -31,4 +31,4 @@ freevideo = "freevideo_engine.cli:main"include = ["freevideo_engine*"][tool.setuptools.package-data]-freevideo_engine = ["build-version.txt", "dependencies.json", "model_files.json", "model_shares.json", "prepared_models.json", "bootstrap_versions.json", "uv_downloads.json", "torch_downloads.json", "test_prompts.json", "windows_process_host.ps1", "windows_bootstrap.ps1", "assets/*.png", "assets/*.ico", "launcher/*.qml", "launcher/licenses/*.txt", "licenses/*.txt"]+freevideo_engine = ["build-version.txt", "build-identity.json", "dependencies.json", "model_files.json", "model_shares.json", "prepared_models.json", "bootstrap_versions.json", "uv_downloads.json", "torch_downloads.json", "test_prompts.json", "windows_process_host.ps1", "windows_bootstrap.ps1", "assets/*.png", "assets/*.ico", "launcher/*.qml", "launcher/licenses/*.txt", "licenses/*.txt"]diff --git a/scripts/build_windows.py b/scripts/build_windows.pyindex 7f9058b..b70db16 100644--- a/scripts/build_windows.py+++ b/scripts/build_windows.py@@ -35,6 +35,7 @@ def stamp_source(staged, identity):version = identity['version']stamp = staged / 'freevideo_engine/build-version.txt'stamp.write_text(version, encoding='utf-8')+ (stamp.parent / 'build-identity.json').write_text(json.dumps(identity), encoding='utf-8')project = staged / 'pyproject.toml'project.write_text(re.sub(r'^version = "[^"]+"', 'version = "' + version + '"',project.read_text(encoding='utf-8'), count=1, flags=re.M), encoding='utf-8')@@ -122,6 +123,7 @@ def main():'--paths', str(ROOT), '--add-data', str(staged) + os.pathsep + 'engine-source','--add-data', str(build_file) + os.pathsep + '.','--add-data', str(stamp) + os.pathsep + 'freevideo_engine',+ '--add-data', str(stamp.parent / 'build-identity.json') + os.pathsep + 'freevideo_engine','--add-data', str(notices) + os.pathsep + 'freevideo_engine/launcher/licenses/bundled',*bundle_data_args(ROOT),'--hidden-import', 'psutil',diff --git a/scripts/test_freevideo_entry.mjs b/scripts/test_freevideo_entry.mjsindex df41ef1..5e7d690 100644--- a/scripts/test_freevideo_entry.mjs+++ b/scripts/test_freevideo_entry.mjs@@ -19,7 +19,7 @@ class Element {test('main browser entry registers both views and preserves node hooks', async () => {const extensions = [], opened = [], installed = [], events = new EventTarget();- let refreshed = 0, compatibilityChecks = 0;+ let refreshed = 0, compatibilityChecks = 0, updateChecks = 0;const app = {registerExtension(extension) { extensions.push(extension); },graph: {extra: {freevideo_studio: true}, _nodes: [], getNodeById() {}},@@ -35,6 +35,7 @@ test('main browser entry registers both views and preserves node hooks', async (createGenerationProgress: () => ({element: new Element('progress'), report: new Element('report'), updateReport() {}, update() {}, hide() {}, dispose() {}}),createProgressConnection: () => ({start() {}, refresh() {}, reset() {}}),notifyCompatibility: async () => { compatibilityChecks++; },+ startUpdateChecks: () => { updateChecks++; },installNavigation: callback => installed.push(callback),refreshNavigation: () => refreshed++, preferredView: () => null,attachReferencePicker() {}, referenceItems: () => [], syncReferencePrompt() {},@@ -58,6 +59,7 @@ test('main browser entry registers both views and preserves node hooks', async (.replace("import { createGenerationProgress } from './generation_progress.js';", 'const {createGenerationProgress} = globalThis.__freevideoEntryTest;').replace("import { createProgressConnection } from './progress_connection.js';", 'const {createProgressConnection} = globalThis.__freevideoEntryTest;').replace("import { notifyCompatibility } from './compatibility.js';", 'const {notifyCompatibility} = globalThis.__freevideoEntryTest;')+ .replace("import { startUpdateChecks } from './updates.js';", 'const {startUpdateChecks} = globalThis.__freevideoEntryTest;').replace("import { attachReferencePicker, referenceItems, syncReferencePrompt } from './prompt_references.js';", 'const {attachReferencePicker,referenceItems,syncReferencePrompt} = globalThis.__freevideoEntryTest;').replace("import { installNavigation, refreshNavigation, preferredView } from './view_navigation.js';", 'const {installNavigation,refreshNavigation,preferredView} = globalThis.__freevideoEntryTest;');await import('data:text/javascript;base64,' + Buffer.from(source).toString('base64'));@@ -66,6 +68,7 @@ test('main browser entry registers both views and preserves node hooks', async (await extension.setup();assert.equal(installed.length, 1, 'the Create / Nodes navigation must be installed');assert.equal(compatibilityChecks, 1);+ assert.equal(updateChecks, 1);class GenerateNode {constructor() {diff --git a/web/freevideo.js b/web/freevideo.jsindex e3e2239..bf2958f 100644--- a/web/freevideo.js+++ b/web/freevideo.js@@ -5,6 +5,7 @@ import { openStudio, loraPanel, loraWarning, promptGuide } from "./studio.js";import { createGenerationProgress } from './generation_progress.js';import { createProgressConnection } from './progress_connection.js';import { notifyCompatibility } from './compatibility.js';+import { startUpdateChecks } from './updates.js';import { installNavigation, refreshNavigation, preferredView } from './view_navigation.js';import { attachReferencePicker, referenceItems, syncReferencePrompt } from './prompt_references.js';@@ -300,7 +301,7 @@ const progressConnection = createProgressConnection(api, message => {app.registerExtension({name: "FreeVideo.UnifiedMedia",beforeConfigureGraph() { configuringGraph = true; },- async setup() { progressConnection.start(); installNavigation(openStudio); await notifyCompatibility(); },+ async setup() { progressConnection.start(); installNavigation(openStudio); startUpdateChecks(); await notifyCompatibility(); },async beforeRegisterNodeDef(nodeType, nodeData) {if (nodeData.name === 'FreeVideoReference') {const connected = nodeType.prototype.onConnectionsChange;diff --git a/web/studio.js b/web/studio.jsindex e581385..c14efde 100644--- a/web/studio.js+++ b/web/studio.js@@ -5,6 +5,7 @@ import { openSetup } from './setup.js';import { wordmark } from './branding.js';import { createGenerationProgress } from './generation_progress.js';import { viewSwitch, viewChanged } from './view_navigation.js';+import { createUpdateNotice } from './updates.js';import { createPreviewScene } from './preview_scene.js?v=20260929-swell';import { animateDetails, closeDialog } from './motion.js';import { openLibrary, latestVideo } from './library.js';@@ -137,6 +138,8 @@ export function openStudio(node) {header.append(brand, navigation, tools);const body = el('div', null, 'fv-body'), controls = el('div', null, 'fv-controls'), output = el('div', null, 'fv-preview-column');dialog.append(header, body); body.append(controls, output);+ const updateNotice = createUpdateNotice(cn);+ output.append(updateNotice.element); cleanup.push(updateNotice.dispose);const section = (label, parent = controls) => { const wrap = el('section', null, 'fv-section'); wrap.append(el('div', label, 'fv-label')); parent.append(wrap); return wrap; };const field = (name, input) => { const label = el('label', null, 'fv-field'); label.append(el('span', name), input); return label; };const expand = label => { const d = el('details', null, 'fv-section'); d.append(el('summary', label, 'fv-section-title')); const content = el('div', null, 'fv-expand'); d.append(content); controls.append(d); cleanup.push(animateDetails(d)); return [d, content]; };diff --git a/web/updates.css b/web/updates.cssnew file mode 100644index 0000000..a3e6644--- /dev/null+++ b/web/updates.css@@ -0,0 +1,6 @@+.fv-update-notice{box-sizing:border-box;display:flex;align-items:center;gap:10px;flex-wrap:wrap;padding:10px 12px;border:1px solid var(--fv-border);border-radius:var(--fv-r-sm,8px);background:var(--fv-card);color:var(--fv-ink);font:12px/1.5 var(--fv-font);animation:fv-panel-enter .25s ease}+.fv-update-notice[hidden]{display:none!important}.fv-update-notice>span{flex:1;min-width:160px;overflow-wrap:anywhere}+.fv-update-notice a,.fv-update-notice button,.fv-studio .fv-update-notice a,.fv-studio .fv-update-notice button{min-height:30px;padding:4px 8px;border:0;border-radius:6px;font:inherit;background:transparent;white-space:nowrap;cursor:pointer;text-decoration:none;color:var(--fv-accent)}+.fv-update-notice button,.fv-studio .fv-update-notice button{color:var(--fv-muted)}.fv-update-notice a:hover,.fv-update-notice button:hover{background:var(--fv-hover)}+.fv-update-notice :focus-visible{outline:2px solid var(--fv-accent);outline-offset:2px}.fv-view-navigation>.fv-update-notice{margin-top:8px;max-width:560px}+@media(prefers-reduced-motion:reduce){.fv-update-notice{animation:none}}diff --git a/web/updates.js b/web/updates.jsnew file mode 100644index 0000000..d607d57--- /dev/null+++ b/web/updates.js@@ -0,0 +1,59 @@+import { api } from '../../scripts/api.js';++const releasePage = 'https://github.com/FlashML-org/FreeVideo/releases/tag/windows-preview';+const storageKey = 'freevideo.dismissed-update';+const listeners = new Set();+let candidate, dismissed, started = false, pending = false, lastCheck = -Infinity;+try { dismissed = sessionStorage.getItem(storageKey); } catch { /* Session memory still works. */ }+const identity = value => value ? `${value.revision}:${value.built_at}` : '';+const publish = () => { for (const render of listeners) render(); };++export async function checkUpdates() {+ if (pending || Date.now() - lastCheck < 1500 || document.hidden) return;+ pending = true; lastCheck = Date.now();+ try {+ const response = await api.fetchApi('/freevideo/updates', {cache: 'no-store', signal: AbortSignal.timeout(10000)});+ if (!response.ok) return;+ const value = await response.json();+ candidate = value.available || null;+ publish();+ // The server returns immediately while its initial network check runs.+ if (value.status === 'checking') setTimeout(checkUpdates, 2000);+ } catch { /* Offline checks do not affect generation; the next poll retries. */ }+ finally { pending = false; }+}++export function startUpdateChecks() {+ if (started) return;+ started = true;+ const css = document.createElement('link'); css.rel = 'stylesheet';+ css.href = new URL('./updates.css', import.meta.url).href; document.head.append(css);+ void checkUpdates();+ setInterval(checkUpdates, 60000);+ document.addEventListener('visibilitychange', () => { if (!document.hidden) void checkUpdates(); });+}++export function createUpdateNotice(cn) {+ const t = (en, zh) => cn ? zh : en;+ const element = document.createElement('aside'); element.className = 'fv-update-notice';+ element.hidden = true; element.setAttribute('role', 'status');+ const label = document.createElement('span');+ const link = document.createElement('a'); link.href = releasePage;+ link.target = '_blank'; link.rel = 'noopener noreferrer';+ link.textContent = t('Download update', '下载新版');+ link.title = t('After your task finishes, open the new FreeVideo.exe to update.', '当前任务完成后,打开新版 FreeVideo.exe 更新。');+ const later = document.createElement('button'); later.type = 'button';+ later.textContent = t('Later', '稍后');+ later.onclick = () => {+ dismissed = identity(candidate);+ try { sessionStorage.setItem(storageKey, dismissed); } catch {}+ publish();+ };+ element.append(label, link, later);+ const render = () => {+ element.hidden = !candidate || dismissed === identity(candidate);+ label.textContent = candidate ? t('FreeVideo update available', 'FreeVideo 有新版本') + ' · ' + candidate.version : '';+ };+ listeners.add(render); render();+ return {element, dispose: () => listeners.delete(render)};+}diff --git a/web/view_navigation.js b/web/view_navigation.jsindex fb70faa..d425e4e 100644--- a/web/view_navigation.js+++ b/web/view_navigation.js@@ -1,6 +1,7 @@import { app } from '../../scripts/app.js';import { openSetup } from './setup.js';import { wordmark } from './branding.js';+import { createUpdateNotice } from './updates.js';const languageOverride = typeof location !== 'undefined'? new URLSearchParams(location.search).get('freevideo_lang') : null;@@ -88,5 +89,6 @@ export function installNavigation(openStudio) {};guide.append(text, dismiss); toolbar.append(guide);}+ toolbar.append(createUpdateNotice(cn).element);document.body.append(toolbar); refreshNavigation();}