The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
refactor(desktop): one resolver for the packaged app's resources dir
kshitijk4poorcc761ddb80c6
diff --git a/hermes_cli/main_desktop.py b/hermes_cli/main_desktop.pyindex 88b4eeacb49..2190922cb17 100644--- a/hermes_cli/main_desktop.py+++ b/hermes_cli/main_desktop.py@@ -42,15 +42,17 @@ def _renderer_bundle_dir(desktop_dir: Path, *, source_mode: bool) -> Optional[Paif source_mode:return desktop_dir / "dist"+ resources = _packaged_resources_dir(desktop_dir)+ return None if resources is None else resources / "app.asar.unpacked" / "dist"+++def _packaged_resources_dir(desktop_dir: Path) -> Optional[Path]:+ """The packaged app's ``resources`` dir (renderer bundle, baked ``install-stamp.json``)."""executable = _desktop_packaged_executable(desktop_dir)if executable is None:return None-# macOS: …/Hermes.app/Contents/MacOS/Hermes → …/Contents/Resources- resources = (- executable.parent.parent / "Resources" if sys.platform == "darwin" else executable.parent / "resources"- )- return resources / "app.asar.unpacked" / "dist"+ return executable.parent.parent / "Resources" if sys.platform == "darwin" else executable.parent / "resources"# The module files the renderer fetches before any app code runs: Vite emits@@ -134,16 +136,13 @@ def _packaged_desktop_current_for_head(desktop_dir: Path, project_root: Path) ->The commit the packaged app actually ships is the missing half; anything unreadablemeans "build"."""- dist_dir = _renderer_bundle_dir(desktop_dir, source_mode=False)- if dist_dir is None:- return False- try:- stamp = json.loads((dist_dir.parent.parent / "install-stamp.json").read_text(encoding="utf-8-sig"))- except (OSError, ValueError):+ resources = _packaged_resources_dir(desktop_dir)+ if resources is None:return False+ from hermes_cli.steward import read_install_stampfrom hermes_cli.version_info import _run_git- commit = stamp.get("commit") if isinstance(stamp, dict) else None+ commit = read_install_stamp(resources).get("commit")if not isinstance(commit, str) or commit != _run_git(project_root, "rev-parse", "HEAD"):return Falsereturn not _desktop_build_needed(desktop_dir, project_root, source_mode=False)diff --git a/tests/hermes_cli/test_source_build.py b/tests/hermes_cli/test_source_build.pyindex fc0d93d14ae..9c3c9e85d9c 100644--- a/tests/hermes_cli/test_source_build.py+++ b/tests/hermes_cli/test_source_build.py@@ -344,9 +344,9 @@ def test_packaged_desktop_is_reused_only_while_it_names_head(tmp_path, monkeypatsubprocess.run([*git, "commit", "-q", "--allow-empty", "-m", "one"], check=True)desktop_dir = root / "apps/desktop"exe = desktop_dir / "release/app/Hermes"- resources = exe.parent.parent / "Resources" if sys.platform == "darwin" else exe.parent / "resources"- (resources / "app.asar.unpacked/dist").mkdir(parents=True)monkeypatch.setattr(main_desktop, "_desktop_packaged_executable", lambda _d: exe)+ resources = main_desktop._packaged_resources_dir(desktop_dir)+ (resources / "app.asar.unpacked/dist").mkdir(parents=True)receipt_current = {"value": True}monkeypatch.setattr(main_desktop, "_desktop_build_needed",lambda *_a, **_k: not receipt_current["value"])