Skip to content

The agent that grows with you

fix(bot-screen): --clone-all leaves the source's screen identity behind

teknium140e601930a95
diff --git a/hermes_cli/profiles.py b/hermes_cli/profiles.py
index 9bc33608c05..fd0e7f027e1 100644
--- a/hermes_cli/profiles.py
+++ b/hermes_cli/profiles.py
@@ -36,7 +36,14 @@ _CLONE_SUBDIR_FILES = ["memories/MEMORY.md", "memories/USER.md"]
# Runtime files stripped after --clone-all. A post-copy step rather than an ignore filter
# because they are created dynamically and may be absent at copy time.
-_CLONE_ALL_STRIP: list[str] = ["gateway.pid", "gateway_state.json", "processes.json"]
+_CLONE_ALL_STRIP: list[str] = [
+ "gateway.pid", "gateway_state.json", "processes.json",
+ # Bot Desktop runtime identity: pid + create_time of the SOURCE's launcher, its DISPLAY/XAUTHORITY and
+ # lease. Copied verbatim, `screen stop` on the clone would kill the source's X server. The persistent
+ # browser profile beside them is user data and stays.
+ "bot-desktop/launcher.pid", "bot-desktop/env", "bot-desktop/rfb.sock",
+ "bot-desktop/lease.json", "bot-desktop/lease.lock",
+]
# Infrastructure excluded from --clone-all ONLY when the source is the default profile
# (``~/.hermes``): git checkout (+ ~3 GB venv), worktrees, sibling profiles, shared bins,
diff --git a/tests/hermes_cli/test_profiles.py b/tests/hermes_cli/test_profiles.py
index 3ac037a683a..4fbef4a10a0 100644
--- a/tests/hermes_cli/test_profiles.py
+++ b/tests/hermes_cli/test_profiles.py
@@ -205,6 +205,25 @@ class TestCreateProfile:
assert not any((profile_dir / "cron").iterdir())
assert yaml.safe_load((profile_dir / "config.yaml").read_text())["model"] == "test"
+ def test_clone_all_does_not_inherit_the_source_screens_identity(self, profile_env):
+ """launcher.pid / env / lease name the SOURCE's live X server; a clone that inherits them believes it
+ owns that screen and `screen stop` on the clone kills the source's desktop. The browser profile
+ beside them is user data (logins) and must come along."""
+ default_home = profile_env / ".hermes"
+ (default_home / "config.yaml").write_text("model: test")
+ bd = default_home / "bot-desktop"
+ (bd / "browser-profile" / "Default").mkdir(parents=True)
+ (bd / "browser-profile" / "Default" / "Cookies").write_text("jar")
+ (bd / "launcher.pid").write_text("4242 1.5")
+ (bd / "env").write_text("DISPLAY=:21\nXAUTHORITY=/x\n")
+ (bd / "lease.json").write_text(json.dumps({"holder": "human", "viewer_id": "v", "epoch": 3}))
+
+ profile_dir = create_profile("coder", clone_all=True, no_alias=True)
+
+ for runtime_file in ("launcher.pid", "env", "lease.json"):
+ assert not (profile_dir / "bot-desktop" / runtime_file).exists(), runtime_file
+ assert (profile_dir / "bot-desktop" / "browser-profile" / "Default" / "Cookies").read_text() == "jar"
+