From cca2869d78388e049ff1116e420b7209643a9c15 Mon Sep 17 00:00:00 2001 From: fahdad <30740087+fahdad@users.noreply.github.com> Date: Fri, 8 May 2026 00:01:58 -0700 Subject: [PATCH] fix(banner): resolve update-check repo from running code, not profile-scoped path MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit check_for_updates() and _resolve_repo_dir() were preferring $HERMES_HOME/hermes-agent/ over Path(__file__).parent.parent.resolve() when looking for a .git checkout. For profiles created with --clone-all, $HERMES_HOME/hermes-agent/ points to a stale copy with a frozen HEAD, causing persistent "N commits behind" banners that never resolved. Flip the resolution order: prefer the running code's location first, fall back to $HERMES_HOME/hermes-agent/ only when the live checkout doesn't have a .git (system-wide pip installs, distro packages). The embedded-rev branch (HERMES_REVISION env var, set by nix builds) is unaffected — it uses git ls-remote against upstream, never reads the local checkout's HEAD. Based on PR #21728 by @fahdad --- hermes_cli/banner.py | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/hermes_cli/banner.py b/hermes_cli/banner.py index c8446f04d9c..1cfb0d51f76 100644 --- a/hermes_cli/banner.py +++ b/hermes_cli/banner.py @@ -206,9 +206,12 @@ def check_for_updates() -> Optional[int]: if embedded_rev: behind = _check_via_rev(embedded_rev) else: - repo_dir = hermes_home / "hermes-agent" + # Prefer the running code's location over the profile-scoped path. + # $HERMES_HOME/hermes-agent/ may be a stale copy from --clone-all; + # Path(__file__) always resolves to the actual installed checkout. + repo_dir = Path(__file__).parent.parent.resolve() if not (repo_dir / ".git").exists(): - repo_dir = Path(__file__).parent.parent.resolve() + repo_dir = hermes_home / "hermes-agent" if not (repo_dir / ".git").exists(): return None behind = _check_via_local_git(repo_dir) @@ -222,11 +225,16 @@ def check_for_updates() -> Optional[int]: def _resolve_repo_dir() -> Optional[Path]: - """Return the active Hermes git checkout, or None if this isn't a git install.""" - hermes_home = get_hermes_home() - repo_dir = hermes_home / "hermes-agent" + """Return the active Hermes git checkout, or None if this isn't a git install. + + Prefers the running code's location over the profile-scoped path + because ``$HERMES_HOME/hermes-agent/`` may be a stale copy carried + over by ``--clone-all``. + """ + repo_dir = Path(__file__).parent.parent.resolve() if not (repo_dir / ".git").exists(): - repo_dir = Path(__file__).parent.parent.resolve() + hermes_home = get_hermes_home() + repo_dir = hermes_home / "hermes-agent" return repo_dir if (repo_dir / ".git").exists() else None