The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(bot-screen): profile rename/delete teardown resets a stale human lease
teknium1b74d2d571776
diff --git a/hermes_cli/profiles.py b/hermes_cli/profiles.pyindex fd0e7f027e1..33699a0698d 100644--- a/hermes_cli/profiles.py+++ b/hermes_cli/profiles.py@@ -1089,6 +1089,11 @@ def _stop_bot_desktop(profile_dir: Path) -> None:try:if runtime.stop():print("✓ Bot Desktop stopped")+ # The screen a human's exclusion protected is gone; on rename the directory (lease.json+ # included) moves with the profile, and a human lease for a dead viewer would fence the+ # agent out of the renamed profile's next screen until someone force-released it.+ from tools.bot_desktop import lease+ lease.release()except Exception as e:logger.warning("Could not stop the Bot Desktop of %s: %s", profile_dir, e)finally:diff --git a/tests/hermes_cli/test_profiles.py b/tests/hermes_cli/test_profiles.pyindex fc8e82edead..10523357a78 100644--- a/tests/hermes_cli/test_profiles.py+++ b/tests/hermes_cli/test_profiles.py@@ -1207,6 +1207,10 @@ def test_profile_delete_and_rename_stop_the_profiles_bot_desktop(profile_env, opprofile_dir = create_profile("coder", no_alias=True)proc = _live_bot_desktop_launcher(profile_dir)+ # A human held the screen when the op ran. lease.json moves with a rename; left human-held it would+ # fence the agent out of the renamed profile's next screen for a viewer that no longer exists.+ (profile_dir / "bot-desktop" / "lease.json").write_text(+ json.dumps({"holder": "human", "viewer_id": "gone", "since": 1.0, "epoch": 3, "reason": ""}), encoding="utf-8")try:with patch("hermes_cli.profiles._cleanup_gateway_service"), \patch("hermes_cli.profiles.check_alias_collision", return_value="skip"):@@ -1220,6 +1224,9 @@ def test_profile_delete_and_rename_stop_the_profiles_bot_desktop(profile_env, opwhile time.monotonic() < deadline and runtime._pid_alive(proc.pid):time.sleep(0.05)assert not runtime._pid_alive(proc.pid), "the launcher was not stopped by the profile op"+ if op == "rename":+ moved = json.loads((profile_dir.parent / "hacker" / "bot-desktop" / "lease.json").read_text(encoding="utf-8"))+ assert moved["holder"] == "agent", "stale human lease survived the teardown"finally:proc.kill()