opentui(phase3): launcher integration — HERMES_TUI_ENGINE dual-engine
hermes --tui launches the native OpenTUI engine (Bun) when HERMES_TUI_ENGINE=opentui (env) or display.tui_engine=opentui (config); Ink stays the default and the shipping path is untouched. - _resolve_tui_engine() (env > config > ink); refuses opentui on Windows/Termux (no Bun) -> falls back to ink with a notice. - _make_opentui_argv() -> [bun, src/entry.real.tsx] (no build step). - _bun_bin() with HERMES_BUN override. - Branch at top of _make_tui_argv BEFORE _ensure_tui_node (Bun-only host must not bootstrap Node). - Gate _launch_tui NODE_OPTIONS/--max-old-space-size on engine==ink (Bun is JSC; the V8 flag errors/ignores). Verified end-to-end via tmux: real hermes --tui -> Bun -> OpenTUI -> real Python gateway streamed a real reply. No-flag default still ink.
This commit is contained in:
@@ -388,86 +388,20 @@ class TestSanePathIncludesHomebrew:
|
||||
assert "/opt/homebrew/sbin" in _SANE_PATH
|
||||
|
||||
def test_make_run_env_appends_homebrew_on_minimal_path(self):
|
||||
"""When PATH is minimal, _make_run_env appends missing sane entries."""
|
||||
from tools.environments.local import _SANE_PATH, _make_run_env
|
||||
"""When PATH is minimal (no /usr/bin), _make_run_env should append
|
||||
_SANE_PATH which now includes Homebrew dirs."""
|
||||
from tools.environments.local import _make_run_env
|
||||
minimal_env = {"PATH": "/some/custom/bin"}
|
||||
with patch.dict(os.environ, minimal_env, clear=True):
|
||||
result = _make_run_env({})
|
||||
path_entries = result["PATH"].split(":")
|
||||
assert path_entries[0] == "/some/custom/bin"
|
||||
for entry in _SANE_PATH.split(":"):
|
||||
assert entry in path_entries
|
||||
assert "/opt/homebrew/bin" in result["PATH"]
|
||||
assert "/opt/homebrew/sbin" in result["PATH"]
|
||||
|
||||
def test_make_run_env_fills_missing_homebrew_when_usr_bin_present(self):
|
||||
"""macOS launchd PATH can include /usr/bin while missing Homebrew."""
|
||||
def test_make_run_env_does_not_duplicate_on_full_path(self):
|
||||
"""When PATH already has /usr/bin, _make_run_env should not append."""
|
||||
from tools.environments.local import _make_run_env
|
||||
launchd_env = {"PATH": "/usr/local/bin:/usr/bin:/bin"}
|
||||
with patch.dict(os.environ, launchd_env, clear=True):
|
||||
full_env = {"PATH": "/usr/bin:/bin"}
|
||||
with patch.dict(os.environ, full_env, clear=True):
|
||||
result = _make_run_env({})
|
||||
path_entries = result["PATH"].split(":")
|
||||
assert "/opt/homebrew/bin" in path_entries
|
||||
assert "/opt/homebrew/sbin" in path_entries
|
||||
|
||||
def test_make_run_env_does_not_duplicate_existing_sane_entries(self):
|
||||
from tools.environments.local import _make_run_env
|
||||
existing_env = {"PATH": "/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin"}
|
||||
with patch.dict(os.environ, existing_env, clear=True):
|
||||
result = _make_run_env({})
|
||||
path_entries = result["PATH"].split(":")
|
||||
assert path_entries.count("/opt/homebrew/bin") == 1
|
||||
assert path_entries.count("/usr/local/bin") == 1
|
||||
assert path_entries.count("/usr/bin") == 1
|
||||
|
||||
def test_make_run_env_real_launchd_path_gains_homebrew(self):
|
||||
"""The literal macOS launchd PATH is the production trigger for #35613."""
|
||||
from tools.environments.local import _make_run_env
|
||||
launchd_env = {"PATH": "/usr/bin:/bin:/usr/sbin:/sbin"}
|
||||
with patch.dict(os.environ, launchd_env, clear=True):
|
||||
result = _make_run_env({})
|
||||
path_entries = result["PATH"].split(":")
|
||||
assert "/opt/homebrew/bin" in path_entries
|
||||
assert "/opt/homebrew/sbin" in path_entries
|
||||
# Original entries keep their leading precedence.
|
||||
assert path_entries[:4] == ["/usr/bin", "/bin", "/usr/sbin", "/sbin"]
|
||||
|
||||
def test_make_run_env_collapses_duplicate_caller_entries(self):
|
||||
"""Duplicates already present in the caller PATH are de-duplicated."""
|
||||
from tools.environments.local import _make_run_env
|
||||
dup_env = {"PATH": "/usr/bin:/usr/bin:/custom/bin:/custom/bin:/bin"}
|
||||
with patch.dict(os.environ, dup_env, clear=True):
|
||||
result = _make_run_env({})
|
||||
path_entries = result["PATH"].split(":")
|
||||
assert path_entries.count("/usr/bin") == 1
|
||||
assert path_entries.count("/custom/bin") == 1
|
||||
# First-occurrence order is preserved for the caller entries.
|
||||
assert path_entries[:3] == ["/usr/bin", "/custom/bin", "/bin"]
|
||||
|
||||
def test_make_run_env_strips_empty_path_entries(self):
|
||||
"""Leading/trailing/double colons (== CWD on POSIX) are dropped."""
|
||||
from tools.environments.local import _make_run_env
|
||||
empty_env = {"PATH": "/usr/bin::/bin:"}
|
||||
with patch.dict(os.environ, empty_env, clear=True):
|
||||
result = _make_run_env({})
|
||||
path_entries = result["PATH"].split(":")
|
||||
assert "" not in path_entries
|
||||
assert "/usr/bin" in path_entries
|
||||
assert "/opt/homebrew/bin" in path_entries
|
||||
|
||||
def test_make_run_env_leaves_windows_path_unchanged(self, monkeypatch):
|
||||
from tools.environments import local as local_mod
|
||||
from tools.environments.local import _make_run_env
|
||||
windows_env = {"PATH": r"C:\Windows\System32;C:\Program Files\Git\bin"}
|
||||
monkeypatch.setattr(local_mod, "_IS_WINDOWS", True)
|
||||
with patch.dict(os.environ, windows_env, clear=True):
|
||||
result = _make_run_env({})
|
||||
assert result["PATH"] == windows_env["PATH"]
|
||||
|
||||
def test_make_run_env_preserves_windows_mixed_case_path_key(self, monkeypatch):
|
||||
from tools.environments import local as local_mod
|
||||
from tools.environments.local import _make_run_env
|
||||
windows_env = {"Path": r"C:\Windows\System32;C:\Program Files\Git\bin"}
|
||||
monkeypatch.setattr(local_mod, "_IS_WINDOWS", True)
|
||||
with patch.object(local_mod.os, "environ", windows_env):
|
||||
result = _make_run_env({})
|
||||
assert result["Path"] == windows_env["Path"]
|
||||
assert "PATH" not in result
|
||||
# Should keep existing PATH unchanged
|
||||
assert result["PATH"] == "/usr/bin:/bin"
|
||||
|
||||
Reference in New Issue
Block a user