Skip to content

Make update notice prominent on every non-JSON command (#269)#272

Open
sdairs wants to merge 2 commits into
mainfrom
issue-269-prominent-update-notice
Open

Make update notice prominent on every non-JSON command (#269)#272
sdairs wants to merge 2 commits into
mainfrom
issue-269-prominent-update-notice

Conversation

@sdairs

@sdairs sdairs commented Jun 25, 2026

Copy link
Copy Markdown
Collaborator

Closes #269

Problem

Users weren't updating clickhousectl because the update notice was barely surfaced — it only printed on --help/--version, never during normal command execution.

What changed

  • Show the notice on every non---json command. The cached update notice now prints to stderr at the very end of every command that produces human-readable output. --json and detected coding agents continue to suppress it, so machine/agent consumers are unaffected.
  • New single-line message:

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

  • --version always checks the network, refreshes the cache, and resets the staleness timer, then prints the notice from the fresh cache.
  • update --check now also writes the cache and resets the timer on every run.
  • Successful update clears the cache so the notice disappears immediately.
  • Kept the 24h background-refresh gate for normal commands (one network call per day). On network failure we now preserve any previously-cached "update available" version instead of clobbering it with the current version, so a known update is never hidden.

Tests

  • cache_is_stale boundary cases (update.rs).
  • command_json_flag mapping + --json/update suppression (main.rs).
  • All 353 tests pass; clippy clean.

Manual verification (live network, current latest 0.3.1)

Scenario Result
--version, seeded stale cache Hit network, cache rewritten to 0.3.1, timer reset
--version on a temp v0.0.1 build Printed version, then the notice
update --check, seeded wrong cache Update available: v0.0.1 → v0.3.1; cache rewritten, timer reset
Normal human command, newer cache Notice prints at the very end after output
Same command with --json / under agent detection Notice suppressed

🤖 Generated with Claude Code

Surface the available-update state far more aggressively:

- Show the cached update notice at the very end of every command that
  produces human-readable output (stderr), not just --help/--version.
  --json and detected coding agents continue to suppress it so machine
  consumers stay clean.
- New single-line message: "There is a new version of clickhousectl.
  Update with `clickhousectl update`."
- --version now always hits the network to refresh the cache + reset the
  staleness timer, then prints the notice from the fresh cache.
- `update --check` now also writes the cache + resets the timer on every
  run.
- Successful `update` clears the cache so the notice disappears at once.
- Keep the 24h background-refresh gate for normal commands; on network
  failure preserve any previously-cached "update available" version
  instead of clobbering it with the current version.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@sdairs sdairs requested a review from iskakaushik as a code owner June 25, 2026 21:45
@sdairs

sdairs commented Jun 26, 2026

Copy link
Copy Markdown
Collaborator Author

bugbot review

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 8812b60. Configure here.

Comment thread crates/clickhousectl/src/update.rs
The 'Already up to date' path in perform_update returned without writing
the cache, so a stale 'update available' notice (e.g. from a yanked
release or wrong cache entry within the 24h window) kept nagging even
after the user explicitly ran `update`. Refresh the cache to network
truth before returning, mirroring the success path and check_for_update.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.

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

1 participant