Skip to content

The agent that grows with you

fix(desktop): the skip notice names the in-app update, and hermes desktop reopens the app it kept

John Paul Solivac9ccdb967d39
diff --git a/hermes_cli/main_desktop.py b/hermes_cli/main_desktop.py
index 9453fa2c464..79bc0b3e873 100644
--- a/hermes_cli/main_desktop.py
+++ b/hermes_cli/main_desktop.py
@@ -1356,10 +1356,10 @@ def build_prepared_desktop(desktop_dir: Path, *, source_mode: bool, npm: str, en
# and stopping it would kill this process first (#123499). Packing would only
# produce a build that cannot be installed; leave the app as it is. Its content
# stamp stays stale, so `hermes desktop` run outside the app rebuilds it
- # (_desktop_build_needed).
+ # (_desktop_build_needed), and the in-app update completes with desktop=True.
print(f" ⚠ Skipped rebuilding the desktop app: this update is running inside it (pid {ancestor}),")
- print(" and Windows locks a running app's files. Quit Hermes Desktop, then run")
- print(" `hermes desktop` from a terminal to rebuild and reopen it.")
+ print(" and Windows locks a running app's files. Quit Hermes Desktop and run `hermes desktop`")
+ print(" from a terminal, or use Update now in Settings → About, to rebuild and reopen it.")
return None
build_label = "source build" if source_mode else "packaged app"
build_env = dict(env)
@@ -1604,7 +1604,8 @@ def cmd_gui(args: argparse.Namespace):
explicit=force_build or getattr(args, "build_only", False))
built = build_prepared_desktop(desktop_dir, source_mode=source_mode, npm=npm, env=build_env)
if not source_mode:
- packaged_executable = built
+ # None only when the build was skipped under its own Desktop: reopen the app it kept.
+ packaged_executable = built or packaged_executable
else:
build_label = "source build" if source_mode else "packaged app"
desktop_launch_notice(f"✓ Desktop {build_label} is up to date (content stamp matches)", source_mode=source_mode)
diff --git a/tests/hermes_cli/test_gui_command.py b/tests/hermes_cli/test_gui_command.py
index 5f22d39d6dd..8bc35970d35 100644
--- a/tests/hermes_cli/test_gui_command.py
+++ b/tests/hermes_cli/test_gui_command.py
@@ -1456,66 +1456,28 @@ def test_the_stop_spares_the_desktop_driving_this_update(tmp_path, monkeypatch,
assert main_desktop._stop_desktop_processes_locking_build(desktop_dir, also_posix=also_posix) == [300]
-def _ancestry(monkeypatch, *parents):
- """Install a fake psutil whose view of this process's ancestors is *parents* (outermost last)."""
- monkeypatch.setitem(sys.modules, "psutil", types.SimpleNamespace(
- Process=lambda pid: types.SimpleNamespace(parents=lambda: list(parents))))
-
-
-def _proc(pid, exe):
- return types.SimpleNamespace(pid=pid, exe=lambda: exe)
-
-
-def test_desktop_ancestor_names_only_a_desktop_from_this_release_tree(tmp_path, monkeypatch):
- desktop_dir = _make_desktop_tree(tmp_path) / "apps" / "desktop"
- live_exe = desktop_dir / "release" / _packaged_exe_rel()
- live_exe.parent.mkdir(parents=True)
- live_exe.write_text("old", encoding="utf-8")
- elsewhere = tmp_path / "other" / "Hermes.exe"
-
- _ancestry(monkeypatch, _proc(40, str(tmp_path / "python.exe")), _proc(41, str(live_exe)))
- assert main_desktop._desktop_ancestor_in(desktop_dir) == 41
- _ancestry(monkeypatch, _proc(40, str(tmp_path / "python.exe")), _proc(42, str(elsewhere)))
- assert main_desktop._desktop_ancestor_in(desktop_dir) is None
-
-
def test_windows_build_under_its_own_desktop_skips_instead_of_killing_it(tmp_path, monkeypatch, capsys):
"""#123499: a Desktop's backend runs the interrupted-update tail at launch. Packing there
can only end in a promotion the Desktop's exe lock refuses, and stopping that Desktop
kills the tail first. The build is skipped, so the tail finishes and clears its markers."""
monkeypatch.setattr(main_desktop.sys, "platform", "win32")
desktop_dir = _make_desktop_tree(tmp_path) / "apps" / "desktop"
- monkeypatch.setattr(main_desktop, "_desktop_ancestor_in", lambda d: 4242)
+ live_exe = desktop_dir / "release" / _packaged_exe_rel()
+ live_exe.parent.mkdir(parents=True)
+ live_exe.write_text("old", encoding="utf-8")
+ backend = types.SimpleNamespace(pid=40, exe=lambda: str(tmp_path / "python.exe"))
+ desktop = types.SimpleNamespace(pid=41, exe=lambda: str(live_exe))
+ monkeypatch.setitem(sys.modules, "psutil", types.SimpleNamespace(
+ Process=lambda pid: types.SimpleNamespace(parents=lambda: [backend, desktop])))
monkeypatch.setattr(main_desktop, "_stop_desktop_processes_locking_build",
lambda *a, **k: pytest.fail("must not stop the Desktop running this build"))
monkeypatch.setattr("pm.progress.run_contained", lambda *a, **k: pytest.fail("must not pack"))
assert main_desktop.build_prepared_desktop(desktop_dir, source_mode=False, npm="npm", env={}) is None
- assert "Skipped rebuilding the desktop app" in capsys.readouterr().out
+ assert "pid 41" in capsys.readouterr().out
assert not list(desktop_dir.glob(f"{main_desktop._DESKTOP_STAGING_PREFIX}*"))
[email protected]("host, source_mode", [("linux", False), ("win32", True)])
-def test_the_skip_is_only_for_a_windows_packaged_build(tmp_path, monkeypatch, host, source_mode):
- """POSIX can rename a running app away and the Desktop relaunches itself, and a
- source build never touches release/: both still build under a Desktop ancestor."""
- monkeypatch.setattr(main_desktop.sys, "platform", host)
- desktop_dir = _make_desktop_tree(tmp_path) / "apps" / "desktop"
- monkeypatch.setattr(main_desktop, "_desktop_ancestor_in", lambda d: 4242)
- monkeypatch.setattr(main_desktop, "_stop_desktop_processes_locking_build", lambda *a, **k: [])
- monkeypatch.setattr("pm.ensure", lambda tool, base_env: types.SimpleNamespace(env=base_env))
-
- class _Packed(Exception):
- pass
-
- def _run(*a, **k):
- raise _Packed
-
- monkeypatch.setattr("pm.progress.run_contained", _run)
- with pytest.raises(_Packed):
- main_desktop.build_prepared_desktop(desktop_dir, source_mode=source_mode, npm="npm", env={})
-
-
def test_gui_failed_pack_leaves_previous_app_untouched(tmp_path, monkeypatch, capsys):
"""Every pack attempt fails → the pre-existing app is exactly as it was,
no staging dir remains, exit is non-zero."""
diff --git a/website/docs/getting-started/updating.md b/website/docs/getting-started/updating.md
index 10f10a66560..bef23da2630 100644
--- a/website/docs/getting-started/updating.md
+++ b/website/docs/getting-started/updating.md
@@ -138,7 +138,7 @@ For an admitted source checkout, `hermes update` runs these phases:
3. **Post-pull syntax validation + auto-rollback** — after the pull, Hermes compiles the nine critical files every `hermes` invocation imports at startup. If any fails to parse (e.g. an orphan merge-conflict marker, an accidentally truncated file), Hermes runs `git reset --hard <pre-pull-sha>` to roll the install back so your shell stays bootable. Re-run `hermes update` once the upstream fix lands.
4. **Dependency preparation** — PM provisions required tools and prepares a complete Python environment from the new lock, existing extras, and enabled plugin requirements. It validates that environment before publishing its selection. A plugin never fails the update. A plugin that no longer fits the new core is added to `plugins.disabled` in every profile that enables it (a memory provider has `memory.provider` cleared). That covers a `requires-python` that excludes Hermes's Python, a `manifest_version` newer than this Hermes supports, and dependencies that the resolver proves can't resolve alongside core and earlier plugins in config order, or that fail their own build. A download or network failure gets one retry and is disabled if it fails again. The update prints `⚠ Disabled plugin '<name>' in <home>: <reason>`, records it in the receipt's warnings, and continues. Re-enable it with `hermes plugins enable <name>` once the plugin ships a compatible release, or once the network is back. A `requires_hermes` range the running version misses never disables a plugin, because a source checkout without release tags can read as an older release. That plugin sits out instead (`⚠ Left plugin '<name>' … out of this update`), stays enabled, and rejoins once Hermes reports a version it accepts. A secondary profile whose config cannot be read sits out the same way until the config is fixed. Only a core that cannot build on its own fails this step.
5. **Config migration** — detects new config options added since your version and prompts you to set them
-6. **Desktop rebuild (stage-and-swap)** — if the Hermes Desktop app was built from this checkout, it is rebuilt so the GUI matches the new code. The rebuild packs into a temporary staging directory next to `apps/desktop/release/`, verifies the staged app, and only then renames it over the previous build (on Windows a real-time scanner briefly holding `release/win-unpacked` is ridden out with a few short retries). A rebuild that fails at any point — corrupt Electron download, missing dependency, disk full — leaves the previous app untouched and launchable; the update fails at that step, and `hermes desktop --build-only --force-build` or the next `hermes update` retries the rebuild. On macOS the rebuilt bundle is then copied (with `ditto`, signature intact) over a stale `/Applications/Hermes.app` or `~/Applications/Hermes.app`, so the copy Finder and the Dock launch matches the backend; an installed copy that is currently running is left alone and the update tells you to quit it and run `hermes update` again. On Windows, when the update finishes from inside the Desktop app it would rebuild (the app completing an interrupted update at launch), the rebuild is skipped with a notice instead: Windows locks a running app's files, and stopping the app would end the update with it. The rest of the update completes; quit Hermes Desktop and run `hermes desktop` from a terminal to rebuild and reopen it.
+6. **Desktop rebuild (stage-and-swap)** — if the Hermes Desktop app was built from this checkout, it is rebuilt so the GUI matches the new code. The rebuild packs into a temporary staging directory next to `apps/desktop/release/`, verifies the staged app, and only then renames it over the previous build (on Windows a real-time scanner briefly holding `release/win-unpacked` is ridden out with a few short retries). A rebuild that fails at any point — corrupt Electron download, missing dependency, disk full — leaves the previous app untouched and launchable; the update fails at that step, and `hermes desktop --build-only --force-build` or the next `hermes update` retries the rebuild. On macOS the rebuilt bundle is then copied (with `ditto`, signature intact) over a stale `/Applications/Hermes.app` or `~/Applications/Hermes.app`, so the copy Finder and the Dock launch matches the backend; an installed copy that is currently running is left alone and the update tells you to quit it and run `hermes update` again. On Windows, when the update finishes from inside the Desktop app it would rebuild (the app completing an interrupted update at launch), the rebuild is skipped with a notice instead: Windows locks a running app's files, and stopping the app would end the update with it. The rest of the update completes; quit Hermes Desktop and run `hermes desktop` from a terminal, or use **Update now** in **Settings → About**, to rebuild and reopen it.
7. **Gateway auto-restart**: running gateways are refreshed after the update completes. Service-managed gateways (systemd on Linux, launchd on macOS) restart through the service manager. Manual gateways are relaunched when Hermes can map their PID to a profile. Manually launched `hermes serve` / `hermes dashboard` backends are different: the updater leaves them running and asks their owner to restart them. See [Manual backend restart reminders](#manual-backend-restart-reminders). Backends owned by a running Desktop app remain the app's responsibility.
8. **Multiplex migration (multi-profile installs)** — once the fleet is verified on the new code, an install with two or more profiles that still run **one gateway per profile** is folded into a single multiplexed default gateway when nothing blocks it (same as `hermes gateway migrate --multiplex --yes`); if a blocker exists (a bot token shared by two profiles, a secondary profile binding a port with no `/p/<profile>/` ingress) the update prints the blockers with their fixes and changes nothing. Single-profile installs are never touched. See [Migrating from per-profile gateways](../user-guide/multi-profile-gateways.md#migrating-from-per-profile-gateways).