From fc3effe39dfc59d5f93874bcc8808346735797e3 Mon Sep 17 00:00:00 2001 From: chengyongru <61816729+chengyongru@users.noreply.github.com> Date: Wed, 30 Sep 2026 15:40:26 +0800 Subject: [PATCH] fix(cli): avoid duplicate WebUI config announcement (#5988) --- nanobot/cli/webui_support.py | 1 - tests/cli/test_commands.py | 25 +++++++++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/nanobot/cli/webui_support.py b/nanobot/cli/webui_support.py index be18077df..576734439 100644 --- a/nanobot/cli/webui_support.py +++ b/nanobot/cli/webui_support.py @@ -177,7 +177,6 @@ def _resolve_webui_config_path(config: str | None) -> Path: return get_config_path() config_path = Path(config).expanduser().resolve(strict=False) set_config_path(config_path) - console.print(f"[dim]Using config: {config_path}[/dim]") return config_path diff --git a/tests/cli/test_commands.py b/tests/cli/test_commands.py index a8cab903c..ea051693b 100644 --- a/tests/cli/test_commands.py +++ b/tests/cli/test_commands.py @@ -2197,6 +2197,7 @@ def test_webui_yes_creates_config_and_enables_local_websocket( ) assert result.exit_code == 0, result.output + assert result.stdout.count("Using config:") == 1 data = json.loads(config_file.read_text(encoding="utf-8")) websocket = data["channels"]["websocket"] assert websocket["enabled"] is True @@ -2219,6 +2220,30 @@ def test_webui_yes_creates_config_and_enables_local_websocket( assert "stop_timeout" not in seen +@pytest.mark.parametrize("explicit_config", [True, False]) +def test_webui_announces_existing_config_once(monkeypatch, tmp_path: Path, explicit_config: bool) -> None: + from nanobot.config import loader + + config_file = tmp_path / "instance" / "config.json" + config = Config() + config.agents.defaults.workspace = str(tmp_path / "workspace") + loader.save_config(config, config_file) + default_config = tmp_path / "default" / "config.json" if explicit_config else config_file + monkeypatch.setattr(loader, "_current_config_path", default_config) + _patch_webui_provider_ready(monkeypatch) + _patch_gateway_ports_free(monkeypatch) + _patch_webui_managed_gateway(monkeypatch) + + args = ["webui", "--yes", "--no-open"] + if explicit_config: + args.extend(["--config", str(config_file)]) + result = runner.invoke(app, args) + + assert result.exit_code == 0, result.output + assert result.stdout.count("Using config:") == 1 + assert f"Using config: {config_file}" in _without_rendered_line_breaks(result.stdout) + + def test_webui_background_points_to_the_single_persistent_gateway_command( tmp_path: Path, ) -> None: