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.
Install, offline package and portable launcher fixes from the bug hunt
Bowen Xue586e063058b9
diff --git a/freevideo_engine/comfy_launcher.py b/freevideo_engine/comfy_launcher.pyindex 406ec78..d64c422 100644--- a/freevideo_engine/comfy_launcher.py+++ b/freevideo_engine/comfy_launcher.py@@ -20,6 +20,7 @@ from .setup_progress import number, progress_textFIREWALL_HINT = ('If Windows asks about the firewall the first time, choose Allow.', 'Windows 首次询问防火墙权限时,请选择“允许”。')+BROWSER_STARTING = ('Still starting. Your browser will open automatically when ready.', '还在启动,好了会自动打开')class Launcher:@@ -392,7 +393,11 @@ class Launcher:self.refresh()def update_engine(self):- if self.controller.busy or not self.launch_selection:+ if not self.launch_selection:+ from .launcher_copy import ACTION_COPY+ self.status.set(self.t(*ACTION_COPY['installation_missing']))+ return+ if self.controller.busy:returnself.remember_installation(self.launch_selection)self.wizard_step = 2@@ -484,6 +489,13 @@ class Launcher:def open_browser(self):if self.controller.state.get('status') != 'open':+ # The controller can change state before the next GUI refresh.+ # A click on the previous enabled button still gets a response.+ if self.controller.busy and self.controller.state.get('action') in ('launch', 'connect', 'install'):+ self.browser_attempted = False+ self.status.set(self.t(*BROWSER_STARTING))+ else:+ self.refresh()returnfrom .windows_ux import open_browserself.browser_attempted = True@@ -539,7 +551,7 @@ class Launcher:('Start ComfyUI and open the FreeVideo workflow.', '启动 ComfyUI 并打开 FreeVideo 工作流。')]if self.wizard_step == 3:descriptions[3] = {- 'running': ('Starting ComfyUI…', '正在启动 ComfyUI…'),+ 'running': BROWSER_STARTING,'open': ('ComfyUI is ready. Open FreeVideo in your browser.', 'ComfyUI 已就绪,可在浏览器中打开 FreeVideo。'),'failed': ('Could not start. Details below.', '启动未完成,原因见下方。'),'restart-required': ('Restart your running ComfyUI, then connect again.', '请重启正在运行的 ComfyUI,然后重新连接。'),@@ -602,7 +614,7 @@ class Launcher:self.browser_controls.pack(fill='x', pady=(16, 0))else:self.browser_controls.pack_forget()- self.browser_button.state(['disabled'] if busy else ['!disabled'])+ self.browser_button.state(['disabled'] if busy or state != 'open' else ['!disabled'])self.shortcut_button.state(['!disabled'] if not busy and self.controller.selection andself.controller.selection.get('ready') else ['disabled'])shortcut = row.get('shortcut', {})diff --git a/freevideo_engine/comfy_updates.py b/freevideo_engine/comfy_updates.pyindex cfcad47..c3d477b 100644--- a/freevideo_engine/comfy_updates.py+++ b/freevideo_engine/comfy_updates.py@@ -37,7 +37,7 @@ def launcher_view(status):"""The parts of a launcher status a page may show; None without a launcher."""if not isinstance(status, dict):return None- view = {k: status.get(k) for k in ('version', 'phase', 'status', 'progress', 'candidate', 'engine', 'error', 'manual', 'channel', 'track')}+ view = {k: status.get(k) for k in ('version', 'phase', 'model', 'status', 'progress', 'candidate', 'engine', 'error', 'manual', 'channel', 'track')}view['phase'] = str(view['phase'] or '')return viewdiff --git a/freevideo_engine/launcher/Main.qml b/freevideo_engine/launcher/Main.qmlindex f8b5c64..d568106 100644--- a/freevideo_engine/launcher/Main.qml+++ b/freevideo_engine/launcher/Main.qml@@ -248,7 +248,7 @@ ApplicationWindow {Accessible.role: Accessible.Graphic; Accessible.name: "FreeVideo"}FNav { objectName: "navLauncher"; glyph: "play"; text: t("Launch", "启动"); Layout.fillWidth: true; selected: s.page === "launcher"; enabled: s.selected && !s.busy; onClicked: backend.action("launcher", false) }- FNav { objectName: "navSetup"; glyph: "download"; text: t("Installation", "安装"); Layout.fillWidth: true; selected: s.page !== "launcher"; enabled: !s.busy && !s.portable; onClicked: backend.action("setup", false) }+ FNav { objectName: "navSetup"; glyph: "download"; text: t("Installation", "安装"); Layout.fillWidth: true; selected: s.page !== "launcher"; enabled: s.can_manage && !s.portable; onClicked: backend.action("setup", false) }Item { Layout.fillHeight: true }Rectangle {Layout.fillWidth: true; Layout.bottomMargin: 8; implicitHeight: busyBody.implicitHeight + 28@@ -374,8 +374,11 @@ ApplicationWindow {ColumnLayout {Layout.fillWidth: true; spacing: 8; Layout.bottomMargin: shortWindow ? 0 : 10FText { objectName: "pageHeading"; horizontalAlignment: Text.AlignHCenter; text: s.page === "launcher" ? t("Your workspace", "你的工作空间") : s.page === "comfy" ? t("Set up FreeVideo", "安装 FreeVideo") : s.page === "models" ? t("Set up your models", "准备模型") : s.status === "review" ? t("Ready to install", "确认安装") : s.busy ? t("Setting things up", "正在准备 FreeVideo") : t("Continue your setup", "继续安装"); font.pixelSize: win.compact ? 26 : theme.hero; font.weight: Font.DemiBold; font.letterSpacing: -0.6; Layout.fillWidth: true }+ FText { objectName: "actionNotice"; visible: !!s.action_notice; text: s.action_notice || ""; color: theme.muted; Layout.fillWidth: true; horizontalAlignment: Text.AlignHCenter }}+ FText { objectName: "operationBusyReason"; visible: !s.can_manage && !s.action_notice; text: s.busy_reason; color: theme.muted; Layout.fillWidth: true; horizontalAlignment: Text.AlignHCenter }+Rectangle {id: failureCardobjectName: "failureCard"; visible: !!s.error; Layout.fillWidth: true@@ -471,8 +474,8 @@ ApplicationWindow {FText { text: s.form.new_comfy ? t("Install location", "安装位置") : t("ComfyUI folder", "ComfyUI 目录"); font.weight: Font.DemiBold }RowLayout {Layout.fillWidth: true; spacing: 8- FField { objectName: "installationPath"; Layout.fillWidth: true; value: s.form.new_comfy ? s.form.destination : s.form.comfy; placeholderText: t("Choose a folder", "选择文件夹"); enabled: !s.busy; onEditingFinished: backend.edit(s.form.new_comfy ? "destination" : "comfy", text) }- FButton { text: t("Browse…", "浏览…"); implicitHeight: theme.height + 4; onClicked: backend.browse(s.form.new_comfy ? "destination" : "comfy") }+ FField { objectName: "installationPath"; Layout.fillWidth: true; value: s.form.new_comfy ? s.form.destination : s.form.comfy; placeholderText: t("Choose a folder", "选择文件夹"); enabled: s.can_manage; onEditingFinished: backend.edit(s.form.new_comfy ? "destination" : "comfy", text) }+ FButton { objectName: "installationBrowse"; text: t("Browse…", "浏览…"); enabled: s.can_manage; implicitHeight: theme.height + 4; onClicked: backend.browse(s.form.new_comfy ? "destination" : "comfy") }}FText { visible: !s.form.new_comfy; text: t("Uses your existing Python when available. A separate environment loads only FreeVideo.", "优先使用已有 Python;独立环境仅加载 FreeVideo。"); color: theme.muted; font.pixelSize: theme.micro; Layout.fillWidth: true }RowLayout {@@ -483,7 +486,7 @@ ApplicationWindow {Layout.alignment: Qt.AlignBaseline; Layout.rightMargin: s.zh ? -(8 + Math.round(font.pixelSize / 2) - 2) : -4 }FText { objectName: "installDiskText"; text: diskLine(); color: disk && (disk.problem || disk.short) ? theme.danger : theme.muted; font.pixelSize: theme.micro + 1; Layout.fillWidth: true; Layout.alignment: Qt.AlignBaseline }// The label's right edge lines up with Browse; the hover fill reaches into the card's padding.- FButton { objectName: "changeDisk"; visible: s.form.new_comfy && diskChoices.length > 0; enabled: !s.busy; flat: true; implicitHeight: theme.heightSm; font.pixelSize: theme.micro + 1+ FButton { objectName: "changeDisk"; visible: s.form.new_comfy && diskChoices.length > 0; enabled: s.can_manage; flat: true; implicitHeight: theme.heightSm; font.pixelSize: theme.micro + 1leftPadding: 10; rightPadding: 10; Layout.rightMargin: -10; Layout.alignment: Qt.AlignBaselinetext: t("Choose another disk", "换一块硬盘"); onClicked: diskDialogOpen = true }}@@ -535,7 +538,7 @@ ApplicationWindow {FText { text: t("Reuse models · optional", "复用已有模型(可选)"); font.weight: Font.DemiBold; Layout.fillWidth: true }FText { text: t("Add folders to find matching models in their subfolders.", "添加总目录,自动匹配子文件夹中的模型。"); color: theme.muted; font.pixelSize: theme.micro; Layout.fillWidth: true }}- FButton { objectName: "addModelFolder"; text: t("Add folder", "添加目录"); enabled: !s.busy; onClicked: backend.browse("model_dirs") }+ FButton { objectName: "addModelFolder"; text: t("Add folder", "添加目录"); enabled: s.can_manage; onClicked: backend.browse("model_dirs") }}Repeater {model: s.form.model_dirs@@ -805,7 +808,7 @@ ApplicationWindow {objectName: "modelUpgradeButton"; primary: truevisible: upgrade.status === "available" || upgrade.status === "releasable"|| (upgrade.status === "failed" && (upgrade.step === "download" || upgrade.step === "release" || (upgrade.step === "switch" && upgrade.kept)))- enabled: !s.busy && !upgrade.busy+ enabled: s.can_manage && !upgrade.busytext: upgrade.status === "failed" ? t("Try again", "重试") : upgrade.status === "releasable" ? t("Remove…", "删除…") : t("Download & upgrade", "下载并升级")onClicked: upgrade.status === "releasable" ? releaseConfirm = true : backend.upgradeModel()}@@ -923,8 +926,8 @@ ApplicationWindow {FButton { objectName: "launchInstalledButton"; visible: updateFirst && s.retry_kind !== "launch"; flat: true; text: t("Launch current version", "启动当前版本"); onClicked: backend.action("primary", accepted) }FButton {objectName: "primaryButton"; primary: !s.repair_offered && !(s.retry_kind === "launch" && engineUpdate.visible) && !manualFailure; implicitWidth: Math.max(160, contentItem.implicitWidth+40); implicitHeight: theme.heightLg- text: s.busy ? t("Working…", "正在处理…") : primaryText()- enabled: !s.busy && !(s.page === "launcher" && s.needs_consent && !accepted)+ text: s.setup_pending ? s.setup_wait_text : s.busy ? t("Working…", "正在处理…") : primaryText()+ enabled: !s.busy && !s.setup_pending && !(s.page === "launcher" && s.needs_consent && !accepted)&& !(s.page === "progress" && s.status === "review" && !s.retry_kind && (!accepted || !!s.error))onClicked: { if (s.retry_kind) { backend.action("retry", accepted); return } if (needsRuntime) { backend.browseRuntimePackage(); return } if (needsPackages) { backend.browsePackages(); return } if (updateFirst) { backend.update(""); return } backend.action(s.page === "launcher" && s.status === "open" ? "browser" : "primary", accepted); if (s.busy && s.page === "launcher") terminalOpen = true }}@@ -1009,6 +1012,8 @@ ApplicationWindow {ScrollBar.horizontal.policy: ScrollBar.AlwaysOffColumnLayout {width: settingsScroll.availableWidth; spacing: 18+ FText { objectName: "settingsActionNotice"; visible: !!s.action_notice && s.action_notice !== s.busy_reason; text: s.action_notice || ""; color: theme.muted; Layout.fillWidth: true }+ FText { objectName: "settingsBusyReason"; visible: (!s.can_manage || !s.can_cleanup) && (!s.action_notice || s.action_notice === s.busy_reason); text: s.busy_reason; color: theme.muted; Layout.fillWidth: true }ColumnLayout {Layout.fillWidth: true; visible: settingsTab === "downloads"; spacing: 20FGroup {@@ -1083,7 +1088,7 @@ ApplicationWindow {FText { text: t("Updates", "更新"); Layout.fillWidth: true }FText { text: t("Settings are kept in Documents across updates.", "设置保存在文档目录中,更新后保留。"); color: theme.muted; font.pixelSize: theme.micro; Layout.fillWidth: true }}- FButton { objectName: "checkUpdatesButton"; text: t("Check now", "检查更新"); implicitHeight: theme.heightSm; font.pixelSize: theme.micro + 1; onClicked: { manualUpdate = true; backend.checkUpdates("") } }+ FButton { objectName: "checkUpdatesButton"; text: s.update.check_requested ? s.update.check_text : t("Check now", "检查更新"); implicitHeight: theme.heightSm; font.pixelSize: theme.micro + 1; onClicked: { manualUpdate = true; backend.checkUpdates("") } }}FButton { text: t("Version & release notes", "版本与更新说明") + " · " + releaseVersion(currentRelease); flat: true; Layout.fillWidth: true; onClicked: releaseNotesOpen = true }}@@ -1176,7 +1181,7 @@ ApplicationWindow {objectName: "modelStorageButton"; visible: upgrade.status === "available" || upgrade.status === "releasable"text: upgrade.status === "releasable" ? t("Remove…", "删除…") : t("Upgrade", "升级")implicitHeight: theme.heightSm; font.pixelSize: theme.micro + 1- enabled: !s.busy && !upgrade.busy+ enabled: s.can_manage && !upgrade.busyonClicked: upgrade.status === "releasable" ? releaseConfirm = true : backend.upgradeModel()}}@@ -1198,7 +1203,7 @@ ApplicationWindow {FButton { text: t("Qt notices & licenses ↗", "Qt 组件与许可证 ↗"); flat: true; implicitHeight: theme.heightSm; leftPadding: 4; font.pixelSize: theme.micro; onClicked: backend.link("https://doc.qt.io/qt-6/licenses-used-in-qt.html") }}ColumnLayout {- Layout.fillWidth: true; visible: settingsTab === "advanced"; spacing: 20; enabled: !s.busy+ Layout.fillWidth: true; visible: settingsTab === "advanced"; spacing: 20; enabled: s.can_manageFGroup {Layout.fillWidth: true; title: t("ComfyUI address", "ComfyUI 地址")FField { objectName: "listenAddress"; Layout.fillWidth: true; value: s.form.url; enabled: !s.form.lan_access; onEditingFinished: backend.edit("url", text) }@@ -1208,7 +1213,7 @@ ApplicationWindow {FGroup {Layout.fillWidth: true; title: t("Folders · optional", "目录 · 可选"); enabled: !s.portableFText { text: t("Engine folder", "引擎目录"); font.pixelSize: theme.micro; color: theme.muted }- RowLayout { Layout.fillWidth: true; spacing: 8; FField { Layout.fillWidth: true; value: s.form.engine; placeholderText: t("Automatic", "自动选择"); onEditingFinished: backend.edit("engine", text) } FButton { text: t("Browse…", "浏览…"); implicitHeight: theme.height + 4; onClicked: backend.browse("engine") } }+ RowLayout { Layout.fillWidth: true; spacing: 8; FField { Layout.fillWidth: true; value: s.form.engine; placeholderText: t("Automatic", "自动选择"); onEditingFinished: backend.edit("engine", text) } FButton { objectName: "engineBrowse"; text: t("Browse…", "浏览…"); enabled: s.can_manage; implicitHeight: theme.height + 4; onClicked: backend.browse("engine") } }FText { text: t("ComfyUI Python", "ComfyUI Python"); font.pixelSize: theme.micro; color: theme.muted; Layout.topMargin: 4 }FField { Layout.fillWidth: true; value: s.form.python; placeholderText: t("Path to python.exe", "python.exe 的路径"); onEditingFinished: backend.edit("python", text) }}@@ -1301,7 +1306,7 @@ ApplicationWindow {}RowLayout {Layout.fillWidth: true; Layout.topMargin: 4; spacing: 8- FButton { text: t("Choose a folder…", "选择文件夹…"); flat: true; onClicked: { diskDialogOpen = false; backend.browse("destination") } }+ FButton { text: t("Choose a folder…", "选择文件夹…"); enabled: s.can_manage; flat: true; onClicked: { diskDialogOpen = false; backend.browse("destination") } }Item { Layout.fillWidth: true }FButton { text: t("Cancel", "取消"); onClicked: diskDialogOpen = false }}@@ -1402,10 +1407,12 @@ ApplicationWindow {FText { objectName: "downloadListNotice"; visible: text.length > 0; text: s.download_list.notice; color: theme.success; Layout.fillWidth: true; font.pixelSize: theme.micro + 1 }FButton { objectName: "openDownloadFolder"; text: downloads.copy.open_folder; flat: true; implicitHeight: theme.heightSm; font.pixelSize: theme.micro + 1; onClicked: backend.openDownloadFolder() }}+ FText { objectName: "downloadActionNotice"; visible: !!s.action_notice && s.action_notice !== s.busy_reason; text: s.action_notice || ""; color: theme.muted; Layout.fillWidth: true }FText { objectName: "downloadListError"; visible: text.length > 0; text: s.download_list.error; color: theme.danger; Layout.fillWidth: true; wrapMode: Text.WordWrap; font.pixelSize: theme.micro + 1 }FText { objectName: "downloadListRawError"; visible: s.error.length > 0 && !s.download_list.inspection_error; text: s.error; color: theme.danger; Layout.fillWidth: true; maximumLineCount: 2; elide: Text.ElideRight; font.pixelSize: theme.micro }}}+ FText { objectName: "downloadBusyReason"; visible: !s.can_manage && (!s.action_notice || s.action_notice === s.busy_reason); text: s.busy_reason; color: theme.muted; Layout.fillWidth: true }RowLayout {objectName: "downloadListActions"; Layout.fillWidth: true; Layout.minimumWidth: 0; spacing: 8// The actions share what the Close button leaves, so a long label wraps instead of leaving the dialog.@@ -1414,7 +1421,7 @@ ApplicationWindow {FButton { id: closeDownloadList; text: downloads.copy.close; flat: true; onClicked: modelInfoOpen = false }Item { Layout.fillWidth: true }FButton { id: checkDownloadList; objectName: "checkDownloadList"; Layout.maximumWidth: parent.actionWidth; visible: !downloads.available || s.download_list.needs_check; text: downloads.copy.check; enabled: !s.busy; onClicked: backend.prepareDownloadList() }- FButton { objectName: "useDownloadedFolder"; Layout.maximumWidth: parent.actionWidth; text: downloads.copy.use_folder; enabled: !s.busy; onClicked: backend.useDownloadedFolder() }+ FButton { objectName: "useDownloadedFolder"; Layout.maximumWidth: parent.actionWidth; text: downloads.copy.use_folder; enabled: s.can_manage; onClicked: backend.useDownloadedFolder() }FButton { objectName: "exportDownloadList"; Layout.maximumWidth: parent.actionWidth; text: downloads.copy.export; primary: true; enabled: downloads.available && !s.busy; onClicked: backend.exportDownloadList() }}}@@ -1496,6 +1503,7 @@ ApplicationWindow {ColumnLayout {id: updateContents; width: updateScroll.availableWidthspacing: 14+ FText { objectName: "updateActionNotice"; visible: !!s.action_notice; text: s.action_notice || ""; color: theme.muted; Layout.fillWidth: true }FText { text: s.update.candidate ? t("Update available", "有可用更新") : s.update.engine ? t("Engine update", "引擎更新") : t("Updates", "更新"); font.pixelSize: theme.section + 2; font.weight: Font.DemiBold }FText { objectName: "updateDialogText"; text: s.update.phase === "waiting" ? t("A video is still generating. FreeVideo restarts and updates as soon as it finishes.", "还有视频正在生成,完成后会自动重启并更新。") : s.update.status === "ready" && s.update.candidate ? t("Downloaded. Restart to finish; models and settings are kept.", "下载完成,重启即可完成更新,模型和设置都会保留。") : s.update.candidate ? t("FreeVideo ", "FreeVideo ") + releaseVersion(s.update.candidate) + t(" is available (current ", " 已发布(当前 ") + releaseVersion(currentRelease) + t("). Updating keeps your models and settings. FreeVideo restarts after the download; running videos finish first.", ")。更新会保留模型和设置,下载完成后自动重启;正在生成的视频会先完成。") : s.update.engine ? t("This launcher already includes engine ", "启动器已带有新版引擎 ") + releaseVersion(currentRelease) + t(" (installed: ", "(已安装 ") + engineVersion + (s.status === "open" ? t("). Updating takes about a minute, restarts ComfyUI once and keeps your models and settings.", ")。更新约需 1 分钟,会重启一次 ComfyUI,模型和设置都会保留。") : t("). Updating takes about a minute, then FreeVideo starts; models and settings are kept.", ")。更新约需 1 分钟,完成后自动启动,模型和设置都会保留。")) : s.update.status === "current" ? t("You're up to date.", "已是最新版本。") : s.update.status === "development" ? t("Running from source. Update with Git.", "当前从源码运行,请通过 Git 更新。") : s.update.status === "error" ? t("Could not check for updates.", "暂时无法检查更新。") : t("Checking the latest release…", "正在检查最新版本…"); color: theme.muted; Layout.fillWidth: true }FMeter { Layout.fillWidth: true; visible: s.update.status === "downloading"; active: true; fraction: s.update.progress && s.update.progress.total ? s.update.progress.done/s.update.progress.total : -1 }diff --git a/freevideo_engine/launcher_copy.py b/freevideo_engine/launcher_copy.pyindex 3cccaa0..9b8f301 100644--- a/freevideo_engine/launcher_copy.py+++ b/freevideo_engine/launcher_copy.py@@ -6,6 +6,23 @@ from .model_repair import PROGRESS as MODEL_REPAIR_PROGRESSfrom .model_status import NAMES+ACTION_COPY = {+ 'download_missing': ('The download folder no longer exists. Export the list again.',+ '下载目录已不存在,请重新导出清单'),+ 'installation_missing': ('There is no installation information yet. Complete installation first.',+ '还没有安装信息,请先完成安装'),+ 'checking_update': ('Checking for updates. Please wait.', '正在检查更新,请稍候'),+ 'busy': ('The background task is busy. You can do this when it finishes.',+ '后台正在忙,完成后可以操作'),+ 'import_queued': ('Saved. Importing will start when the current task finishes.',+ '已记下,处理完当前任务后自动导入'),+ 'setup_queued': ('Models are being prepared in the background. Setup will continue when they are ready.',+ '后台正在准备模型,好了会接着继续'),+ 'update_queued': ('Another task is running. Updating will start when it finishes.',+ '正在做别的事,完成后会自动更新'),+}++SOURCES = {'auto': ('Automatic', '自动选择'), 'official': ('Hugging Face', 'Hugging Face'),'hf-mirror': ('HF Mirror', 'HF 镜像'), 'modelscope': ('ModelScope', '魔搭'),diff --git a/freevideo_engine/launcher_session.py b/freevideo_engine/launcher_session.pyindex 98a5669..c6201eb 100644--- a/freevideo_engine/launcher_session.py+++ b/freevideo_engine/launcher_session.py@@ -15,7 +15,7 @@ from .comfy_launcher_runtime import Controller, layout, local_url, loopback_url,from .desktop_runtime import launcher_root, materialize_sourcefrom .download_settings import Probe, read as download_preferences, speed_textfrom .launcher_settings import Store, default_language-from .launcher_copy import size_text+from .launcher_copy import ACTION_COPY, size_textfrom .launcher_terminal import Tailfrom .model_status import FAMILIES, NAMESfrom .model_guidance import (package_instructions, video_instructions, runtime_packages_supported, download_view,@@ -66,6 +66,12 @@ class Session:# The source whose earlier copies were removed once ComfyUI ran it.old_versions_retired = Nonearchives_busy = False+ action_notice = ''+ pending_update = None+ pending_check = None+ upgrade = image_installer = None+ model_switch = None+ language = 'en'def __init__(self, source=None, *, controller=None, store=None, updater=None, smoke=False):from .offline_packages import Importer@@ -106,6 +112,11 @@ class Session:self.token = ''self.error = ''self.notice = ''+ self.action_notice = ''+ self.pending_update = None+ self.pending_action = None+ self.pending_imports = []+ self.pending_check = Noneself.report = dict(status='idle', path='', error='')self.compatibility = dict(available=False, level=0, automatic=False)self.probe = Probe()@@ -176,6 +187,19 @@ class Session:def t(self, en, zh):return zh if self.language.startswith('zh') else en+ def task_busy(self):+ """Work that must finish before another installation operation starts."""+ return bool(self.controller.busy or self.importer.busy or self.cleaner.busy+ or self.archives_busy or self.closing or self.upgrade and self.upgrade.active+ or self.model_switch or self.engine_updating+ or self.image_installer and self.image_installer.busy)++ def can_manage(self):+ return not (self.task_busy() or self.update_intent)++ def explain_busy(self):+ self.action_notice = 'busy'+def engine_root(self):if self.form['engine'].strip():return Path(plain(resolved(Path(self.form['engine']).expanduser())))@@ -213,8 +237,8 @@ class Session:self.persist()def edit(self, key, value):- if self.image_installer and self.image_installer.busy and key in (- 'engine', 'comfy', 'destination', 'new_comfy', 'offline_runtime'):+ if key in ('engine', 'comfy', 'destination', 'new_comfy', 'offline_runtime') and not self.can_manage():+ self.explain_busy()returnif key == 'language':self.language = str(value); self.persist(); return@@ -223,7 +247,10 @@ class Session:raise ValueError(self.t('Pause installation before changing the token.', '请先暂停安装,再修改 Token。'))from .hf_auth import validateself.token = validate(str(value)); return- if key not in self.form or self.controller.busy or self.importer.busy or self.cleaner.busy or self.archives_busy:+ if key not in self.form:+ return+ if self.controller.busy or self.importer.busy or self.cleaner.busy or self.archives_busy:+ self.explain_busy()returnif key in ('separate', 'repair', 'new_comfy', 'sampling_caches', 'lan_access', 'image_model'):value = bool(value)@@ -275,7 +302,10 @@ class Session:def use_disk(self, folder):"""Move a new installation to another disk, then show the location page to confirm it."""- if not self.form['new_comfy'] or self.controller.busy or self.importer.busy or self.cleaner.busy or self.archives_busy:+ if not self.can_manage():+ self.explain_busy()+ return+ if not self.form['new_comfy']:returnself.edit('destination', str(folder))self.page = 'comfy'@@ -327,7 +357,8 @@ class Session:self.download_error = self.t(*DOWNLOAD_COPY['error_' + error.key]).format(reason=reason)def use_downloaded_folder(self, folder):- if self.controller.busy or self.importer.busy or self.cleaner.busy:+ if not self.can_manage():+ self.explain_busy()returnself.add_folder(folder)# Even a folder already in the list may have received new downloads.@@ -367,10 +398,12 @@ class Session:def import_packages(self, paths):- if self.controller.busy or self.importer.busy or self.cleaner.busy or self.archives_busy:- returnif not paths:return+ if self.task_busy() or self.update_intent or self.pending_update:+ self.pending_imports = list(dict.fromkeys(self.pending_imports + list(paths)))+ self.action_notice = 'import_queued'+ returnself.repair_request = Nonedestination = (Path(plain(resolved(Path(self.form['destination']).expanduser()))) if self.form['new_comfy']else self.engine_root().parent)@@ -423,7 +456,17 @@ class Session:self.page = 'launcher'self.persist()- def action(self, name, accepted=False):+ def action(self, name, accepted=False, *, retry=None):+ if name == 'stop':+ self.pending_action = None+ if self.action_notice == 'setup_queued':+ self.action_notice = ''+ setup_action = (name == 'primary' and self.page != 'launcher'+ or name == 'retry' and self.retry_kind() != 'launch')+ if setup_action and self.task_busy():+ self.pending_action = (name, accepted, self.page, self.retry_kind() if name == 'retry' else None)+ self.action_notice = 'setup_queued'+ returnif self.cleaner.busy or self.archives_busy:returnif self.image_installer and self.image_installer.busy and (@@ -466,7 +509,7 @@ class Session:self.started = time.monotonic()returnif name == 'retry':- kind = self.retry_kind()+ kind = retry or self.retry_kind()if kind == 'import':_, paths, destination = self.import_retryself.importer.start(paths, destination)@@ -604,10 +647,8 @@ class Session:return ''def cleanup_downloads(self, remove=False):- if self.image_installer and self.image_installer.busy:- return- if (self.controller.busy or self.importer.busy or self.archives_busy or self.closing or self.upgrade.active or self.model_switch- or self.update_intent or self.engine_updating or self.updater and self.updater.busy):+ if not self.can_manage() or self.updater and self.updater.busy:+ self.explain_busy()returnself.cleaner.start(self.engine_root(), remove=remove)@@ -721,7 +762,8 @@ class Session:the previous model. An old model left after the switch is released heretoo, when the user asks."""- if self.image_installer and self.image_installer.busy:+ if not self.can_manage():+ self.explain_busy()returnstate = self.upgrade.stateif (state.get('status') not in ('available', 'failed', 'releasable') or self.upgrade.busy or self.model_switch@@ -990,6 +1032,10 @@ class Session:return ''def dismiss_update(self):+ self.pending_update = None+ self.bridge_pending = False+ if self.action_notice == 'update_queued':+ self.action_notice = ''key = self.update_key()if key:self.update_snoozed = dict(self.update_snoozed, **{key: time.monotonic() + SNOOZE_SECONDS})@@ -1005,20 +1051,31 @@ class Session:self.update_snoozed = {k: v for k, v in self.update_snoozed.items() if k != key}def check_update(self, token=''):- if self.updater and not self.updater.busy:- if token.strip():- self.updater.token = token.strip()- self.update_checked = time.monotonic()- self.updater.run('check')+ if not self.updater:+ return+ self.action_notice = 'checking_update'+ if self.updater.busy:+ self.pending_check = token+ return+ self.pending_check = None+ if token.strip():+ self.updater.token = token.strip()+ self.update_checked = time.monotonic()+ self.updater.run('check')def update(self, token='', source='launcher'):"""One explicit update: the newest launcher if one is known, otherwisethe engine bundled with this launcher. Downloading, waiting for runningComfyUI jobs and restarting continue from tick()."""- if self.controller.busy or self.importer.busy or self.cleaner.busy or self.archives_busy or self.closing:- if source == 'browser':- self.bridge_pending = True+ if self.engine_updating or self.update_restarting:return+ if self.task_busy() or self.updater and self.updater.busy:+ self.pending_update = (token, source)+ self.action_notice = 'update_queued'+ return+ self.pending_update = None+ if self.action_notice == 'update_queued':+ self.action_notice = ''self.repair_request = Noneif self.updater and token.strip():self.updater.token = token.strip()@@ -1095,7 +1152,7 @@ class Session:return Falsedef _restart_when_idle(self):- if self.archives_busy:+ if self.task_busy():returnrow = self.updater.stateif row.get('status') != 'ready' or self.update_restarting:@@ -1122,7 +1179,7 @@ class Session:self.closing = Truedef _update_engine_when_idle(self):- if self.controller.busy or self.importer.busy or self.archives_busy or self.upgrade.active or self.model_switch:+ if self.task_busy():returnbusy = self._queue_busy()self.update_waiting = bool(busy)@@ -1149,7 +1206,13 @@ class Session:updater = self.updaterif updater:updater.poll(allow_download=not (self.controller.busy or self.importer.busy or self.cleaner.busy))- if (updater and self.update_intent is None and not updater.busy and now - self.update_checked >= CHECK_SECONDS+ if (updater and self.pending_check is not None and not updater.busy and not self.closing+ and not self.update_intent and not self.pending_update):+ self.check_update(self.pending_check)+ if (self.action_notice == 'checking_update' and self.pending_check is None+ and updater and not updater.busy and updater.state.get('status') != 'checking'):+ self.action_notice = ''+ if (updater and self.update_intent is None and not self.pending_update and not updater.busy and now - self.update_checked >= CHECK_SECONDSand not updater.retryand updater.state.get('status') in ('idle', 'current', 'available', 'error', 'cancelled')):self.update_checked = now@@ -1162,11 +1225,14 @@ class Session:request = take_request(self.bridge)if request and request['action'] == 'cancel':self.bridge_pending = False- if self.update_intent:+ if self.update_intent or self.pending_update:self.dismiss_update()elif request or (self.bridge_pending and not self.controller.busy):self.bridge_pending = Falseself.update(source='browser')+ if self.pending_update and not self.task_busy() and not (updater and updater.busy):+ token, source = self.pending_update+ self.update(token, source)row = updater.state if updater else {}if self.update_intent == 'check' and updater and not updater.busy:self.update_intent = None@@ -1299,7 +1365,9 @@ class Session:installed=self.installed_version(), phase=self.update_phase(), key=key,channel=self.updater.current.get('channel') if self.updater else None,track=self.updater.current.get('track', 'stable') if self.updater else 'stable',- manual=bool(self.updater and self.updater.current.get('packaging') in ('onedir', 'app')))+ manual=bool(self.updater and self.updater.current.get('packaging') in ('onedir', 'app')),+ check_requested=self.pending_check is not None or row.get('status') == 'checking',+ check_text=self.t(*ACTION_COPY['checking_update']))# Versions between the one in use and the update, so skipped notes are not lost.from .release_notes import sincecurrent = view['current_release'] or {}@@ -1538,6 +1606,23 @@ class Session:self.tail.select(selected)self.tail.read(final=not self.controller.terminal_running(selected))self._tick_updates()+ if self.action_notice == 'busy' and self.can_manage() and not (self.updater and self.updater.busy):+ self.action_notice = ''+ if self.pending_imports and not self.task_busy() and not self.update_intent and not self.pending_update:+ paths, self.pending_imports = self.pending_imports, []+ if self.action_notice == 'import_queued':+ self.action_notice = ''+ self.import_packages(paths)+ if self.pending_action and not self.task_busy() and not self.update_intent and not self.pending_update:+ name, accepted, page, retry = self.pending_action+ self.pending_action = None+ if self.action_notice == 'setup_queued':+ self.action_notice = ''+ self.page = page+ if retry:+ Session.action(self, name, accepted, retry=retry)+ else:+ self.action(name, accepted)def _tick_page_check(self, row):"""Show a page that failed to load FreeVideo, or never reported, in the failure card."""@@ -1935,10 +2020,11 @@ class Session:return plain_data(dict(download_list=download_state, sampling_cache_bytes=total_bytes(), version=__version__, image_pack=image_pack,disk=disk, decimal_sizes=sys.platform == 'darwin', zh=self.language.startswith('zh'), form=dict(self.form),page=self.page, status=row.get('status', 'idle'), busy=busy,+ action_notice=self.t(*ACTION_COPY[self.action_notice]) if self.action_notice else '',+ setup_pending=bool(self.pending_action), setup_wait_text=self.t(*ACTION_COPY['setup_queued']),+ can_manage=self.can_manage(), busy_reason=self.t(*ACTION_COPY['busy']),cleanup=cleanup,- can_cleanup=not (self.controller.busy or self.importer.busy or self.cleaner.busy or self.archives_busy or self.closing- or self.update_intent or self.engine_updating or self.updater and self.updater.busy- or self.upgrade.active or self.model_switch or image_pack['busy']),+ can_cleanup=self.can_manage() and not (self.updater and self.updater.busy),model_upgrade=dict(model_upgrade, switching=bool(self.model_switch)),offline=dict(progress_view(self.importer.state, zh), runtime=bool(self.form['offline_runtime']),runtime_supported=runtime_packages_supported(),diff --git a/freevideo_engine/launcher_update.py b/freevideo_engine/launcher_update.pyindex 290d5ce..8598c7c 100644--- a/freevideo_engine/launcher_update.py+++ b/freevideo_engine/launcher_update.py@@ -3,6 +3,7 @@Executables live in a versioned user cache. The original EXE stays intact andforwards to a newer, explicitly approved download on subsequent starts."""+import errnoimport hashlibfrom email.utils import parsedate_to_datetimeimport json@@ -82,6 +83,8 @@ def retry_after(error):def failure_kind(error):if isinstance(error, UpdateUnavailable):return error.kind+ if isinstance(error, OSError) and error.errno == errno.ENOSPC:+ return 'disk'if isinstance(error, urllib.error.HTTPError):headers = {str(k).lower(): v for k, v in (error.headers or {}).items()}if error.code == 429 or (error.code == 403 and@@ -625,9 +628,11 @@ class UpdateClient:self.failures = 0except Exception as error:self.failures += 1- row = dict(status='cancelled' if self.cancelled.is_set() else 'error',- error_code=failure_kind(error), candidate=selected or self.available)- if (not self.cancelled.is_set() and row['error_code'] not in ('invalid', 'disk')+ stopped = self.cancelled.is_set()+ row = dict(status='cancelled' if stopped else 'error', candidate=selected or self.available)+ if not stopped:+ row['error_code'] = failure_kind(error)+ if (not stopped and row['error_code'] not in ('invalid', 'disk')and (operation == 'check' or self.failures <= MAX_DOWNLOAD_RETRIES)):delay = max(min(MAX_RETRY_SECONDS, RETRY_SECONDS * 2**min(self.failures - 1, 4)),retry_after(error))diff --git a/freevideo_engine/modern_launcher.py b/freevideo_engine/modern_launcher.pyindex 4fa9b5f..8fad2d2 100644--- a/freevideo_engine/modern_launcher.py+++ b/freevideo_engine/modern_launcher.py@@ -175,7 +175,8 @@ def create_ui(session, *, show=True):@Slot(str)def browse(self, key):- if session.controller.busy:+ if not session.can_manage():+ self.invoke(session.explain_busy)returnpath = QFileDialog.getExistingDirectory(None, session.t('Choose folder', '选择文件夹'),str(session.form.get(key) or ''), QFileDialog.ShowDirsOnly)@@ -196,7 +197,8 @@ def create_ui(session, *, show=True):@Slot()def useDownloadedFolder(self):- if session.controller.busy or session.importer.busy:+ if not session.can_manage():+ self.invoke(session.explain_busy)returnpath = QFileDialog.getExistingDirectory(None, session.downloads_view()['copy']['use_folder'], '', QFileDialog.ShowDirsOnly)if path:@@ -278,7 +280,12 @@ def create_ui(session, *, show=True):from PySide6.QtGui import QDesktopServicesfolder = session.download_exportif folder and Path(folder).is_dir():+ if session.action_notice == 'download_missing':+ session.action_notice = ''self.invoke(QDesktopServices.openUrl, QUrl.fromLocalFile(str(Path(folder).resolve())))+ else:+ session.action_notice = 'download_missing'+ self.refresh()@Slot(str)def selectSource(self, value):diff --git a/freevideo_engine/offline_packages.py b/freevideo_engine/offline_packages.pyindex 4f6c526..62810c8 100644--- a/freevideo_engine/offline_packages.py+++ b/freevideo_engine/offline_packages.py@@ -5,6 +5,7 @@ import osfrom pathlib import Pathimport shutilimport stat+import tempfileimport threadingimport timeimport zipfile@@ -202,8 +203,8 @@ def inspect_archive(path):return dict(value, marker=marker, raw=raw, id=hashlib.sha256(raw).hexdigest())-# Size and modification time of each file an import has hashed. A later check-# of the same unchanged file trusts them instead of hashing tens of GiB again.+# Size, modification time and checked digest of each imported file. A later+# check of the same unchanged content avoids hashing tens of GiB again.VERIFIED = 'import-verified.json'@@ -221,10 +222,10 @@ def stamp(path):def unchanged(path, row, known, current=None, progress=None):- """Still the file its import checked: the size matches, and the recorded time too.+ """Still the content its import checked: size, time and expected digest match.- Only a file whose record says it was rewritten since is hashed. `current`- is its [size, mtime] when a directory walk already read it.+ Missing or earlier size/time-only records require hashing. `current` is+ its [size, mtime] when a directory walk already read it."""try:current = current or stamp(path)@@ -232,7 +233,7 @@ def unchanged(path, row, known, current=None, progress=None):return Falseif current[0] != row['bytes']:return False- if known.get(row['path']) in (None, current):+ if known.get(row['path']) == [*current, row['sha256']]:return Truefrom .network import hash_filereturn hash_file(path, **({'progress': progress} if progress else {})) == row['sha256']@@ -256,11 +257,18 @@ def copy_progress(source, target, progress):def import_archive(path, destination, progress=lambda **kw: None, cancelled=lambda: False):- """Extract once, checked by the ZIP's own CRC-32 and each file's size.+ """Extract once, checking CRC-32, size and inventory SHA-256 while streaming.A file is written under a temporary name and renamed only when complete,so a file found under its own name was checked when it was written."""+ from .locking import runtime_lock+ # This lease also excludes package cleanup and other launcher instances.+ with runtime_lock(resolved(destination) / '.freevideo-packages/import.lock', inherit=False):+ return _import_archive(path, destination, progress, cancelled)+++def _import_archive(path, destination, progress, cancelled):path = resolved(path)progress(done=0, total=None, detail=path.name)archive = path.stat()@@ -285,9 +293,9 @@ def import_archive(path, destination, progress=lambda **kw: None, cancelled=lambif current[0] != row['bytes'] or not unchanged(root / row['path'], row, known, current,progress=file_progress(progress, 'verify', row['bytes'])):raise ValueError('已有导入文件已改变,未覆盖:' + plain(root / row['path']))- verified[row['path']] = current+ verified[row['path']] = [*current, row['sha256']]marker = root / value['marker']- if not missing and marker.is_file() and marker.read_bytes() == value['raw']:+ if len(verified) == len(value['files']) and marker.is_file() and marker.read_bytes() == value['raw']:# Imported before and complete: nothing to read again.save(root / VERIFIED, verified)progress(done=total, total=total, detail=path.name, activity='')@@ -306,6 +314,7 @@ def import_archive(path, destination, progress=lambda **kw: None, cancelled=lambtarget = root / row['path']target.parent.mkdir(parents=True, exist_ok=True)partial = target.with_name(target.name + '.importing')+ digest = hashlib.sha256()try:# Reading a member to its end checks its CRC-32 (BadZipFile otherwise).with archive.open(PREFIX + row['path']) as source, partial.open('wb') as output:@@ -316,13 +325,14 @@ def import_archive(path, destination, progress=lambda **kw: None, cancelled=lambif not data:breakoutput.write(data); done += len(data)+ digest.update(data)progress(done=done, total=total, detail=path.name)except zipfile.BadZipFile as error:raise ValueError('离线包已损坏,请重新下载:' + path.name) from error- if partial.stat().st_size != row['bytes']:+ if partial.stat().st_size != row['bytes'] or digest.hexdigest() != row['sha256']:raise ValueError('离线包校验失败,已保留文件:' + path.name)partial.replace(target)- verified[row['path']] = stamp(target)+ verified[row['path']] = [*stamp(target), row['sha256']]save(root / VERIFIED, verified)marker.write_bytes(value['raw'])return dict(root=plain(root), kind=value['kind'], variant=value['variant'], name=path.name, **origin)@@ -362,6 +372,25 @@ def encoder_library(runtime, config, present):return ENCODER_COPY, [copy for _, copy in rows]+def publish_without_overwrite(partial, target):+ """Give a finished copy its final name, never replacing a file that appeared meanwhile."""+ try:+ try:+ os.link(partial, target)+ except FileExistsError:+ raise+ except OSError:+ # No hard links on this disk: renaming onto nothing is the safe way left.+ if os.name != 'nt' and os.path.lexists(target):+ raise FileExistsError(str(target))+ os.rename(partial, target)+ return+ except FileExistsError:+ partial.unlink(missing_ok=True)+ raise ValueError('离线安装已有不同模型,未覆盖:' + plain(target)) from None+ partial.unlink(missing_ok=True)++def assemble(runtime, models, source, progress=lambda **kw: None):"""Bind imported components to the current EXE's engine, without running it."""runtime = io_path(runtime)@@ -402,7 +431,13 @@ def assemble(runtime, models, source, progress=lambda **kw: None):try:os.link(src, target)except OSError:- copy_progress(src, target, file_progress(progress, 'copy_bytes', src.stat().st_size))+ # Keep an interrupted copy outside the final name. A unique staging+ # name also preserves any existing neighbors the user added.+ with tempfile.NamedTemporaryFile(prefix='model-copy-', suffix='.copying',+ dir=target.parent, delete=False) as output:+ partial = Path(output.name)+ copy_progress(src, partial, file_progress(progress, 'copy_bytes', src.stat().st_size))+ publish_without_overwrite(partial, target)included = []for row in model['files']:@@ -481,7 +516,8 @@ def finish(runtime, config, model, source, here=None):# the first start takes that instead of reading tens of GiB once more.imported, final = stamps(runtime), listing(runtime)trusted = {row['path'] for row in model['files'] + copies}- trusted |= {row['path'] for row in config['files'] if imported.get(row['path']) == final.get(row['path'])}+ trusted |= {row['path'] for row in config['files'] if row['path'] in final+ and imported.get(row['path']) == [*final[row['path']], row['sha256']]}save(runtime / 'engine' / 'portable-verified.json',{row['path']: dict(bytes=final[row['path']][0], mtime_ns=final[row['path']][1], sha256=row['sha256'])for row in value['files'] if row['path'] in trusted and row['path'] in final})diff --git a/freevideo_engine/package_cleanup.py b/freevideo_engine/package_cleanup.pyindex 19ce369..f7ce501 100644--- a/freevideo_engine/package_cleanup.py+++ b/freevideo_engine/package_cleanup.py@@ -226,8 +226,36 @@ def packages(folder):yield Path(plain(pack)), 'models', value if isinstance(value, dict) else None+def known_package_tree(pack, value):+ """Retain unrecognized packages and anything added outside their inventory."""+ from .offline_packages import inventory, VERIFIED+ if (not isinstance(value, dict) or value.get('schema_version') != 1 or value.get('kind') != 'models'+ or not isinstance(value.get('files'), list) or not value['files']):+ return False+ try:+ inventory(value['files'])+ if any(not row['path'].startswith('models/') for row in value['files']):+ return False+ files = {INNER + '/' + row['path'] for row in value['files']}+ files.update(INNER + '/' + name for name in (MODELS_MARKER, VERIFIED, '模型包使用说明.txt'))+ folders = {parent.as_posix() for name in files for parent in Path(name).parents}+ pack = io_path(pack)+ def unreadable(error):+ raise error+ for directory, children, names in os.walk(pack, followlinks=False, onerror=unreadable):+ directory = Path(directory)+ if any((directory / name).relative_to(pack).as_posix() not in folders for name in children):+ return False+ if any((directory / name).relative_to(pack).as_posix() not in files for name in names):+ return False+ return True+ except (OSError, ValueError, KeyError, TypeError):+ return False++def prune_packages(engine, comfy_root=None, index=None, running=None, dry_run=False):"""Model package extractions the installation no longer needs."""+ from .locking import runtime_lockresult = dict(released_bytes=0, removed=[], kept=[])try:engine = checked_real_path(engine)@@ -241,32 +269,39 @@ def prune_packages(engine, comfy_root=None, index=None, running=None, dry_run=Fainstalled = installed_at(engine)holders = [io_path(checked_real_path(path)) for paths in index.values() for path in paths]for folder in package_roots(engine, comfy_root):- for pack, kind, value in packages(folder):- pack = io_path(pack)- if kind == 'runtime' or inside(engine, pack):- result['kept'].append(dict(kind='offline-package', path=plain(pack), reason='environment package'))- continue- if any(inside(path, pack) for path in holders):- result['kept'].append(dict(kind='offline-package', path=plain(pack), reason='installed files live here'))- continue- rows = [row for row in (value or {}).get('files', [])- if isinstance(row, dict) and row.get('path') != PACK_INVENTORY- and (pack / INNER / str(row.get('path', ''))).is_file()]- covered = bool(rows) and all(row.get('sha256') in index for row in rows)- try:- stale = installed is not None and max((pack / INNER).stat().st_mtime, pack.stat().st_mtime) < installed- except OSError:- stale = installed is not None- if not covered and not stale:- result['kept'].append(dict(kind='offline-package', path=plain(pack), reason='imported after this installation'))- continue- freed = discard(pack, folder, running, dry_run)- if freed is None:- result['kept'].append(dict(kind='offline-package', path=plain(pack), reason='in use'))- continue- result['released_bytes'] += freed- result['removed'].append(dict(kind='offline-package', path=plain(pack), bytes=freed,- reason='installed and verified' if covered else 'not used by this installation'))+ try:+ with runtime_lock(io_path(folder) / 'import.lock', inherit=False):+ for pack, kind, value in packages(folder):+ pack = io_path(pack)+ if kind == 'runtime' or inside(engine, pack):+ result['kept'].append(dict(kind='offline-package', path=plain(pack), reason='environment package'))+ continue+ if any(inside(path, pack) for path in holders):+ result['kept'].append(dict(kind='offline-package', path=plain(pack), reason='installed files live here'))+ continue+ if not known_package_tree(pack, value):+ result['kept'].append(dict(kind='offline-package', path=plain(pack), reason='in use'))+ continue+ rows = [row for row in (value or {}).get('files', [])+ if isinstance(row, dict) and row.get('path') != PACK_INVENTORY+ and (pack / INNER / str(row.get('path', ''))).is_file()]+ covered = bool(rows) and all(row.get('sha256') in index for row in rows)+ try:+ stale = installed is not None and max((pack / INNER).stat().st_mtime, pack.stat().st_mtime) < installed+ except OSError:+ stale = installed is not None+ if not covered and not stale:+ result['kept'].append(dict(kind='offline-package', path=plain(pack), reason='imported after this installation'))+ continue+ freed = discard(pack, folder, running, dry_run)+ if freed is None:+ result['kept'].append(dict(kind='offline-package', path=plain(pack), reason='in use'))+ continue+ result['released_bytes'] += freed+ result['removed'].append(dict(kind='offline-package', path=plain(pack), bytes=freed,+ reason='installed and verified' if covered else 'not used by this installation'))+ except BlockingIOError:+ result['kept'].append(dict(kind='offline-package', path=plain(folder), reason='in use'))return resultdiff --git a/web/launcher.js b/web/launcher.jsindex 63a1fdb..836d860 100644--- a/web/launcher.js+++ b/web/launcher.js@@ -12,8 +12,8 @@ let configured = performance.now();// ComfyUI restores the previous session's workflow and tabs after every// extension's setup, so that restore can bring another workflow to the front-// over ours. Once startup is quiet, bring ours back unless the user has-// already moved on. Never awaited from setup: ComfyUI restores only after+// over ours. Once startup is quiet, bring our tab back into view even if a+// click or key arrived during startup. Never awaited from setup: ComfyUI restores only after// setup returns.async function keepInFront(workflow, opened) {let touched = false;@@ -23,8 +23,11 @@ async function keepInFront(workflow, opened) {const begin = performance.now();while (performance.now() - begin < 15000&& (app.extensionManager?.spinner || performance.now() - configured < 600)) await sleep(100);- if (studioWorkflow(app.graph) || touched) return;+ // An already visible FreeVideo graph may contain edits; keep that copy.+ if (studioWorkflow(app.graph)) return;const store = app.extensionManager?.workflow;+ // The user kept working in our own tab: its edits stay, even without the generate node.+ if (touched && opened && store?.activeWorkflow === opened) return;// Our own tab when ComfyUI still has it; a new one otherwise.const target = opened && store?.getWorkflowByPath?.(opened.path) === opened ? opened : 'FreeVideo';await app.loadGraphData(structuredClone(workflow), true, true, target);diff --git a/web/setup.js b/web/setup.jsindex 79c5bbc..6003743 100644--- a/web/setup.js+++ b/web/setup.js@@ -13,6 +13,7 @@ const languageOverride = typeof location !== 'undefined'const cn = languageOverride === 'zh' || (languageOverride !== 'en'&& String(navigator.language || '').toLowerCase().startsWith('zh'));const t = (en, zh) => cn ? zh : en;+const INSTALLED_HINT = {en: 'Already installed. To reinstall, click Detect & review first.', zh: '已装好;要重装请先点「检测并预览」'};const gib = n => Number.isFinite(n) ? (n / 2 ** 30).toFixed(1) + " GiB" : "—";const failureText = value => {const text = String(value || ''), matches = [...text.matchAll(/MODEL_MISMATCH_REPAIR: ([^\r\n]+)/g)];@@ -260,8 +261,9 @@ export async function openSetup() {const controls = () => {for (const e of [root, extra, copy, samplingCaches, saveFolders, inspect, use, hfToken, applyToken, clearToken]) e.disabled = busy;cancel.disabled = !busy; install.disabled = busy || !planId || !accept.checked; accept.disabled = busy; inspect.classList.toggle("fv-primary", !planId); install.classList.toggle("fv-primary", Boolean(planId));- const why = busy || (ready && !planId) ? "" : planStale ? t("Settings changed. Click Detect & review again to update the plan.", "设置已更改,请重新点击「检测并预览」更新安装计划。")+ const why = busy ? "" : planStale ? t("Settings changed. Click Detect & review again to update the plan.", "设置已更改,请重新点击「检测并预览」更新安装计划。"): planErrors ? t("The plan has problems shown in red above. Please resolve them, then click Detect & review again.", "安装计划中有标红的问题,请解决后重新点击「检测并预览」。")+ : ready && !planId ? t(INSTALLED_HINT.en, INSTALLED_HINT.zh): !planId ? t("Click Detect & review first. Install / repair becomes available once the plan is ready.", "请先点击「检测并预览」,生成安装计划后即可安装。"): !accept.checked ? t("Tick the agreement above to enable Install / repair.", "勾选上方的同意选项后,即可点击「安装/修复」。") : "";blocked.textContent = why; blocked.hidden = !why;diff --git a/web/updates.js b/web/updates.jsindex 0475c13..b40b70d 100644--- a/web/updates.js+++ b/web/updates.js@@ -3,6 +3,7 @@ import { api } from '../../scripts/api.js';// Every platform downloads from one release: the latest vX.Y.Z.const releasePage = 'https://github.com/FlashML-org/FreeVideo/releases/latest';const storageKey = 'freevideo.dismissed-update';+const CANCEL_FAILURE = {en: 'Cancellation failed. Please use the launcher.', zh: '取消没成功,请在启动器里操作'};const listeners = new Set();// Launcher phases during which the server may disappear and come back updated.const working = new Set(['checking', 'downloading', 'waiting', 'restarting', 'engine']);@@ -80,10 +81,17 @@ export async function applyUpdate() {}export async function cancelUpdate() {- try {- const response = await api.fetchApi('/freevideo/updates/cancel', {method: 'POST', cache: 'no-store', signal: AbortSignal.timeout(10000)});- if (response.ok) updating = false;- } catch { /* The launcher keeps its state; the next poll shows it. */ }+ failure = '';+ for (let attempt = 0; attempt < 2; attempt++) {+ try {+ const response = await api.fetchApi('/freevideo/updates/cancel', {method: 'POST', cache: 'no-store', signal: AbortSignal.timeout(10000)});+ if (!response.ok) throw new Error(response.statusText);+ updating = false;+ break;+ } catch {+ if (attempt === 1) failure = 'cancel';+ }+ }publish();lastCheck = -Infinity;later(800);@@ -144,7 +152,9 @@ export function createUpdateNotice(cn) {const model = launcher?.model || '';const busy = updating && (working.has(phase) || !!model || offline);let text = '', actions = false;- if (busy) {+ if (failure === 'cancel') {+ text = t(CANCEL_FAILURE.en, CANCEL_FAILURE.zh);+ } else if (busy) {text = model === 'switching' || (model && offline)? t('Switching to the faster model… ComfyUI restarts once and this page reconnects by itself.', '正在切换到更快的模型…ComfyUI 会重启一次,页面会自动恢复。'): model === 'waiting' ? t('The faster model is ready. FreeVideo switches after the current video; ComfyUI restarts once.', '更快的模型已下载好,当前视频生成完后自动切换,ComfyUI 会重启一次。')