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.
Phone access reasons in formal wording
Bowen Xue0afd06f5260c
diff --git a/freevideo_engine/comfy_launcher_runtime.py b/freevideo_engine/comfy_launcher_runtime.pyindex 7feb804..367c312 100644--- a/freevideo_engine/comfy_launcher_runtime.py+++ b/freevideo_engine/comfy_launcher_runtime.py@@ -424,6 +424,13 @@ def bind_check(hostname, port):raise+def lan_error(reason, message):+ """The launcher's message, with the lan_page reason code the phone panel shows."""+ error = ValueError(message)+ error.lan_reason = reason+ return error++def address(hostname, port):return 'http://%s:%d' % ('[%s]' % hostname if ':' in hostname else hostname, port)@@ -1263,6 +1270,18 @@ class Controller:self._configure_access(dict(lan_access=(self.selection or {}).get('lan_access')), connect=True)def _start_access_proxy(self):+ from . import lan_page+ engine = self.selection['engine']+ try:+ self._open_access_proxy()+ except Exception as error:+ # The page's phone panel shows why instead of waiting; a launcher closing is not a failure.+ if not (self._closed or self.cancelled.is_set()):+ lan_page.note_failure(engine, getattr(error, 'lan_reason', 'failed'))+ raise+ lan_page.forget_failure(engine)++ def _open_access_proxy(self):from .comfy_service import TOKEN, check_proxy, folder, start_proxy, tokenself.selection = selected = dict(self.selection, lan_access=False)self.state = dict(self.state, selection=dict(selected))@@ -1270,7 +1289,7 @@ class Controller:info = server_info(selected['url'])hosts = (info.get('listen') or '').split(',')if not hosts or not all(loopback_host(host) for host in hosts):- raise ValueError('The ComfyUI already running is open to the network directly. After its jobs finish, restart it on 127.0.0.1, then turn on LAN access.')+ raise lan_error('comfy_on_network', 'The ComfyUI already running is open to the network directly. After its jobs finish, restart it on 127.0.0.1, then turn on LAN access.')configuration = tuple(selected[k] for k in ('root', 'engine', 'source', 'python', 'url'))if (self.access_configuration != configuration orself.access_proxy is not None and self.access_proxy.poll() is not None):@@ -1281,7 +1300,7 @@ class Controller:port = (urlsplit(selected['url']).port or 80) + 1candidate = next_free_address(address('0.0.0.0', port - 1)) if port <= 65535 else Noneif candidate is None:- raise ValueError('The ports for LAN access are in use or reserved by the system. Choose another ComfyUI port.')+ raise lan_error('ports_in_use', 'The ports for LAN access are in use or reserved by the system. Choose another ComfyUI port.')port = urlsplit(candidate).portself.selection = selected = dict(selected, lan_port=port)self.state = dict(self.state, selection=dict(selected))diff --git a/freevideo_engine/lan_page.py b/freevideo_engine/lan_page.pyindex ecdae41..34e763b 100644--- a/freevideo_engine/lan_page.py+++ b/freevideo_engine/lan_page.py@@ -1,10 +1,46 @@"""Local page LAN settings, independent of the HTTP server."""+import json+from pathlib import Pathimport socketimport timefrom . import lan_auth, lan_passwordfrom .launcher_settings import Store, default_language+# Why the launcher could not open phone access, for the page's phone panel.+# The launcher writes it when opening fails; turning the switch from the page clears it.+FAILURE_FILE = 'lan-failure.json'+REASONS = ('ports_in_use', 'comfy_on_network', 'failed')+# An older note belongs to an earlier session; the panel then just shows the switch off.+FAILURE_SECONDS = 600+++def note_failure(engine, reason):+ try:+ path = Path(engine) / 'launcher' / FAILURE_FILE+ path.parent.mkdir(parents=True, exist_ok=True)+ path.write_text(json.dumps(dict(reason=reason if reason in REASONS else 'failed')), encoding='utf-8')+ except OSError:+ pass+++def forget_failure(engine):+ try:+ (Path(engine) / 'launcher' / FAILURE_FILE).unlink()+ except OSError:+ pass+++def failure(engine):+ path = Path(engine) / 'launcher' / FAILURE_FILE+ try:+ if not 0 <= time.time() - path.stat().st_mtime <= FAILURE_SECONDS:+ return ''+ reason = json.loads(path.read_text(encoding='utf-8')).get('reason')+ except (OSError, ValueError, AttributeError):+ return ''+ return reason if reason in REASONS else ''+class LanUnavailable(RuntimeError):"""The launcher has not recorded an installation on this computer."""@@ -35,9 +71,12 @@ def read(engine):from .comfy_launcher_runtime import lan_access_linkslinks = lan_access_links(engine, port, password_set=password_set)link = links[0] if links else ''- return dict(available=installation is not None, enabled=enabled, starting=flag and not enabled,+ # Listening without a network address, or the launcher's last attempt failed.+ reason = ('no_address' if enabled and not link else '' if enabled or installation is None+ else failure(engine))+ return dict(available=installation is not None, enabled=enabled, starting=flag and not enabled and not reason,link=link, password_set=password_set, devices=len(auth.devices(time.time())),- min_length=lan_password.MIN_LENGTH)+ min_length=lan_password.MIN_LENGTH, reason=reason)def apply(engine, body):@@ -68,6 +107,8 @@ def apply(engine, body):else:lan_password.set_password(engine, body['password'])if 'enabled' in body:+ # A new attempt (or turning it off) replaces the last failure.+ forget_failure(engine)installation = dict(installation, lan_access=body['enabled'])# access.lan_enabled() checks the current top-level permission copies.saved['lan_access'] = body['enabled']diff --git a/web/lan_access.css b/web/lan_access.cssindex 3732cce..f1ab158 100644--- a/web/lan_access.css+++ b/web/lan_access.css@@ -6,3 +6,4 @@.fv-lan-tip{position:fixed;z-index:1001;background:var(--fv-raised);color:var(--fv-ink);font-size:var(--fv-micro);padding:6px 10px;border:1px solid var(--fv-border);border-radius:6px;white-space:nowrap;pointer-events:none;box-shadow:0 4px 12px #0004}/* The extra tool must not take the readable project name out of a narrow editor. */@media(max-width:680px){.fv-studio.fv-editor .fv-header[data-fit~=wrap][data-fit~=compact] .fv-wordmark{display:none}}+.fv-lan-problem{display:flex;align-items:baseline;justify-content:space-between;gap:8px;margin:12px 0 0}.fv-lan-reason{font-size:var(--fv-body);color:var(--fv-muted);line-height:1.65;margin:0}.fv-lan.fv-lan .fv-lan-retry{flex:none;color:var(--fv-accent);background:none;height:32px;padding:0 4px}diff --git a/web/lan_access.js b/web/lan_access.jsindex a3b2607..aecb349 100644--- a/web/lan_access.js+++ b/web/lan_access.js@@ -40,8 +40,20 @@ export function createLanAccess(t, api) {const error = el('p', 'fv-lan-error', t('Please try again.', '请重试。')); error.hidden = true; error.setAttribute('role', 'status');content.append(qr, el('p', 'fv-lan-scan', t('Connect to the same Wi-Fi, then scan', '手机连同一个 Wi-Fi 后扫码')), copy, passwordRow, form);const tip = el('span', 'fv-lan-tip', label); tip.setAttribute('role', 'tooltip'); tip.hidden = true;- panel.append(head, starting, content, error); element.append(trigger, panel, tip);- let state = {enabled: false, link: '', password_set: false}, seen = false, disposed = false, writing = false, desired = null, reading = false, timer = null, copied = null, drawn = '';+ // Why phone access is not open: the launcher's reason, or no link after openWait.+ const problem = el('div', 'fv-lan-problem'), problemText = el('p', 'fv-lan-reason'), retry = button('fv-lan-retry', t('Try again', '重试'), () => open());+ problem.append(problemText, retry); problem.hidden = true; problemText.setAttribute('role', 'status');+ const reasons = {+ ports_in_use: t('The ports for phone access are in use or reserved by the system.', '手机连接所需的端口已被占用或被系统保留。'),+ comfy_on_network: t('This ComfyUI is already open to the network. Restart it on this computer only, then try again.', 'ComfyUI 已直接对网络开放。请改为仅在本机打开后重试。'),+ no_address: t('No LAN address found. Connect to Wi-Fi or a wired network first.', '未找到局域网地址,请先连接 Wi-Fi 或有线网络。'),+ failed: t('Phone access could not be opened.', '手机连接无法打开。'),+ late: t('Phone access has not opened yet. Make sure the FreeVideo launcher is running.', '手机连接尚未打开。请确认 FreeVideo 启动器正在运行。'),+ unavailable: t('Phone access needs FreeVideo started from its launcher on this computer.', '手机连接需要通过本机的 FreeVideo 启动器启动。'),+ };+ const openWait = 30000;+ panel.append(head, starting, problem, content, error); element.append(trigger, panel, tip);+ let state = {enabled: false, link: '', password_set: false}, seen = false, disposed = false, writing = false, desired = null, reading = false, timer = null, copied = null, drawn = '', since = 0;try { seen = localStorage.getItem(seenKey) === '1'; } catch {}const windows = /Win/i.test(globalThis.navigator?.platform || globalThis.navigator?.userAgent || '');function fail() { error.hidden = false; }@@ -51,9 +63,14 @@ export function createLanAccess(t, api) {panel.style.left = `${Math.max(8, Math.min(box.right - 264, window.innerWidth - 272))}px`;}function render() {- const on = desired ?? state.enabled, pending = on && (!state.enabled || !state.link);- toggleButton.setAttribute('aria-checked', String(!!on)); toggleButton.disabled = writing || desired != null;- content.hidden = !on || pending; starting.hidden = !pending;+ // No launcher installation: the switch cannot work from this page, so say why instead of "Please try again".+ const unavailable = state.available === false, reason = unavailable ? 'unavailable' : reasons[state.reason] ? state.reason : '', on = desired ?? (state.enabled || state.starting);+ const linked = !!(state.enabled && state.link), waiting = on && !linked && !reason;+ if (!waiting) since = 0; else if (!since) since = Date.now();+ const late = waiting && Date.now() - since >= openWait, pending = waiting && !late, shown = reason || (late ? 'late' : '');+ toggleButton.setAttribute('aria-checked', String(!!on)); toggleButton.disabled = writing || desired != null || unavailable;+ content.hidden = !on || !linked; starting.hidden = !pending;+ problem.hidden = !shown; problemText.textContent = shown ? reasons[shown] : ''; retry.disabled = writing; retry.hidden = unavailable;starting.replaceChildren();if (pending && windows) {if (t('en', 'zh') === 'zh') { starting.append(document.createTextNode('Windows 会弹出确认框,'), el('br'), el('span', '', '请勾选“专用网络”,再点“允许访问”。')); }@@ -61,7 +78,7 @@ export function createLanAccess(t, api) {} else if (pending) starting.textContent = t('Opening…', '正在打开…');passwordState.textContent = state.password_set ? t('Password: on', '密码:已设置') : t('Password: not set', '密码:未设置');set.textContent = state.password_set ? t('Change', '修改') : t('Set', '设置');- if (on && !pending && state.link !== drawn) { try { drawQr(qr, state.link); drawn = state.link; } catch { fail(); } }+ if (!content.hidden && state.link !== drawn) { try { drawQr(qr, state.link); drawn = state.link; } catch { fail(); } }position();}async function read() {@@ -69,7 +86,7 @@ export function createLanAccess(t, api) {try {const response = await agentGet(api, '/freevideo/lan', {signal: AbortSignal.timeout(10000)});if (!response.ok) throw new Error(); const value = await response.json(); if (disposed || writing) return;- state = value; if (desired === state.enabled && (!desired || state.link)) desired = null;+ state = value; if (state.reason || desired === state.enabled && (!desired || state.link)) desired = null;error.hidden = true; render();} catch { if (!disposed) fail(); }finally { reading = false; if (!disposed && !panel.hidden) timer = setTimeout(read, document.hidden ? 10000 : 2000); }@@ -88,13 +105,16 @@ export function createLanAccess(t, api) {async function write(body) {writing = true; error.hidden = true; render();try {- const response = await agentPost(api, '/freevideo/lan', body); if (!response.ok) throw new Error();+ const response = await agentPost(api, '/freevideo/lan', body);+ if (response.status === 409 && (await response.json().catch(() => null))?.error?.code === 'lan_unavailable') { if (!disposed) state = {...state, available: false}; return false; }+ if (!response.ok) throw new Error();const value = await response.json(); if (disposed) return false;if (typeof value.enabled === 'boolean') state = {...state, ...value}; return true;} catch { if (!disposed) fail(); return false; }finally { writing = false; if (!disposed) render(); }}- async function changeEnabled() { desired = !state.enabled; if (!await write({enabled: desired})) desired = null; render(); read(); }+ async function changeEnabled() { await open(!(state.enabled || state.starting)); }+ async function open(enabled = true) { since = 0; desired = enabled; if (!await write({enabled})) desired = null; render(); read(); }form.onsubmit = async event => { event.preventDefault(); if (save.disabled || writing) return; save.disabled = true; if (await write({password: password.value})) { password.value = ''; form.hidden = true; set.focus(); read(); } else password.oninput(); };function observe(value) { if (!seen && longGeneration(value)) dot.hidden = false; }const opened = () => { seen = true; dot.hidden = true; };