fix(banner): stop fabricating "1 commit behind" on SSH-official remotes - #61050
fix(banner): stop fabricating "1 commit behind" on SSH-official remotes#61050gkd2323c wants to merge 1 commit into
Conversation
|
Thanks for the focused fix. Current main still turns the unknown-count sentinel into a literal Existing consumers are compatible: Automated hermes-sweeper review. |
46e7120 to
6a80a21
Compare
The SSH-official-remote path in _check_via_local_git was hard-coded to return 1 when _check_via_rev reported UPDATE_AVAILABLE_NO_COUNT, so 'hermes --version' and the CLI banner surfaced a stable but false 'Update available: 1 commit behind — run hermes update' message. The count never grew: whether upstream was 1 commit or 100 commits ahead, the banner always said '1 commit behind'. Root cause: an ls-remote probe against the upstream URL can only tell us tip SHAs, not a real commit count. Returning the sentinel UPDATE_AVAILABLE_NO_COUNT (-1) already means 'update exists, count unknown' — the exact right shape for this path. The dashboard/desktop UI does not depend on the fabricated 1: - The REST /api/hermes/update/check endpoint (hermes_cli/web_server.py::check_hermes_update) treats any nonzero behind as update_available=true, and its docstring explicitly documents -1 as a legitimate value. - The desktop store (apps/desktop/src/store/updates.ts::mapBackendCheck) clamps behind<=0 to 0 and reads updateAvailable as a separate boolean field. So restoring the sentinel is a strict improvement: CLI banner and hermes --version now say 'Update available' honestly instead of inventing a count, and every REST/desktop consumer keeps working. Changes: - hermes_cli/banner.py: drop the 'return 1' override in the SSH branch; propagate the sentinel unchanged. - hermes_cli/main.py::_print_version_info: render the sentinel as 'Update available — run <cmd>' (without a count). - tests/hermes_cli/test_update_check.py: update the SSH-official test to assert on the sentinel; add 3 new tests covering the CLI renderer's -1 / >0 / 0 branches.
6a80a21 to
9a9061d
Compare
|
Merged via PR #86257 — your commit was cherry-picked onto current main with your authorship preserved in git log (bf10349). Thanks! Your fix was the earliest in this cluster and is credited as the base of the salvage: the SSH-official path now passes the UPDATE_AVAILABLE_NO_COUNT sentinel through untouched and |
Problem
The SSH-official-remote branch in
banner._check_via_local_gitwas hard-coded to return1whenever_check_via_revreportedUPDATE_AVAILABLE_NO_COUNT, sohermes --versionand the CLI banner surfaced a stable but falseUpdate available: 1 commit behind — run hermes updatemessage.The count never grew: whether upstream was 1 commit or 100 commits ahead, the banner always said "1 commit behind".
Root cause
Introduced in #52828 to "align with the desktop client checker". The intent was to give the desktop UI something to show, but the change picked the wrong lever: an
ls-remoteprobe against the upstream URL can only tell us tip SHAs, not a real commit count. Fabricating1in the source path breaks every downstream consumer that renders a count.The
UPDATE_AVAILABLE_NO_COUNTsentinel (-1) already means "update exists, count unknown" — that's the exact shape this path should return. It's whatcheck_via_nix_revisionand (via #50784)check_via_pypialready do.Why no UI consumer needs the fake
1/api/hermes/update/check(hermes_cli/web_server.py::check_hermes_update) treats any nonzerobehindasupdate_available=true, and the docstring explicitly documents-1as a legitimate value ("-1 if behind by an unknown count (nix/pypi)").apps/desktop/src/store/updates.ts::mapBackendCheck) already clampsbehind <= 0to0and readsupdateAvailableas a separate boolean field — so a-1payload from the backend renders asupdateAvailable=true, behind=0, exactly the "yes update, no number" UX the original PR was trying to achieve.So restoring the sentinel is a strict improvement: the CLI banner and
hermes --versionsay "Update available" honestly instead of inventing a count, and every REST/desktop consumer keeps working.Changes
hermes_cli/banner.py::_check_via_local_git— drop thereturn 1override in the SSH branch; propagate the sentinel unchanged. Comment explains why every UI consumer already handles-1correctly.hermes_cli/main.py::_print_version_info— render the sentinel asUpdate available — run <cmd>(no count).tests/hermes_cli/test_update_check.pytest_check_for_updates_official_ssh_origin_uses_https_probeto assert on the sentinel (was asserting on the fabricated1).UPDATE_AVAILABLE_NO_COUNT→ "Update available" without a count;> 0→ exact-count rendering;== 0→ "Up to date".Test plan
Repro (before this PR)
Clone
git@github.com:NousResearch/hermes-agent.git(SSH remote) via the installer (--depth 1). Fully update to the latest tag. Runhermes --version:Now run
hermes update. It reportsAlready up to date.hermes --versionstill says1 commit behind. Rinse and repeat — the message is permanent because the SSH branch never actually counted anything.After this PR the same environment reports
Up to date(when caught up) orUpdate available — run 'hermes update'(when upstream is genuinely ahead).