fix(cli): keep macOS bootstrap URLs out of argv [skip ci]

Browser bootstrap URLs contain credentials. Deliver them through native Launch Services instead of the open command, and fail without a subprocess or BROWSER fallback so shared WebUI callers cannot expose the URL in process arguments or errors.

Cover encoding, native failures, resource cleanup and Desktop dispatch with regression tests. Preserve existing browser behavior and leave TUI and non-macOS handoff changes outside this scoped repair.
This commit is contained in:
Xubin Ren committed 2026-09-08 10:04:15 +08:00
1 parent dba77b5e74
commit 29bf9f9ca7
4 files changed
+150 -15

No files matched your search

+6 -6
View File
@@ -2564,17 +2564,17 @@ def test_open_webui_browser_reports_launch_failure(monkeypatch, capsys) -> None:
)
def test_launch_browser_uses_macos_foreground_opener(monkeypatch) -> None:
seen: list[list[str]] = []
def test_launch_browser_uses_macos_url_services(monkeypatch) -> None:
seen: list[str] = []
monkeypatch.setattr(cli_webui_support.sys, "platform", "darwin")
monkeypatch.setattr(
cli_webui_support.subprocess,
"run",
lambda command, **_kwargs: seen.append(command) or SimpleNamespace(returncode=0),
cli_webui_support,
"_launch_macos_browser",
lambda url: seen.append(url) or True,
)
assert cli_webui_support._launch_browser("http://127.0.0.1:8765/") is True
assert seen == [["open", "http://127.0.0.1:8765/"]]
assert seen == ["http://127.0.0.1:8765/"]
def test_launch_browser_uses_default_browser_off_macos(monkeypatch) -> None: