From 0738b80833c12eb6127caa97279a5db83e0f7b54 Mon Sep 17 00:00:00 2001 From: helix4u <4317663+helix4u@users.noreply.github.com> Date: Fri, 24 Apr 2026 15:51:38 -0600 Subject: [PATCH] fix(tui): rebuild when ink bundle is missing --- hermes_cli/main.py | 2 ++ tests/hermes_cli/test_tui_npm_install.py | 28 ++++++++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/hermes_cli/main.py b/hermes_cli/main.py index 7de68d2cb4..ca229c99c5 100644 --- a/hermes_cli/main.py +++ b/hermes_cli/main.py @@ -839,6 +839,8 @@ def _find_bundled_tui(tui_dir: Path) -> Optional[Path]: def _tui_build_needed(tui_dir: Path) -> bool: + if _hermes_ink_bundle_stale(tui_dir): + return True entry = tui_dir / "dist" / "entry.js" if not entry.exists(): return True diff --git a/tests/hermes_cli/test_tui_npm_install.py b/tests/hermes_cli/test_tui_npm_install.py index 3f3191ccf3..bceaf9de0b 100644 --- a/tests/hermes_cli/test_tui_npm_install.py +++ b/tests/hermes_cli/test_tui_npm_install.py @@ -19,6 +19,18 @@ def _touch_ink(root: Path) -> None: ink.write_text("{}") +def _touch_tui_entry(root: Path) -> None: + entry = root / "dist" / "entry.js" + entry.parent.mkdir(parents=True, exist_ok=True) + entry.write_text("console.log('tui')") + + +def _touch_ink_bundle(root: Path) -> None: + bundle = root / "packages" / "hermes-ink" / "dist" / "ink-bundle.js" + bundle.parent.mkdir(parents=True, exist_ok=True) + bundle.write_text("export {}") + + def test_need_install_when_ink_missing(tmp_path: Path, main_mod) -> None: (tmp_path / "package-lock.json").write_text("{}") assert main_mod._tui_need_npm_install(tmp_path) is True @@ -51,3 +63,19 @@ def test_need_install_when_marker_missing(tmp_path: Path, main_mod) -> None: def test_no_install_without_lockfile_when_ink_present(tmp_path: Path, main_mod) -> None: _touch_ink(tmp_path) assert main_mod._tui_need_npm_install(tmp_path) is False + + +def test_build_needed_when_local_ink_bundle_missing(tmp_path: Path, main_mod) -> None: + _touch_tui_entry(tmp_path) + _touch_ink(tmp_path) + + assert main_mod._tui_need_npm_install(tmp_path) is False + assert main_mod._tui_build_needed(tmp_path) is True + + +def test_build_not_needed_when_entry_and_ink_bundle_present(tmp_path: Path, main_mod) -> None: + _touch_tui_entry(tmp_path) + _touch_ink(tmp_path) + _touch_ink_bundle(tmp_path) + + assert main_mod._tui_build_needed(tmp_path) is False