feat: add command to check for updates#706
Conversation
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default mode and found 1 potential issue.
❌ 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 9217b8b. Configure here.
LindseyB
left a comment
There was a problem hiding this comment.
Looks good, I just have some suggestions about how we can quickly handle rate limiting
| if result.info != nil && result.info.IsNewer { | ||
| fmt.Fprint(os.Stderr, update.NotificationMessage(result.info)) | ||
| } | ||
| case <-time.After(500 * time.Millisecond): |
There was a problem hiding this comment.
Nit: Can we move this timeout into a constant
|
|
||
| const ( | ||
| defaultGitHubReleasesURL = "https://api.github.com/repos/launchdarkly/ldcli/releases/latest" | ||
| cacheTTL = 24 * time.Hour |
There was a problem hiding this comment.
| cacheTTL = 24 * time.Hour | |
| cacheTTL = 24 * time.Hour | |
| errorCacheTTL = 1 * time.Hour |
| writeCache(&cacheEntry{ | ||
| LatestVersion: latest, | ||
| CheckedAt: time.Now(), | ||
| }) |
There was a problem hiding this comment.
I'm thinking we need to update this to make sure we don't hammer the GitHUb API if it's down or rate limiting us:
| }) | |
| client := &http.Client{Timeout: httpTimeout} | |
| latest, err := fetchLatestVersion(client) | |
| if err != nil { | |
| writeCache(&cacheEntry{ | |
| LatestVersion: currentVersion, | |
| CheckedAt: time.Now().Add(errorCacheTTL - cacheTTL), // -23h, expires in 1h | |
| }) | |
| return nil | |
| } | |
| writeCache(&cacheEntry{ | |
| LatestVersion: latest, | |
| CheckedAt: time.Now(), | |
| }) |
There was a problem hiding this comment.
The suggested change box got funky but you should get the idea

Requirements
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
Medium Risk
Introduces a new background network request and cache file write on normal CLI execution, which could affect startup behavior and stderr output. Risk is mitigated by timeouts, caching, and an explicit
update-check-opt-outsetting.Overview
Adds an automatic update notification:
cmd/root.gonow starts a background update check during command execution and, if a newer version is found, prints a message to stderr (skipped for non-TTY stderr or when opted out).Introduces
internal/updateto fetch the latest GitHub release with a short timeout and a 24-hour on-disk cache, plus tests for version parsing/comparison and caching behavior. Exposes a newupdate-check-opt-outconfig/flag (wired intocliflags,config.Config.Update, and help golden output).Reviewed by Cursor Bugbot for commit 90f093e. Bugbot is set up for automated code reviews on this repo. Configure here.