The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(desktop-update): name the failing updater output in the hand-off failure
liuhao1024e241405cd154
diff --git a/scripts/desktop-update/posix.sh b/scripts/desktop-update/posix.shindex 1ef18a2d998..34b9b4c6f2b 100755--- a/scripts/desktop-update/posix.sh+++ b/scripts/desktop-update/posix.sh@@ -130,6 +130,18 @@ owed_followup_steps() { # $OUT -> the distinct owed steps, space-separated, in p| awk '!seen[$0]++' | tr '\n' ' ' | sed 's/ *$//'}+update_output_tail() { # $OUT -> the updater's last non-empty output lines, one line each+ # The shim window and the next-boot result dialog are the only surfaces a+ # user can reach when the update failed; the exit code alone never names+ # the failing layer (#137327). $OUT is the run's slice of the hand-off log,+ # which interleaves our own log() lines (a leading ISO timestamp) with the+ # updater's output — keep only the updater's, strip progress escapes (ANSI,+ # CR), and bound it: three lines of at most 120 characters each.+ printf '%s' "$OUT" | tr -d '\r' | sed "s/$(printf '\033')\[[0-9;?]*[A-Za-z]//g" \+ | grep -v -e '^[[:space:]]*$' -e '^[0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\}T' | tail -n 3 \+ | while IFS= read -r _tail_line; do printf '%s\n' "${_tail_line:0:120}"; done+}+# The marker (contract C1/C2 + the A7 lock): parsing, identity, claim, delegate,# release and the Desktop's helper ops live in marker.sh.MY_PID=$$ MY_CT=""@@ -1303,6 +1315,11 @@ elif [ "$CODE" -ne 2 ] && update_committed_after_exit; thenadd_warning "update" "hermes update exited $CODE after the commit point (receipt outcome: $RECEIPT_OUTCOME)"elseFINAL_CODE="$CODE" FINAL_MSG="Update failed (exit $CODE). Run hermes debug share in a terminal to send a report."+ # Name the failing layer where the user can see it: the updater's own tail+ # rides the result file and the shim message (empty output keeps the+ # original generic copy, byte-identical).+ FAIL_EXCERPT="$(update_output_tail | tr '\n' ' ' | sed 's/ *$//')"+ [ -z "$FAIL_EXCERPT" ] || FINAL_MSG="$FINAL_MSG Last output: $FAIL_EXCERPT"# The bricked-venv class is fixable and must not read as a generic exit 1:# a dead interpreter with a failed/impossible heal means retrying can never# succeed — tell the user what is actually wrong (#95759).diff --git a/tests/scripts/desktop_update/test_desktop_update_posix_marker.py b/tests/scripts/desktop_update/test_desktop_update_posix_marker.pyindex 92503a958c8..6a55018c136 100644--- a/tests/scripts/desktop_update/test_desktop_update_posix_marker.py+++ b/tests/scripts/desktop_update/test_desktop_update_posix_marker.py@@ -302,6 +302,26 @@ def test_nonzero_exit_without_this_runs_committed_receipt_still_fails(tmp_path,assert (outcome["ok"], outcome["exit_code"]) == (False, 130), outcome[email protected]("output", ["", "sweeping the venv\n\nERROR: the autostash cannot be re-applied"],+ ids=["no-output", "names-the-failing-layer"])+def test_failed_update_carries_the_updaters_own_output(tmp_path, output):+ """The generic failure copy is the only thing the shim and the next-boot result dialog can+ show the user; without the updater's tail the exit code names nothing (#137327). Empty+ updater output keeps the original copy byte-identical."""+ home, install = _install(tmp_path)++ result = _run(tmp_path, home, install, HANDOFF_EXIT="1", HANDOFF_OUTPUT=output)++ assert result.returncode == 1, result.stdout + result.stderr+ outcome = json.loads((home / ".hermes-update-result.json").read_text(encoding="utf-8-sig"))+ assert (outcome["ok"], outcome["exit_code"]) == (False, 1), outcome+ assert outcome["message"].startswith("Update failed (exit 1). Run hermes debug share"), outcome+ if output:+ assert "Last output: sweeping the venv ERROR: the autostash cannot be re-applied" in outcome["message"], outcome+ else:+ assert "Last output:" not in outcome["message"], outcome++def test_interrupted_app_swap_is_rolled_back_at_the_next_run(tmp_path):home, install = _install(tmp_path)app = tmp_path / "Applications" / "Hermes.app"