refactor(auto-updater): Introduce state machine and guard staged updates#2427
Merged
k11kirky merged 4 commits intoMay 29, 2026
Conversation
Member
Author
Contributor
What T-Rex did
Prompt To Fix All With AIFix the following 3 code review issues. Work through them one at a time, proposing concise fixes.
---
### Issue 1 of 3
apps/code/src/main/services/updates/service.ts:227-233
**Reset update quit flag** When `quitAndInstall()` throws, this catch block moves the update state back to `ready` but leaves `AppLifecycleService.isQuittingForUpdate` set from the earlier `setQuittingForUpdate()` call. The next normal app quit then returns early from the `before-quit` handler and skips `gracefulExit()`, so database close, watcher teardown, and analytics/log flushing can be bypassed for the rest of the session. Please clear that lifecycle flag on this failure path, or only set it once the install handoff can no longer fail back into a normal session.
### Issue 2 of 3
apps/code/src/main/services/updates/service.ts:123-128
**Preserve installing status** `isUpdateStaged()` is true for both `ready` and `installing`, so `getStatus()` reports an in-progress install as `updateReady: true`. A renderer reload during the 3s shutdown window then hydrates the store back to `ready`, and `UpdateBanner` shows the clickable Restart button instead of the Restarting state. The status payload needs to distinguish `installing` so the renderer can keep the install UI and avoid sending another no-op install request.
### Issue 3 of 3
apps/code/src/main/services/updates/service.ts:351-367
**Stop staged polling** After an update is downloaded, the hourly interval created in `setupAutoUpdater()` stays active even though every periodic check now short-circuits forever. That leaves the process waking up and writing skipped-check transition logs every hour until restart. Clear `checkIntervalId` when the update reaches `ready`, since no later periodic check can do useful work once the staged update guard is active.
Reviews (1): Last reviewed commit: "Bound update install cleanup" | Re-trigger Greptile |
This was referenced May 29, 2026
aebda98 to
fb78347
Compare
k11kirky
approved these changes
May 29, 2026
This was referenced May 29, 2026
Merged
Contributor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Problem
The auto-updater juggled several boolean flags (updateReady, checkingForUpdates, etc.) to track lifecycle, which produced ambiguous states, let periodic checks re-run after an update was already staged and let installUpdate re-enter mid-install. Shutdown during install could also hang forever.
Closes #2169 #2377
Changes
How did you test this?
manually
Automatic notifications