Conversation
…ckground - Spawn auto-update via tokio::spawn instead of blocking main startup - Remove interactive y/n prompt from auto_update() in check_update.rs - Extract run_auto_update_if_newer() with injectable callback for testing - Extract apply_downloaded_binary_update() from update_binary_atomic() for testability - Extract update_via_brew_with_command() for testable brew update path - Remove process::exec()/exit() from binary update success path; update now returns Ok - Add should_spawn_auto_update() gate that skips update in warden/async/print/command modes - Extract run_stakpak_in_warden_with_path() for testability; add env propagation test - Unify update success messages to prompt restart rather than auto-re-exec - Update system prompt and README with restart guidance - Add unit tests for: update gate, newer-version check, brew path injection, atomic binary swap without process exit, warden env propagation
Introduces several improvements to the binary update process: - **`restart_current_process`**: A new function that handles restarting the current process, essential for applying updates atomically. - **Atomic Replacement**: Ensures that the new binary is copied to a temporary location, permissions are set, and then atomically replaced with the current executable. This minimizes downtime and potential corruption. - **Error Handling and Cleanup**: Enhanced error handling throughout the update process, including cleanup of temporary files if an error occurs. - **Verification Test**: A new verification test is run on the downloaded binary before applying it. - **Background Updates**: The `stakpak update` command now supports a `--background` flag, allowing updates to be performed without interrupting the current session. This is used by
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Refactors the auto-update system from a blocking interactive prompt to a non-interactive background task spawned at startup. This eliminates the y/n prompt that previously blocked the CLI from starting and removes all
process::exec()/process::exit()calls from the update success path.Changes Made
main.rs: Auto-update now runs viatokio::spawnin the background. Addedshould_spawn_auto_update()gate that skips update in warden, async, print, or command-modes. Restructured config loading to separate initialization from auto-update gating.auto_update.rs: Extractedapply_downloaded_binary_update()fromupdate_binary_atomic()to isolate the file-swap logic for testability. Extractedupdate_via_brew_with_command()for injectable brew path. Removedprocess::exec()/exit()— update now returnsOk(())and prints a restart message. Addedupdate_success_message()for consistent messaging.check_update.rs: Removed interactive y/n stdin prompt. Extractedrun_auto_update_if_newer()with an injectable async callback for testing.warden.rs: Extractedrun_stakpak_in_warden_with_path()for testability. Added test verifyingSTAKPAK_SKIP_WARDEN=1env propagation to inner process.Testing
cargo test --workspace)cargo clippy --all-targets)cargo fmt --check)Breaking Changes
None. The update behavior is transparent to users — the only visible change is that updates no longer block startup or prompt for confirmation.