The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(update): hermes update rebuilds the Webapp bundle a home serves
emozilla443732a58ba3
diff --git a/hermes_cli/source_build.py b/hermes_cli/source_build.pyindex 901dcebdbd5..a884aadc518 100644--- a/hermes_cli/source_build.py+++ b/hermes_cli/source_build.py@@ -224,6 +224,9 @@ def build_update_products(project_root: Path, *, desktop: bool) -> None:# One whole line the Desktop hand-off scripts match: the follow-up text is truncated# and names whichever products failed first, so it cannot say if THIS app was rebuilt.print(f" Desktop app build owed: {desktop_reason} failed")+ if (project_root / "apps/desktop/scripts/build-webapp.mjs").is_file():+ # Its dependencies live in a private workspace, so it never waits on the union above.+ attempt("Webapp build", lambda: _rebuild_served_webapp(project_root, publish_stage))# A configured memory provider that no longer ships in core is installed from the# catalog for every profile home sharing this venv (config, data and tool names# unchanged). The update must finish even if the migration blows up.@@ -245,6 +248,21 @@ def build_update_products(project_root: Path, *, desktop: bool) -> None:raise ProductBuildError(failures)+def _rebuild_served_webapp(project_root: Path, publish_stage) -> None:+ """The Webapp bundle (``apps/desktop/dist-webapp``), when a home sharing this install serves it+ (``webapp.enabled``): its gateway serves the bundle as built, so one older than the updated+ backend would talk to it with an outdated contract. Built with the function ``hermes webapp``+ uses, which reuses a current bundle."""+ from gateway.webapp_listener import webapp_settings+ from hermes_cli.webapp import prepare_webapp_renderer+ from pm.plugins_state import dependency_homes++ if not any(webapp_settings(home).enabled for home in dependency_homes()):+ return+ publish_stage("Building the Webapp")+ prepare_webapp_renderer(project_root, explicit=True)++def _build_desktop_product(project_root: Path, env: dict, publish_stage) -> None:from hermes_cli.main_desktop import (_packaged_desktop_current_for_head, _refresh_installed_desktop_apps, build_prepared_desktop)diff --git a/scripts/ci/classify_changes.py b/scripts/ci/classify_changes.pyindex be24a876a97..9f6eb8d831f 100644--- a/scripts/ci/classify_changes.py+++ b/scripts/ci/classify_changes.py@@ -375,6 +375,8 @@ _UPDATE_DEPENDENCIES = (# tui, web, desktop and their shared frontend-common)."scripts/build/","apps/desktop/scripts/build-webapp.mjs", # source_build's Webapp renderer build+ "hermes_cli/webapp.py", # source_build rebuilds the Webapp bundle a home serves+ "gateway/webapp_listener.py", # source_build reads which homes serve the Webapp)# General-purpose modules an entry point imports but that half the product# imports too (>= HUB_MIN_IMPORTERS product modules, checked by the test). Thediff --git a/tests/hermes_cli/test_source_build.py b/tests/hermes_cli/test_source_build.pyindex e34d2d63a9b..191c893d3f9 100644--- a/tests/hermes_cli/test_source_build.py+++ b/tests/hermes_cli/test_source_build.py@@ -418,3 +418,36 @@ def test_packaged_desktop_is_reused_only_while_it_names_head(tmp_path, monkeypatreceipt_current["value"] = Truesubprocess.run([*git, "commit", "-q", "--allow-empty", "-m", "two"], check=True)assert not reused()++[email protected]("enabled", [False, True])+def test_update_rebuilds_the_webapp_bundle_a_home_serves(tmp_path, monkeypatch, enabled):+ """``hermes update`` rebuilds ``apps/desktop/dist-webapp``, with the function ``hermes webapp``+ uses, when any home sharing this install has ``webapp.enabled``: that home's gateway serves the+ bundle as built, so an old one would talk to the updated backend. Otherwise it is left alone."""+ import hermes_cli.left_core_migration as left_core+ import hermes_cli.main_install_repair as install_repair+ import hermes_cli.memory_provider_migration as memory_migration+ from hermes_cli import update_stage, webapp+ from hermes_cli.source_build import build_update_products+ from pm import plugins_state++ root = tmp_path / "checkout"+ (root / "apps/desktop/scripts").mkdir(parents=True)+ (root / "apps/desktop/scripts/build-webapp.mjs").write_text("", encoding="utf-8")+ homes = [tmp_path / "default", tmp_path / "profiles" / "work"]+ for home in homes:+ home.mkdir(parents=True)+ (homes[1] / "config.yaml").write_text(f"webapp:\n enabled: {str(enabled).lower()}\n", encoding="utf-8")+ builds = []+ monkeypatch.setattr(install_repair, "_install_configured_features_missing_deps", lambda _root: None)+ monkeypatch.setattr(memory_migration, "migrate_all_homes", list)+ monkeypatch.setattr(left_core, "migrate_all_homes", list)+ monkeypatch.setattr(update_stage, "publish_stage", lambda _stage: None)+ monkeypatch.setattr(plugins_state, "dependency_homes", lambda: homes)+ monkeypatch.setattr(webapp, "prepare_webapp_renderer",+ lambda project_root, **options: builds.append((project_root, options)))++ build_update_products(root, desktop=False)++ assert builds == ([(root, {"explicit": True})] if enabled else [])