Skip to content

Make update notice more prominent: show on every non-JSON output, drop 24h check gate #269

Description

@sdairs

Problem

Users aren't updating clickhousectl. The update notice isn't surfaced enough.

Today the notice is shown in very few places:

  • It only prints on --help and --version (the clap error branch in crates/clickhousectl/src/main.rs), via update::print_cached_update_notice().
  • It does not print during normal command execution at all — see the comment at main.rs: "The notice itself is only shown on --help (above), not during normal execution."
  • A 24-hour cache gate (CHECK_INTERVAL_SECS = 24 * 60 * 60 + refresh_update_cache() in crates/clickhousectl/src/update.rs) means we only refresh the cached "latest version" once per day.

What we want

  1. Kill the once-every-24-hour check gate. Remove the CHECK_INTERVAL_SECS throttle so we surface the available-update state on every invocation.

  2. Show the notice on every command that does not pass --json. Every single non---json output should display the update notice when a newer version is available — not just --help/--version.

  3. --help must always show it (when an update is available).

  4. clickhousectl --version must always show it (when an update is available).

  5. Always put the notice at the very end of the output.

  6. New message text (single line, replacing the current two-line message):

    There is a new version of clickhousectl. Update with clickhouse update.

Notes / open questions

  • The requested message says clickhouse update, but the update command is actually clickhousectl update (clickhouse is the server binary). We should confirm the intended command name before merging — most likely clickhousectl update.
  • --json output must remain clean (no notice), so machine/agent consumers are unaffected.
  • Need to make sure the notice goes to stderr (as it does today) so it never corrupts piped stdout, and that it always lands after the command's own output.
  • Consider keeping the background cache refresh (so we don't make a blocking network call on every command) but drop the staleness throttle, or refresh more aggressively. Implementation detail to settle in the PR.

Acceptance criteria

  • 24h check interval removed.
  • Update notice shown at the end of every non---json command when an update is available.
  • Update notice shown after --help and --version.
  • Notice uses the new single-line message.
  • --json output unaffected.
  • Tests updated/added.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions