Skip to content

The agent that grows with you

fix(update): respawn a pre-takeover dashboard through the installation-bound launcher

teknium10c397dd6afae
diff --git a/hermes_cli/main_dashboard.py b/hermes_cli/main_dashboard.py
index 1ea281054b0..3d42936fcac 100644
--- a/hermes_cli/main_dashboard.py
+++ b/hermes_cli/main_dashboard.py
@@ -381,26 +381,20 @@ _RESPAWN_LIVENESS_GRACE_SECONDS = 1.0
def _respawnable_command_for_current_install(argv: list[str]) -> list[str]:
- """Collapse a captured ``[interpreter, launcher, ...]`` argv onto the running install.
+ """Rebuild a captured ``[<interpreter>, <hermes launcher>, ...]`` argv on this install's launcher.
A pre-PM-takeover install left ``~/.local/bin/hermes`` as a symlink to a Python console
- script, so the kernel recorded a manual backend as
- ``[<old venv python>, <launcher path>, dashboard, ...]``. The takeover then rewrote that
- launcher into a POSIX shell shim, and replaying the captured argv verbatim asks the old
- interpreter to parse a shell script — the child dies at parse time while the updater
- prints ``✓ restarted`` (#124778). Any ``python <entry>`` pair is rebuilt against the
- ``hermes`` entry of the code that is running now; other shapes replay unchanged.
+ script, so the kernel recorded a manual backend as ``[<old venv python>, <launcher>, dashboard,
+ ...]``. The takeover then rewrote that launcher into a POSIX shell shim, and replaying the
+ captured argv verbatim asks the old interpreter to parse a shell script (#124778). This
+ checkout's own ``hermes`` entry script stays Python, so it and every other shape replay unchanged.
"""
- interpreter_name = os.path.basename(argv[0]) if argv else ""
- if len(argv) <= 2 or not interpreter_name.startswith("python") or argv[1].startswith("-"):
- return list(argv)
- entry = Path(__file__).resolve().parents[1] / "hermes"
- if not entry.is_file():
- return list(argv)
- current_interpreter = sys.executable or argv[0]
- rebuilt = [current_interpreter, str(entry)]
- rebuilt.extend(argv[2:])
- return rebuilt
+ root = Path(__file__).resolve().parents[1]
+ if (len(argv) > 2 and os.path.basename(argv[0]).startswith("python")
+ and os.path.basename(argv[1]) == "hermes" and Path(argv[1]) != root / "hermes"):
+ from hermes_cli._launchers import runtime_command
+ return runtime_command(root, argv[2:])
+ return list(argv)
def _respawn_dashboard_processes(commands: list[list[str]]) -> list[list[str]]:
diff --git a/tests/hermes_cli/test_update_stale_dashboard.py b/tests/hermes_cli/test_update_stale_dashboard.py
index 7c2e7c7e753..0d8118c574f 100644
--- a/tests/hermes_cli/test_update_stale_dashboard.py
+++ b/tests/hermes_cli/test_update_stale_dashboard.py
@@ -523,8 +523,8 @@ class TestManualBackendRespawn:
def test_pre_takeover_interpreter_launcher_argv_is_rebuilt(self, tmp_path, monkeypatch):
"""A kernel-captured ``[old venv python, launcher, ...]`` argv is respawned through
- the running install's interpreter + ``hermes`` entry instead of being replayed
- verbatim after the PM takeover rewrote the launcher into a shell shim (#124778)."""
+ this install's launcher command instead of being replayed verbatim after the PM
+ takeover rewrote the launcher into a shell shim (#124778)."""
live = self._live()
monkeypatch.setenv("HERMES_HOME", str(tmp_path / ".hermes"))
spawned: list[list[str]] = []
@@ -540,14 +540,17 @@ class TestManualBackendRespawn:
"/old/venv/bin/python", "/home/u/.local/bin/hermes",
"dashboard", "--no-open", "--host", "127.0.0.1", "--port", "34553",
]
+ from hermes_cli import _launchers
+ from hermes_cli._launchers import runtime_command
+
with patch.object(live.subprocess, "Popen", _FakePopen), \
- patch.object(live.time, "sleep"):
+ patch.object(live.time, "sleep"), \
+ patch.object(_launchers, "resolve_store_python", return_value=None):
failed = live._respawn_dashboard_processes([captured])
+ expected = runtime_command(Path(live.__file__).resolve().parents[1], captured[2:])
assert failed == []
- entry = Path(live.__file__).resolve().parents[1] / "hermes"
- assert spawned == [[sys.executable, str(entry),
- "dashboard", "--no-open", "--host", "127.0.0.1", "--port", "34553"]]
+ assert spawned == [expected]
def test_child_exiting_within_the_grace_window_is_a_reported_failure(
self, tmp_path, monkeypatch, capsys):