Skip to content

The agent that grows with you

fix(update): skip recompiling the TUI and web UI when their inputs are unchanged

teknium1d49da55d4c7f
diff --git a/hermes_cli/source_build.py b/hermes_cli/source_build.py
index d7a6e0743da..726250366a3 100644
--- a/hermes_cli/source_build.py
+++ b/hermes_cli/source_build.py
@@ -114,12 +114,22 @@ def build_update_products(project_root: Path, *, desktop: bool) -> None:
workspaces = frontends + (("apps/desktop",) if desktop else ())
publish_stage("Updating Node dependencies")
prepare_source_dependencies(project_root, workspaces, env=env, explicit=True)
+ # An update that changed no TUI/web input reuses the receipted output, as the
+ # launch path already does; recompiling it produces the same bytes. Desktop has
+ # no such skip: its baked install stamp carries the commit, so every update
+ # that moves HEAD changes a desktop input anyway.
if "ui-tui" in frontends:
- publish_stage("Building the TUI")
- build_source_tui(project_root, env=env)
+ if source_product_current(project_root, "tui", project_root / "ui-tui/dist"):
+ print(" ✓ TUI is up to date")
+ else:
+ publish_stage("Building the TUI")
+ build_source_tui(project_root, env=env)
if "web" in frontends:
- publish_stage("Building the web UI")
- build_source_web(project_root, env=env)
+ if source_product_current(project_root, "web", project_root / "hermes_cli/web_dist"):
+ print(" ✓ Web UI is up to date")
+ else:
+ publish_stage("Building the web UI")
+ build_source_web(project_root, env=env)
if desktop:
from hermes_cli.main_desktop import _refresh_installed_desktop_apps, build_prepared_desktop
diff --git a/tests/hermes_cli/test_source_build.py b/tests/hermes_cli/test_source_build.py
index 92e4ea5ce44..2760787c910 100644
--- a/tests/hermes_cli/test_source_build.py
+++ b/tests/hermes_cli/test_source_build.py
@@ -275,6 +275,27 @@ def test_update_builds_selected_products_after_one_union_preparation(source_prod
assert not list((root / "apps/desktop").glob(".staging-*"))
+def test_update_recompiles_only_products_whose_inputs_changed(source_products):
+ from hermes_cli.source_build import build_update_products
+
+ root, _ = source_products
+
+ def products():
+ return [event["step"] for event in _events(root) if event["step"] != "deps"]
+
+ build_update_products(root, desktop=True)
+ (root / "events.jsonl").unlink()
+ build_update_products(root, desktop=True)
+ assert products() == ["desktop"]
+
+ (root / "events.jsonl").unlink()
+ (root / "web/src").mkdir(parents=True, exist_ok=True)
+ (root / "web/src/changed.ts").write_text("export {}\n", encoding="utf-8")
+ build_update_products(root, desktop=False)
+ assert products() == ["web"]
+
+
@pytest.mark.platforms("linux")
@pytest.mark.parametrize("step", ["tui", "web", "desktop"])
def test_update_failure_raises_without_retries_or_replacing_live_app(source_products, step):