Your lightweight open-source personal agent.
Python agent-frameworkai-agentai-agentschatbotchatopsdiscord-botllm-agentsllmslocal-llmmcpmodel-context-protocolmulti-agentopenai-compatibleopenclawpersonal-ai-assistantpythonself-hostedtelegram-bot-ai-assistantwebuiworkflow-automation
test(cli): isolate WebUI interrupt polling
Xubin Rene84aa07bcc3d
diff --git a/nanobot/cli/webui_support.py b/nanobot/cli/webui_support.pyindex 331791bb7..9edf8b9b2 100644--- a/nanobot/cli/webui_support.py+++ b/nanobot/cli/webui_support.py@@ -443,6 +443,7 @@ def _attach_to_background_gateway(runtime: "GatewayRuntime",*,poll_hook: Callable[[], None] | None = None,+ sleep: Callable[[float], None] = time.sleep,) -> None:"""Keep a WebUI launcher attached without taking ownership of the gateway."""_print_webui_foreground_lifecycle(attached=True)@@ -450,7 +451,7 @@ def _attach_to_background_gateway(while runtime.status().running:if poll_hook is not None:poll_hook()- time.sleep(0.5)+ sleep(0.5)except KeyboardInterrupt:console.print("\n[yellow]WebUI launcher detached.[/yellow]")returndiff --git a/tests/cli/test_commands.py b/tests/cli/test_commands.pyindex ced9f62ed..b638b2440 100644--- a/tests/cli/test_commands.py+++ b/tests/cli/test_commands.py@@ -2565,7 +2565,7 @@ def test_webui_foreground_attaches_to_existing_managed_gateway(monkeypatch, tmp_assert seen["open_kwargs"] == {"wait": False}-def test_attach_to_background_gateway_detaches_on_ctrl_c(monkeypatch, capsys) -> None:+def test_attach_to_background_gateway_detaches_on_ctrl_c(capsys) -> None:stopped = Falseclass _FakeRuntime:@@ -2580,9 +2580,7 @@ def test_attach_to_background_gateway_detaches_on_ctrl_c(monkeypatch, capsys) ->def _interrupt(_seconds: float) -> None:raise KeyboardInterrupt- monkeypatch.setattr("nanobot.cli.webui_support.time.sleep", _interrupt)-- cli_webui_support._attach_to_background_gateway(_FakeRuntime())+ cli_webui_support._attach_to_background_gateway(_FakeRuntime(), sleep=_interrupt)assert stopped is Falseoutput = capsys.readouterr().out