The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(desktop): rebuild a packaged app whose node-pty has no native binary
brooklyn!ff8c8f023b12
diff --git a/hermes_cli/main_desktop.py b/hermes_cli/main_desktop.pyindex 77eae183b7c..9dd6addecf7 100644--- a/hermes_cli/main_desktop.py+++ b/hermes_cli/main_desktop.py@@ -98,6 +98,22 @@ def _renderer_bundle_torn(dist_dir: Path) -> bool:return False+def _packaged_node_pty_missing(dist_dir: Path) -> bool:+ """True when the packaged node-pty has no native binary for this OS.++ The main process requires node-pty at startup, so such a package dies+ before any window opens while the source stamp still matches (#62462).+ Same places node-pty's loader and stage-native-deps.mjs look. Conservative:+ a package without node-pty at all is not judged here.+ """+ root = dist_dir / "node_modules" / "node-pty"+ if not (root / "package.json").is_file():+ return False++ native_dirs = [root / "build" / "Release", *(root / "prebuilds").glob(f"{sys.platform}-*")]+ return not any(next(d.rglob("*.node"), None) for d in native_dirs if d.is_dir())++def _desktop_build_needed(desktop_dir: Path, project_root: Path, *, source_mode: bool) -> bool:"""True when the desktop build output is stale, missing, torn, or built in the other mode."""if source_mode:@@ -113,6 +129,10 @@ def _desktop_build_needed(desktop_dir: Path, project_root: Path, *, source_mode:print(f" ⚠ A previous update left the desktop bundle incomplete ({dist_dir}); rebuilding it")return True+ if not source_mode and dist_dir is not None and _packaged_node_pty_missing(dist_dir):+ print(" ⚠ The packaged desktop app has no node-pty native binary; rebuilding it")+ return True+return not _stamp_is_current(_desktop_stamp_path(), lambda: _compute_desktop_content_hash(project_root), sourceMode=source_mode)diff --git a/tests/hermes_cli/test_desktop_native_deps_stale.py b/tests/hermes_cli/test_desktop_native_deps_stale.pynew file mode 100644index 00000000000..9513bc8f406--- /dev/null+++ b/tests/hermes_cli/test_desktop_native_deps_stale.py@@ -0,0 +1,52 @@+"""A matching source stamp must not hide a packaged app whose node-pty has no native binary.++Regression for #62462: ``hermes desktop`` reported "content stamp matches" and+launched a package that crashed on ``require('node-pty')``.+"""+import sys++import pytest++from hermes_cli import main_desktop+++def packaged(tmp_path, monkeypatch):+ desktop = tmp_path / "apps/desktop"+ dist = desktop / "release/fixture/resources/app.asar.unpacked/dist"+ pty = dist / "node_modules/node-pty"+ (pty / "lib").mkdir(parents=True)+ (pty / "package.json").write_text('{"main": "lib/index.js"}', encoding="utf-8")+ (dist / "index.html").write_text("<html></html>", encoding="utf-8")+ (tmp_path / ".gitignore").write_text("apps/desktop/release/\n", encoding="utf-8")+ # Executable lookup and the per-OS resources layout are covered natively elsewhere.+ monkeypatch.setattr(main_desktop, "_desktop_packaged_executable", lambda _: dist / "Hermes")+ monkeypatch.setattr(main_desktop, "_renderer_bundle_dir", lambda *_a, **_k: dist)+ main_desktop._write_desktop_build_stamp(tmp_path, source_mode=False)+ return tmp_path, desktop, pty+++def _needed(root, desktop):+ return main_desktop._desktop_build_needed(desktop, root, source_mode=False)++[email protected]("stale", ["prebuilds/{platform}-x64/", "prebuilds/{other}-x64/pty.node"])+def test_current_stamp_does_not_hide_missing_native_binary(packaged, stale):+ root, desktop, pty = packaged+ other = "linux" if sys.platform == "win32" else "win32"+ path = pty / stale.format(platform=sys.platform, other=other)+ if stale.endswith("/"):+ path.mkdir(parents=True)+ else:+ path.parent.mkdir(parents=True)+ path.write_bytes(b"MZ")+ assert _needed(root, desktop)++[email protected]("location", ["build/Release/pty.node", "prebuilds/{platform}-arm64/pty.node"])+def test_package_with_native_binary_stays_current(packaged, location):+ root, desktop, pty = packaged+ binary = pty / location.format(platform=sys.platform)+ binary.parent.mkdir(parents=True)+ binary.write_bytes(b"\x7fELF")+ assert not _needed(root, desktop)