Skip to content

feat(self-update): wait for delegated daemon update to complete#699

Merged
passcod merged 2 commits into
mainfrom
claude/bestool-self-update-visibility-mibvdl
Jul 20, 2026
Merged

feat(self-update): wait for delegated daemon update to complete#699
passcod merged 2 commits into
mainfrom
claude/bestool-self-update-visibility-mibvdl

Conversation

@passcod

@passcod passcod commented Jul 20, 2026

Copy link
Copy Markdown
Member

Problem

On Windows, when the alert daemon is running, bestool self-update hands the binary swap off to the daemon and then exits immediately:

INFO bestool::actions::self_update: alert daemon is running; delegating update to it
INFO bestool::actions::self_update: alert daemon is updating and will restart from="1.36.2" to="1.46.1"

The daemon does the download / verify / install / restart in a background task, so the command returns before any of that happens. The operator has no visibility on whether the update actually completed.

Change

The CLI now waits for the delegated update to run to completion instead of exiting the moment the daemon accepts it.

  • crates/bestool/src/actions/self_update.rs — before kicking off the update, record the daemon's started_at; after delegating, poll until one of:

    • /status reports a fresh started_at (the daemon restarted onto the new binary) → log the running version and return success, warning if it isn't the version that was requested;
    • the self-update task reports the target version as failed → return a clear error pointing at the daemon logs;
    • a 5-minute timeout elapses → return a timeout error pointing at bestool alertd status.

    Connection errors during polling are treated as "daemon mid-restart" and don't abort the wait.

  • crates/bestool/src/actions/self_update/task.rs — add a /tasks/self-update/status endpoint exposing the last failed_version, so a failed background install is surfaced instead of only timing out.

Tests

Added unit tests for the restart-detection logic (restart_completed).

Verification

Non-test builds pass on both the unix default target and x86_64-pc-windows-gnu (the delegation path is Windows-only); cargo fmt --check and clippy are clean for the changed code. Note: cargo test / clippy --tests for the crate currently fails to compile due to a pre-existing, unrelated issue in canopy_contract.rs (identical on the base commit), so the new tests compile-check under the non-test Windows build but weren't executed here.

🤖 Generated with Claude Code

https://claude.ai/code/session_01J7Hgzqa2sEfCUnqj8sNdoK


Generated by Claude Code

claude and others added 2 commits July 20, 2026 01:19
When the alert daemon owns the binary swap, `bestool self-update` handed
off the update and exited immediately, leaving the operator with no
visibility on whether it succeeded.

Poll the daemon after delegating: watch `/status` for a restart (a fresh
`started_at`) to confirm the new binary is running, and add a
`/tasks/self-update/status` endpoint so a failed install is surfaced
instead of timing out silently.

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
@passcod
passcod enabled auto-merge July 20, 2026 09:47
@passcod
passcod added this pull request to the merge queue Jul 20, 2026
Merged via the queue into main with commit 6f1a57f Jul 20, 2026
11 checks passed
@passcod
passcod deleted the claude/bestool-self-update-visibility-mibvdl branch July 20, 2026 10:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants