Skip to content

The agent that grows with you

fix(bot-screen): release stranded control through CLI stop

Yags3d6c58622f31
diff --git a/hermes_cli/subcommands/computer_use_screen.py b/hermes_cli/subcommands/computer_use_screen.py
index 5c2dc526063..236c6c3f5a0 100644
--- a/hermes_cli/subcommands/computer_use_screen.py
+++ b/hermes_cli/subcommands/computer_use_screen.py
@@ -46,6 +46,9 @@ def _screen_start(args) -> int:
def _screen_stop(args) -> int:
from tools.bot_desktop import runtime
+ if runtime.is_supported_host():
+ from tools.bot_desktop import lease
+ lease.release()
print("Bot Desktop: stopped" if runtime.stop() else "Bot Desktop: was not running")
return 0
diff --git a/tests/hermes_cli/test_bot_desktop_screen_stop.py b/tests/hermes_cli/test_bot_desktop_screen_stop.py
new file mode 100644
index 00000000000..33f661aed50
--- /dev/null
+++ b/tests/hermes_cli/test_bot_desktop_screen_stop.py
@@ -0,0 +1,19 @@
+"""The documented CLI stop is also recovery for a disconnected viewer's lease."""
+
+import argparse
+
+from hermes_cli.subcommands.computer_use_screen import build_screen_parser
+import pytest
+
+
+def test_screen_stop_hands_back_even_when_the_desktop_has_already_exited():
+ from tools.bot_desktop import lease
+
+ parser = argparse.ArgumentParser()
+ build_screen_parser(parser.add_subparsers(), lambda sub, help_text: sub.add_argument('--json', action='store_true'))
+ lease.acquire('disconnected-viewer')
+ args = parser.parse_args(['screen', 'stop'])
+ assert args.screen_func(args) == 0
+ assert lease.get().holder == lease.AGENT
+ assert lease.wait_for_release(timeout=0)