Skip to content

Your lightweight open-source personal agent.

fix(webui): resolve build runner executable

chengyongrue3de01c9f61d
diff --git a/nanobot/webui/build.py b/nanobot/webui/build.py
index 950cf1f0b..6c53afc6c 100644
--- a/nanobot/webui/build.py
+++ b/nanobot/webui/build.py
@@ -266,8 +266,8 @@ def ensure_webui_bundle(
def pick_webui_build_runner() -> str | None:
"""Pick the frontend package manager used to build the WebUI."""
for candidate in ("bun", "npm"):
- if shutil.which(candidate):
- return candidate
+ if executable := shutil.which(candidate):
+ return executable
return None
diff --git a/tests/webui/test_build.py b/tests/webui/test_build.py
index 5b70d17b8..ff811ca1c 100644
--- a/tests/webui/test_build.py
+++ b/tests/webui/test_build.py
@@ -4,7 +4,11 @@ import os
import tomllib
from pathlib import Path
-from nanobot.webui.build import ensure_webui_bundle, inspect_webui_bundle
+from nanobot.webui.build import (
+ ensure_webui_bundle,
+ inspect_webui_bundle,
+ pick_webui_build_runner,
+)
_MTIME_BASE_NS = 1_700_000_000_000_000_000
_MTIME_STEP_NS = 5_000_000_000
@@ -119,6 +123,17 @@ def test_ensure_webui_bundle_auto_builds_stale_dist(tmp_path: Path) -> None:
assert commands == [("bun", "install"), ("bun", "run", "build")]
+def test_pick_webui_build_runner_returns_resolved_executable(monkeypatch) -> None:
+ bun_shim = r"C:\tools\npm\bun.CMD"
+
+ monkeypatch.setattr(
+ "nanobot.webui.build.shutil.which",
+ lambda candidate: bun_shim if candidate == "bun" else None,
+ )
+
+ assert pick_webui_build_runner() == bun_shim
+
+
def test_ensure_webui_bundle_warns_without_building(tmp_path: Path) -> None:
source = tmp_path / "webui"
dist = tmp_path / "nanobot" / "web" / "dist"