Compare commits

...
Author SHA1 Message Date
Dr.Lt.Data ce965cdbcf v4: A list request without mode is answered (#3653)
`GET /v2/customnode/getmappings` of both servers, and
`/v2/customnode/getlist` and `/v2/externalmodel/getlist` of the legacy
server, read `mode` with `request.rel_url.query["mode"]` and answered
500 with `KeyError: 'mode'` for a request without it (#2740).

- The four handlers read `mode` with `cache` as its default
- Add a test for the four handlers: a request without `mode` gets the
  answer of `mode=cache`, which is not the answer of `mode=local`
- `tests/test_legacy_secgate_other_paths.py` puts back the `get_data` that
  it replaces for its own cases. It left the replacement in place, and a
  test that ran after it read no file
- Add a CHANGELOG entry

The same change for main is #2741.
2026-12-04 01:19:38 +09:00
Dr.Lt.Data 18ca3be301 v4: The Version column no longer shows an older registry version as an update (#3651)
The Version column of the legacy Custom Nodes Manager showed
`[↑<version>]` whenever the installed version was not the latest
version of the registry, so a nodepack installed at 1.78.1 showed
`[↑1.47.0]` when the registry had 1.47.0 as its latest (#3272).

- `compareVersionSpecs` orders versions that are only numbers, and the
  arrow is shown only when the version of the registry is newer
- For any other version, such as `2.0.0-rc1`, an enabled nodepack
  shows the arrow when the server offers an update for it
  (`update-state`). A disabled nodepack is as before
- Add tests and a CHANGELOG entry

The same change for main is #3364.
2026-12-03 12:50:44 +09:00
Benjamin Lu bf98e9f2cc v4: Report desktop-linux form factor for Desktop installs on Linux (#3377)
A Desktop install on Linux reported `form_factor=other` to the
registry. The Manager mapped the marker that Desktop sets,
`__COMFYUI_DESKTOP_VERSION__`, to `desktop-win` and `desktop-mac` only,
and Desktop sets the marker on Linux since its v1.1.8.

- Move the choice of the form factor out of the fetch of the registry
  list into `get_form_factor()`
- Desktop on Linux reports `desktop-linux`. Every other combination
  reports what it did before
- Add tests for each platform with and without the marker, and for the
  request carrying the value, and a CHANGELOG entry
2026-12-03 12:00:18 +09:00
9 changed files with 295 additions and 31 deletions
+20
View File
@@ -44,6 +44,26 @@ and this project adheres to [Semantic Versioning 2.0.0](https://semver.org/spec/
### Fixed
- A list request without `mode` is answered. `GET /v2/customnode/getmappings`
and, with the legacy UI, `/v2/customnode/getlist` and
`/v2/externalmodel/getlist` answered 500 with `KeyError: 'mode'` when the
request had no `mode` (#2740). Such a request is now answered as one with
`mode=cache`. The legacy pages always send `mode`, so nothing changes for
them.
- The Version column of the legacy Custom Nodes Manager no longer shows an
older registry version as an update. The column showed `[↑<version>]`
whenever the installed version was not the latest version of the registry,
so a nodepack installed at 1.78.1 showed `[↑1.47.0]` when the registry had
1.47.0 as its latest (#3272). The arrow is now shown only when the version
of the registry is newer. For a version that is not only numbers, such as
`2.0.0-rc1`, an enabled nodepack shows the arrow when an update is offered
for it, and a disabled one is as before. The **Update** button is not
changed: it was already offered only for a newer version.
- Report the `desktop-linux` form factor to the registry for Desktop installs
on Linux, which previously reported `other`.
- aria2 does not download a file that is already there. With aria2 as the
downloader, an install of a model whose file was already in its folder
downloaded the model once more. aria2 saved the download next to the file
+24 -21
View File
@@ -20,6 +20,29 @@ lock = asyncio.Lock()
is_cache_loading = False
def get_form_factor():
"""Form factor reported to the registry, based on environment and platform."""
is_desktop = bool(os.environ.get('__COMFYUI_DESKTOP_VERSION__'))
system = platform.system().lower()
if is_desktop:
if system == 'windows':
return 'desktop-win'
if system == 'darwin':
return 'desktop-mac'
if system == 'linux':
return 'desktop-linux'
return 'other'
if system == 'windows':
return 'git-windows'
if system == 'darwin':
return 'git-mac'
if system == 'linux':
return 'git-linux'
return 'other'
async def get_cnr_data(cache_mode=True, dont_wait=True):
try:
return await _get_cnr_data(cache_mode, dont_wait)
@@ -39,12 +62,7 @@ async def _get_cnr_data(cache_mode=True, dont_wait=True):
full_nodes = {}
# Determine form factor based on environment and platform
is_desktop = bool(os.environ.get('__COMFYUI_DESKTOP_VERSION__'))
system = platform.system().lower()
is_windows = system == 'windows'
is_mac = system == 'darwin'
is_linux = system == 'linux'
# Get ComfyUI version tag
if is_desktop:
@@ -53,22 +71,7 @@ async def _get_cnr_data(cache_mode=True, dont_wait=True):
else:
comfyui_ver = context.get_comfyui_tag() or 'unknown'
if is_desktop:
if is_windows:
form_factor = 'desktop-win'
elif is_mac:
form_factor = 'desktop-mac'
else:
form_factor = 'other'
else:
if is_windows:
form_factor = 'git-windows'
elif is_mac:
form_factor = 'git-mac'
elif is_linux:
form_factor = 'git-linux'
else:
form_factor = 'other'
form_factor = get_form_factor()
from comfyui_manager.glob import manager_core
verbose = manager_core.get_config().get('verbose', False)
+1 -1
View File
@@ -1427,7 +1427,7 @@ async def fetch_customnode_mappings(request):
"""
provide unified (node -> node pack) mapping list
"""
mode = request.rel_url.query["mode"]
mode = request.rel_url.query.get("mode", "cache")
nickname_mode = False
if mode == "nickname":
+22 -1
View File
@@ -22,6 +22,22 @@ const gridId = "node";
const INVALID_INSTALLATION_GUIDANCE = "This nodepack was not installed through ComfyUI-Manager, or its installation is damaged, so the Manager cannot update it. Reinstalling deletes its folder and installs the nodepack again.";
function compareVersionSpecs(a, b) {
const pa = String(a).split(".").map((x) => /^\d+$/.test(x) ? parseInt(x, 10) : NaN);
const pb = String(b).split(".").map((x) => /^\d+$/.test(x) ? parseInt(x, 10) : NaN);
if (pa.some(Number.isNaN) || pb.some(Number.isNaN)) {
return null;
}
const len = Math.max(pa.length, pb.length);
for (let i = 0; i < len; i++) {
const x = pa[i] || 0;
const y = pb[i] || 0;
if (x > y) return 1;
if (x < y) return -1;
}
return 0;
}
const pageHtml = `
<div class="cn-manager cn-manager-dark">
<div class="cn-manager-grid"></div>
@@ -850,7 +866,12 @@ export class CustomNodesManager {
if(version == 'nightly') {
return `<div>${sanitizeHTML(String(version))}</div><div>[${sanitizeHTML(String(rowItem.cnr_latest))}]</div>`;
}
return `<div>${sanitizeHTML(String(version))}</div><div>[↑${sanitizeHTML(String(rowItem.cnr_latest))}]</div>`;
const cmp = compareVersionSpecs(rowItem.cnr_latest, version);
const serverChecked = rowItem.state === 'enabled';
const newer = cmp === null && serverChecked ? rowItem['update-state'] === 'true' : cmp === null || cmp === 1;
if(newer) {
return `<div>${sanitizeHTML(String(version))}</div><div>[↑${sanitizeHTML(String(rowItem.cnr_latest))}]</div>`;
}
}
return sanitizeHTML(String(version));
}
+8 -6
View File
@@ -875,7 +875,7 @@ async def fetch_customnode_mappings(request):
"""
provide unified (node -> node pack) mapping list
"""
mode = request.rel_url.query["mode"]
mode = request.rel_url.query.get("mode", "cache")
nickname_mode = False
if mode == "nickname":
@@ -1134,14 +1134,16 @@ async def fetch_customnode_list(request):
"""
provide unified custom node list
"""
if request.rel_url.query["mode"] == "local":
mode = request.rel_url.query.get("mode", "cache")
if mode == "local":
channel = 'local'
else:
channel = core.get_config()['channel_url']
node_packs = await core.get_unified_total_nodes(channel, request.rel_url.query["mode"], 'cache')
json_obj_github = core.get_data_by_mode(request.rel_url.query["mode"], 'github-stats.json', 'default')
json_obj_extras = core.get_data_by_mode(request.rel_url.query["mode"], 'extras.json', 'default')
node_packs = await core.get_unified_total_nodes(channel, mode, 'cache')
json_obj_github = core.get_data_by_mode(mode, 'github-stats.json', 'default')
json_obj_extras = core.get_data_by_mode(mode, 'extras.json', 'default')
core.populate_github_stats(node_packs, await json_obj_github)
core.populate_favorites(node_packs, await json_obj_extras)
@@ -1237,7 +1239,7 @@ def check_model_installed(json_obj):
@routes.get("/v2/externalmodel/getlist")
async def fetch_externalmodel_list(request):
# The model list is only allowed in the default channel, yet.
json_obj = await core.get_data_by_mode(request.rel_url.query["mode"], 'model-list.json')
json_obj = await core.get_data_by_mode(request.rel_url.query.get("mode", "cache"), 'model-list.json')
check_model_installed(json_obj)
+58
View File
@@ -0,0 +1,58 @@
"""Form factor the CNR client reports to the registry."""
import asyncio
import pytest
from _install_flags_testutil import import_context
@pytest.fixture
def cnr_utils():
import_context()
from comfyui_manager.common import cnr_utils
return cnr_utils
@pytest.mark.parametrize(
('system', 'desktop', 'expected'),
[
('Windows', True, 'desktop-win'),
('Darwin', True, 'desktop-mac'),
('Linux', True, 'desktop-linux'),
('FreeBSD', True, 'other'),
('Windows', False, 'git-windows'),
('Darwin', False, 'git-mac'),
('Linux', False, 'git-linux'),
('FreeBSD', False, 'other'),
],
)
def test_form_factor(cnr_utils, monkeypatch, system, desktop, expected):
monkeypatch.setattr(cnr_utils.platform, 'system', lambda: system)
if desktop:
monkeypatch.setenv('__COMFYUI_DESKTOP_VERSION__', '1.0.0')
else:
monkeypatch.delenv('__COMFYUI_DESKTOP_VERSION__', raising=False)
assert cnr_utils.get_form_factor() == expected
def test_the_registry_request_carries_the_form_factor(cnr_utils, monkeypatch):
from comfyui_manager.glob import manager_core
asked = []
async def get_data_with_cache(uri, **kwargs):
asked.append(uri)
return {'nodes': [], 'totalPages': 1}
monkeypatch.setattr(cnr_utils.manager_util, 'get_data_with_cache', get_data_with_cache)
monkeypatch.setattr(cnr_utils.manager_util, 'save_to_cache', lambda uri, data: None)
monkeypatch.setattr(manager_core, 'get_config', lambda: {})
monkeypatch.setattr(cnr_utils.time, 'sleep', lambda seconds: None)
monkeypatch.setattr(cnr_utils.platform, 'system', lambda: 'Linux')
monkeypatch.setenv('__COMFYUI_DESKTOP_VERSION__', '1.0.0')
asyncio.run(cnr_utils._get_cnr_data(cache_mode=False))
assert [uri.partition('&form_factor=')[2] for uri in asked] == ['desktop-linux']
+5 -2
View File
@@ -52,6 +52,7 @@ from _install_flags_testutil import ( # noqa: E402
)
_LEGACY_SERVER = None
_GET_DATA = None
def _import_legacy_server():
@@ -59,7 +60,7 @@ def _import_legacy_server():
(idempotent; memoized). Returns the real module object so the tests drive
the REAL gate function and REAL handlers — only the runtime *environment*
is stubbed, never the gate logic."""
global _LEGACY_SERVER
global _LEGACY_SERVER, _GET_DATA
if _LEGACY_SERVER is not None:
return _LEGACY_SERVER
@@ -108,6 +109,7 @@ def _import_legacy_server():
async def _inert_get_data(uri, *a, **k):
return {"custom_nodes": [], "models": [], "node_map": {}}
_GET_DATA = mu.get_data
mu.get_data = _inert_get_data
_LEGACY_SERVER = importlib.import_module("comfyui_manager.legacy.manager_server")
@@ -116,7 +118,8 @@ def _import_legacy_server():
@pytest.fixture(scope="module")
def ms():
return _import_legacy_server()
yield _import_legacy_server()
sys.modules["comfyui_manager.common.manager_util"].get_data = _GET_DATA
@pytest.fixture
+28
View File
@@ -0,0 +1,28 @@
import asyncio
import json
import re
from types import SimpleNamespace
import pytest
from aiohttp import web
from legacy_html_testutil import PACKAGE, load_functions
from test_default_channel import COMFY_ORG, configure, registry, route, user, write # noqa: F401
ROUTES = [('glob', 'fetch_customnode_mappings'), ('legacy', 'fetch_customnode_mappings'),
('legacy', 'fetch_customnode_list'), ('legacy', 'fetch_externalmodel_list')]
@pytest.mark.parametrize('server,name', ROUTES)
def test_a_request_without_mode_is_answered_as_mode_cache(user, registry, server, name): # noqa: F811
configure(user, None, COMFY_ORG)
write(user, f'{server} start')
handler = load_functions(PACKAGE / server / 'manager_server.py', {name}, {
'core': user.cores[server], 'web': web, 'routes': SimpleNamespace(get=route, post=route), 're': re,
'nodes': SimpleNamespace(NODE_CLASS_MAPPINGS={}), 'populate_markdown': lambda row: None,
'check_model_installed': lambda listed: None})[name]
def ask(**query):
return json.loads(asyncio.run(handler(SimpleNamespace(rel_url=SimpleNamespace(query=query)))).text)
assert ask() == ask(mode='cache') != ask(mode='local')
+129
View File
@@ -0,0 +1,129 @@
import json
import os
import unittest
from pathlib import Path
from js_lift import NODE, JsSource, run_node, slice_braced, slice_object_entry
REPO_ROOT = Path(__file__).resolve().parent.parent
JS = JsSource(os.environ.get("MANAGER_JS_DIR") or (REPO_ROOT / "comfyui_manager" / "js"))
MANAGER = "custom-nodes-manager.js"
COMMON = "common.js"
VERSION_ANCHOR = "id: 'version',"
HELPER_MARKER = "function compareVersionSpecs"
def _helper_source() -> str:
return slice_braced(JS.text(MANAGER), HELPER_MARKER)
def _version_formatter() -> str:
block = slice_object_entry(JS.text(MANAGER), VERSION_ANCHOR)
marker = "formatter:"
return block[block.index(marker) + len(marker):].strip()
def _sanitize_html_source() -> str:
return JS.lift_declaration(COMMON, "export function sanitizeHTML(")
def _render(formatter_source: str, installed, cnr_latest, **row) -> str:
script = "\n".join([
_sanitize_html_source(),
_helper_source(),
"const formatter = %s;" % (formatter_source,),
"const rowItem = %s;" % json.dumps({"cnr_latest": cnr_latest, "originalData": {"id": "x"}, **row}),
"console.log(JSON.stringify({markup: String(formatter(%s, rowItem, {}))}));"
% json.dumps(installed),
])
return run_node(script)["markup"]
BADGE = "<div>%s</div><div>[↑%s]</div>"
CASES = [
("1.78.1", "1.47.0", "1.78.1",
"issue #3272: locally newer must NOT be flagged as updatable"),
("1.47.0", "1.47.0", "1.47.0",
"equal versions: no badge"),
("1.0.0", "1.47.0", BADGE % ("1.0.0", "1.47.0"),
"registry is genuinely newer: badge kept"),
("1.78.1", "0.0.0", "1.78.1",
"manager_core's 'no latest_version' sentinel must not render [↑0.0.0]"),
("0.0.0", "1.47.0", BADGE % ("0.0.0", "1.47.0"),
"a 0.0.0 install is still older than the registry: badge kept"),
("1.2", "1.10.0", BADGE % ("1.2", "1.10.0"),
"numeric compare: 1.10.0 > 1.2 (a string compare would miss this update)"),
("1.10.0", "1.2", "1.10.0",
"numeric compare: 1.10.0 > 1.2, so no badge"),
("nightly", "1.47.0", "<div>nightly</div><div>[1.47.0]</div>",
"the nightly branch is untouched: no arrow, badge-free"),
("1.2.3rc1", "1.47.0", BADGE % ("1.2.3rc1", "1.47.0"),
"unparseable spec: legacy string behavior kept"),
]
UNORDERED_CASES = [
("2.0.0rc1", "1.47.0", "enabled", "false", "2.0.0rc1",
"a release candidate of a newer version is not behind the registry"),
("1.0.0-beta.2", "0.9.0", "enabled", "false", "1.0.0-beta.2",
"a beta of a newer version is not behind the registry"),
("1.0.0", "nightly", "enabled", "false", "1.0.0",
"a nodepack without a version in the registry has nothing to update to"),
("1.2.3rc1", "1.47.0", "enabled", "true", BADGE % ("1.2.3rc1", "1.47.0"),
"the server offers the update: badge kept"),
("1.2.3rc1", "1.47.0", "disabled", "false", BADGE % ("1.2.3rc1", "1.47.0"),
"disabled: the server has no answer, legacy string behavior kept"),
("1.78.1", "1.47.0", "enabled", "true", "1.78.1",
"versions the helper orders do not read update-state"),
]
@unittest.skipIf(NODE is None, "node is required to execute the lifted production JS")
class VersionBadgeSemverTest(unittest.TestCase):
@classmethod
def setUpClass(cls):
cls.formatter = _version_formatter()
def _markup(self, installed, cnr_latest) -> str:
return _render(self.formatter, installed, cnr_latest)
def test_the_badge_follows_numeric_ordering(self):
for installed, latest, expected, why in CASES:
with self.subTest(installed=installed, cnr_latest=latest):
self.assertEqual(self._markup(installed, latest), expected, why)
def test_an_enabled_nodepack_follows_the_server_for_versions_the_helper_cannot_order(self):
for installed, latest, state, update_state, expected, why in UNORDERED_CASES:
with self.subTest(installed=installed, cnr_latest=latest, state=state):
row = {"state": state, "update-state": update_state}
self.assertEqual(_render(self.formatter, installed, latest, **row), expected, why)
@unittest.skipIf(NODE is None, "node is required to execute the lifted production JS")
class CompareVersionSpecsTest(unittest.TestCase):
def _compare(self, a, b):
out = run_node(
"%s\nconsole.log(JSON.stringify({r: compareVersionSpecs(%s, %s)}));"
% (_helper_source(), json.dumps(a), json.dumps(b))
)
return out["r"]
def test_dot_separated_specs_order_numerically(self):
self.assertEqual(self._compare("1.2.10", "1.2.9"), 1)
self.assertEqual(self._compare("1.10.0", "1.9"), 1)
self.assertEqual(self._compare("1.9", "1.10.0"), -1)
self.assertEqual(self._compare("1.47.0", "1.47.0"), 0)
self.assertEqual(self._compare("1.2", "1.2.0"), 0)
def test_non_numeric_specs_return_null(self):
self.assertIsNone(self._compare("nightly", "1.47.0"))
self.assertIsNone(self._compare("1.2.3rc1", "1.47.0"))
self.assertIsNone(self._compare("1.47.0", ""))
if __name__ == "__main__":
unittest.main()