fix(cli): avoid duplicate WebUI config announcement (#5988)
This commit is contained in:
1 parent
e2b89d45bf
commit
fc3effe39d
2 files changed
+25
-1
No files matched your search
@@ -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
|
||||
|
||||
|
||||
|
||||
@@ -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:
|
||||
|
||||
Reference in new issue
Block a user