From 0707a7676853c45f1c0eb3bee0c118005e1dbe5d Mon Sep 17 00:00:00 2001 From: Ethanfel Date: Mon, 22 Jun 2026 17:48:10 +0200 Subject: [PATCH] feat(install): handleTrialInstall orchestrator with Manager fallback --- js/nodes_stats.js | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/js/nodes_stats.js b/js/nodes_stats.js index 0cae5ab..5f90741 100644 --- a/js/nodes_stats.js +++ b/js/nodes_stats.js @@ -1225,6 +1225,41 @@ async function handleInstall(pkg, dialog) { ); } +// Real install of a missing pack, optionally on a 7-day trial. Resolves the +// install spec, installs via Manager, discovers the resulting directory, and +// (for a trial) registers it. Falls back to opening Manager on any failure. +async function handleTrialInstall(pkg, dialog, temporary) { + if (await managerIsBusy()) { + notify("ComfyUI Manager is busy. Please try again in a moment.", "warn"); + return; + } + const target = await resolveInstallTarget(pkg); + if (!target) { await handleInstall(pkg, dialog); return; } + + setWorkflowButtonsBusy(dialog, true); + try { + await runManagerEnable(installPayload(target, pkg)); // shared /manager/queue/install flow + const dir = temporary ? await findInstalledDir(target) : null; + if (temporary && dir) { + await fetch("/nodes-stats/trials/start", { + method: "POST", headers: { "Content-Type": "application/json" }, + body: JSON.stringify({ package: dir }), + }); + } + showRestartBanner(dialog); + if (temporary && !dir) { + notify(`Installed ${pkg}, but couldn't register the trial — manage it manually. Restart to load.`, "warn"); + } else { + notify(`Installed ${pkg}${temporary ? " for a 7-day trial" : ""}. Restart ComfyUI to load it.`, "success"); + } + } catch (e) { + notify("Install failed: " + e.message + " — opening ComfyUI Manager.", "warn"); + await handleInstall(pkg, dialog); + } finally { + setWorkflowButtonsBusy(dialog, false); + } +} + function setWorkflowButtonsBusy(dialog, busy) { dialog.querySelectorAll(".ns-enable-temp-btn, .ns-enable-perm-btn, .ns-install-btn").forEach((b) => { b.disabled = busy;