From 364dc0a877a14518eb5479a5a7a6a3317e57ffbb Mon Sep 17 00:00:00 2001 From: Junha Park <0xjunha@gmail.com> Date: Wed, 20 May 2026 16:46:38 +0900 Subject: [PATCH] fix(cli): show auto-refresh restart guidance after upgrade --- CHANGELOG.md | 2 ++ crates/cli/src/tests/upgrade.rs | 15 +++++++++++++++ crates/cli/src/upgrade.rs | 16 ++++++++++++++++ 3 files changed, 33 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1a98d05..2e4dc22 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,8 @@ All notable Darc release changes should be summarized here. ## Unreleased +- Print post-upgrade auto-refresh restart guidance after `darc upgrade`. + ## [0.2.0] - 2026-05-20 - Add Git-backed encrypted team sharing for selected Darc session context with `darc share`, `darc remote`, diff --git a/crates/cli/src/tests/upgrade.rs b/crates/cli/src/tests/upgrade.rs index dc99a30..c5f6238 100644 --- a/crates/cli/src/tests/upgrade.rs +++ b/crates/cli/src/tests/upgrade.rs @@ -147,6 +147,21 @@ fn upgrade_check_json_uses_current_install_command() { ); } +#[test] +fn post_upgrade_background_refresh_note_bolds_restart_command() { + let note = super::post_upgrade_background_refresh_note(HumanStyle::new( + true, + false, + Some("xterm-256color"), + )); + + assert!(note.contains("\x1b[1mdarc refresh --auto\x1b[0m")); + assert_eq!( + strip_ansi_text(¬e), + "If Darc auto-refresh was running, run darc refresh --auto to restart it with the new version." + ); +} + #[test] fn upgrade_http_error_detail_is_bounded_and_single_line() { let detail = super::upgrade_http_error_detail(" first line\nsecond\tline ").unwrap(); diff --git a/crates/cli/src/upgrade.rs b/crates/cli/src/upgrade.rs index 0c49230..833bc5c 100644 --- a/crates/cli/src/upgrade.rs +++ b/crates/cli/src/upgrade.rs @@ -316,11 +316,27 @@ fn run_darc_upgrade(status: UpgradeStatus) -> Result<()> { .status() .with_context(|| format!("failed to run updater {}", updater_path.display()))?; if result.success() { + print_post_upgrade_background_refresh_note(style); return Ok(()); } bail!("updater exited with status {result}") } +/// Prints follow-up guidance for users with a running auto-refresh service. +fn print_post_upgrade_background_refresh_note(style: HumanStyle) { + println!(); + print_section(style, "Background refresh"); + print_line(2, post_upgrade_background_refresh_note(style)); +} + +/// Formats the post-upgrade auto-refresh restart guidance. +pub(crate) fn post_upgrade_background_refresh_note(style: HumanStyle) -> String { + format!( + "If Darc auto-refresh was running, run {} to restart it with the new version.", + style.bold("darc refresh --auto") + ) +} + /// Checks GitHub Releases for the latest Darc CLI release. fn check_darc_upgrade(timeout: Duration, auth: UpgradeCheckAuth) -> Result { let current_version = env!("CARGO_PKG_VERSION").to_owned();