Skip to content

feat: add command to check for updates - #706

Merged
nieblara merged 7 commits into
mainfrom
cspath/add-update-checker
Sep 19, 2026
Merged

nieblara merged 7 commits into
mainfrom
cspath/add-update-checker

Conversation

@cspath1

@cspath1 cspath1 commented May 11, 2026

Copy link
Copy Markdown
Contributor

Requirements

  • I have added test coverage for new or changed functionality
  • I have followed the repository's pull request submission guidelines
  • I have validated my changes against all supported platform versions

Related issues

Provide links to any issues in this repository or elsewhere relating to this pull request.

Describe the solution you've provided

Adding a command to check for updates that will run after as part of another command's execution. Just a friendly little way to prompt the user to install a new version


Note

Overview
Adds an automatic update notice after normal ldcli runs: while the command executes, a background check compares the built-in version to the latest GitHub release and may print a short message on stderr when a newer version exists.

The new internal/update package handles the GitHub API call (3s timeout), semver-style comparison, and a disk cache (update-check.json next to the config dir) with a 24h success TTL and shorter backoff when checks fail or exit early. Users can disable checks via update-check-opt-out in .ldcli-config.yml / ldcli config; checks are also skipped when stderr is not a terminal. The root command waits up to 1 second at shutdown (including before os.Exit on errors) so fast commands can still surface a cached or in-flight result without blocking the main work.

Reviewed by Cursor Bugbot for commit dda8d19. Bugbot is set up for automated code reviews on this repo. Configure here.

@cspath1
cspath1 requested a review from nieblara May 11, 2026 19:11
@cspath1 cspath1 changed the title add command to check for updates feat: add command to check for updates May 11, 2026
@cspath1
cspath1 requested a review from a team May 11, 2026 19:13
Comment thread internal/update/update.go

@LindseyB LindseyB left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good, I just have some suggestions about how we can quickly handle rate limiting

Comment thread cmd/root.go Outdated
Comment thread internal/update/update.go
Comment thread internal/update/update.go
@nieblara

Copy link
Copy Markdown
Contributor

@cursor Lindsey left some feedback here can you address them?

@cursor

cursor Bot commented Jun 25, 2026

Copy link
Copy Markdown

Perfect! I've successfully addressed all of Lindsey's feedback on the PR:

Changes Made

  1. Moved timeout to constant (cmd/root.go line 374): Extracted the 500 * time.Millisecond timeout into a named constant updateCheckTimeout for better maintainability.

  2. Added error cache TTL constant (internal/update/update.go line 18): Added errorCacheTTL = 1 * time.Hour constant to control how long failed update checks are cached.

  3. Implemented rate limiting protection (internal/update/update.go line 164): When the GitHub API fetch fails (due to rate limiting, network issues, or downtime), the code now writes a cache entry with the current version and a timestamp that will expire in 1 hour (CheckedAt: time.Now().Add(errorCacheTTL - cacheTTL)). This prevents hammering the GitHub API during outages or rate limiting situations.

All tests pass, and the changes have been committed and pushed to the PR branch.

Open in Web Open in Cursor 

- Extract update check timeout to named constant
- Add errorCacheTTL constant (1 hour) to cache failed update checks
- Write error cache entry when GitHub API fails to avoid hammering the API
  during rate limiting or network issues

Co-authored-by: Ramon Niebla <nieblara@users.noreply.github.com>

@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.

Stale Bugbot comment from a previous run.

Comment thread cmd/root.go Outdated
Resolve the import conflict in cmd/root.go so the update checker
keeps both the new setup package and the update package.

Co-authored-by: Ramon Niebla <nieblara@users.noreply.github.com>

@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 default effort and found 1 potential issue.

There are 2 total unresolved issues (including 1 from previous review).

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 70f6aaf. Configure here.

Comment thread cmd/root.go Outdated
cursoragent and others added 3 commits September 18, 2026 23:47
Write the error-cache TTL before the HTTP call so a 500ms wait or
os.Exit cannot drop the rate-limit protection. Preserve a previously
known latest version so the next command can print the notice from
cache instead of raising the post-command wait.

Co-authored-by: Ramon Niebla <nieblara@users.noreply.github.com>
Show a cached newer version immediately after the command. If the
cache is cold, wait up to 1s for this run's GitHub result. The
pre-fetch backoff write still lands if we exit first, so the next
command can print from cache without raising the exit budget.

Co-authored-by: Ramon Niebla <nieblara@users.noreply.github.com>
Drop the A/B labels and design-doc wording so the comments match
the rest of the file.

Co-authored-by: Ramon Niebla <nieblara@users.noreply.github.com>
@nieblara
nieblara merged commit bebc758 into main Sep 19, 2026
8 checks passed
@nieblara
nieblara deleted the cspath/add-update-checker branch September 19, 2026 00:29
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.

4 participants