The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(desktop): never stop the Desktop that drives this update on POSIX
ethernetcc226721263c
diff --git a/hermes_cli/main_desktop.py b/hermes_cli/main_desktop.pyindex 3f537063532..d74b4eca2f4 100644--- a/hermes_cli/main_desktop.py+++ b/hermes_cli/main_desktop.py@@ -428,6 +428,19 @@ def _stop_desktop_processes_locking_build(desktop_dir: Path, *, also_posix: boolreturn []me = os.getpid()+ # On POSIX, never stop a Desktop that is one of OUR ancestors. A+ # historical Desktop (v2026.7.1 Linux in-app update) runs `hermes update`+ # as a child with piped stdout/stderr and owns the post-update rebuild and+ # relaunch. Killing it breaks those pipes (EPIPE fails the update) and+ # leaves nobody to relaunch. It also outlives the swap safely because it+ # relaunches itself afterwards. Windows keeps stopping it: there, the exe+ # lock would make the rename fail anyway.+ spared: set[int] = set()+ if sys.platform != "win32":+ try:+ spared = {parent.pid for parent in psutil.Process(me).parents()}+ except Exception:+ spared = set()victims = []try:proc_iter = psutil.process_iter(["pid", "exe"])@@ -438,7 +451,7 @@ def _stop_desktop_processes_locking_build(desktop_dir: Path, *, also_posix: boolinfo = proc.infopid = info.get("pid")exe = info.get("exe")- if not exe or pid is None or pid == me:+ if not exe or pid is None or pid == me or pid in spared:continueexe_path = Path(exe).resolve()except Exception:diff --git a/tests/hermes_cli/test_gui_command.py b/tests/hermes_cli/test_gui_command.pyindex 9e725a223f2..88b3758911e 100644--- a/tests/hermes_cli/test_gui_command.py+++ b/tests/hermes_cli/test_gui_command.py@@ -7,6 +7,7 @@ import osimport subprocessimport sysimport time+import typesfrom pathlib import Pathfrom unittest.mock import patch@@ -1092,6 +1093,47 @@ def test_stop_desktop_processes_locking_build_posix_swap_bypasses_early_return(tassert main_desktop._stop_desktop_processes_locking_build(desktop_dir, also_posix=True) == [100][email protected]("posix") # Windows must stop the exe-locking ancestor too+def test_posix_swap_spares_the_desktop_driving_this_update(tmp_path, monkeypatch):+ """A historical Desktop runs `hermes update` as a piped child and relaunches+ itself afterwards; stopping it breaks the update's stdout (EPIPE). Only an+ unrelated Desktop from the same release tree is stopped."""+ root = _make_desktop_tree(tmp_path)+ desktop_dir = root / "apps" / "desktop"+ live_exe = desktop_dir / "release" / _packaged_exe_rel()+ live_exe.parent.mkdir(parents=True)+ live_exe.write_text("old", encoding="utf-8")++ class _FakeProc:+ def __init__(self, pid, exe):+ self.info = {"pid": pid, "exe": exe}+ self.pid = pid++ def terminate(self):+ return None++ driver = _FakeProc(100, str(live_exe))+ other = _FakeProc(300, str(live_exe))++ class _FakePsutil:+ @staticmethod+ def Process(pid):+ assert pid == os.getpid()+ return types.SimpleNamespace(parents=lambda: [driver])++ @staticmethod+ def process_iter(attrs):+ return [driver, other]++ @staticmethod+ def wait_procs(victims, timeout=5):+ return [], []++ monkeypatch.setitem(sys.modules, "psutil", _FakePsutil)++ assert main_desktop._stop_desktop_processes_locking_build(desktop_dir, also_posix=True) == [300]++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."""