Compare commits

...
2 Commits
Author SHA1 Message Date
ausboss 9986ded109 Merge pull request #356 from ausboss/fix/cache-guard-version-order
Ask for a reload only when the pack is newer than the page
2026-11-14 18:00:18 -06:00
ausboss 197ac04a8c Ask for a reload only when the pack is newer than the page
The update guard asked for a reload whenever the server's version and the
page's differed. After the Manager switches the pack on disk, the server
keeps reporting the old version until ComfyUI restarts, so a reload in
between loads the new files and the message said the page was older when
it was newer.

Now the guard speaks only when the server's version is the newer one, and
versions compare part by part as numbers. A version that is not three
plain numbers, such as "unknown", stays silent.

A page newer than the server stays silent rather than asking for a
restart: from two version numbers it cannot be told apart from a downgrade
with the tab left open, which needs a reload, and the Manager already asks
for its own restart after a switch.
2026-11-14 17:47:11 -06:00
3 changed files with 66 additions and 1 deletions
+10
View File
@@ -2,6 +2,16 @@
All notable changes to ComfyUI-AusBoss are documented here.
## Unreleased
- **The "AusBoss was updated" message no longer asks for a reload by
mistake.** After the Manager switched the pack to another version, a
page reload before ComfyUI restarted brought up the message, telling you
the page was older than the pack when it was newer. A restart was what
was needed. Now the message only comes up when the pack really is newer
than the page, and versions such as 2.25.10 and 2.25.9 are compared as
numbers.
## 2.26.2 - 2026-11-14
- **Loaders never look up a file name they refused.** Before each run,
+20 -1
View File
@@ -49,6 +49,25 @@ function askForReload(installed) {
}
}
// "2.26.2" -> [2, 26, 2]. Anything else, such as "unknown", is null.
function parseVersion(version) {
const match = /^(\d+)\.(\d+)\.(\d+)$/.exec(typeof version === "string" ? version : "");
return match ? match.slice(1).map(Number) : null;
}
// Only a server newer than the page means this tab runs old files. The page
// is newer when the Manager switched the pack on disk and the page was
// reloaded before ComfyUI restarted, and then a restart is what is needed.
// Two version numbers cannot tell that apart from a downgrade with the tab
// left open, which needs a reload, so in that case the guard says nothing.
function serverIsNewer(installed, running) {
const server = parseVersion(installed);
const page = parseVersion(running);
if (!server || !page) return false;
const step = server.findIndex((part, index) => part !== page[index]);
return step >= 0 && server[step] > page[step];
}
// The installed version this page already asked a reload for. A server that
// drops and comes back several times must not stack the same message.
let asked = null;
@@ -58,7 +77,7 @@ async function check() {
try {
const installed = (await (await api.fetchApi("/ausboss/pack_version")).json())?.version;
const running = await runningVersion();
if (!installed || installed === "unknown" || !running || installed === running || installed === asked) return;
if (!serverIsNewer(installed, running) || installed === asked) return;
asked = installed;
const listing = await (await api.fetchApi("/ausboss/pack_modules")).json();
await refreshModules(Array.isArray(listing?.modules) ? listing.modules : []);
+36
View File
@@ -102,3 +102,39 @@ test("a server that does not answer keeps the page quiet", async (t) => {
await page.serverComesBack("2.7.0");
assert.equal(page.toasts.length, 1);
});
// The Manager switches the pack's files on disk, and the server keeps running
// the old version until ComfyUI restarts. A reload in between gives the page
// the new files: the page is newer than the server, and "press F5" is wrong.
test("a page newer than the server says nothing", async (t) => {
const page = await openPage(t, { running: "2.26.2", installed: "2.25.2" });
assert.deepEqual(page.toasts, []);
assert.deepEqual(page.refreshed, []);
await page.serverComesBack("2.26.2");
assert.deepEqual(page.toasts, [], "after the restart the two match");
});
test("versions compare as numbers, not as text", async (t) => {
const older = await openPage(t, { running: "2.25.10", installed: "2.25.9" });
assert.deepEqual(older.toasts, [], "2.25.9 is older than 2.25.10");
const newer = await openPage(t, { running: "2.25.9", installed: "2.25.10" });
assert.equal(newer.toasts.length, 1, "2.25.10 is newer than 2.25.9");
assert.match(newer.toasts[0].detail, /v2\.25\.10 is installed/);
});
test("an unknown or odd version says nothing", async (t) => {
for (const [running, installed] of [
["2.26.2", "unknown"],
["2.26.2", "2.27"],
["2.26.2", "2.27.0rc1"],
["2.26.2", "v2.27.0"],
["2.26.2", 3],
["unknown", "2.27.0"],
["dev", "2.27.0"],
[null, "2.27.0"],
]) {
const page = await openPage(t, { running, installed });
assert.deepEqual(page.toasts, [], `page ${running}, server ${installed}`);
assert.deepEqual(page.refreshed, [], `page ${running}, server ${installed}`);
}
});