feat(updates): update modal, auto-download setting, changelog#2818
feat(updates): update modal, auto-download setting, changelog#2818charlesvien wants to merge 1 commit into
Conversation
|
Warning This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
This stack of pull requests is managed by Graphite. Learn more about stacking. |
|
React Doctor found 1 issue in 1 file · 1 warning. 1 warning
Reviewed by React Doctor for commit |
|
| const { status, version, availableVersion, downloadPercent } = | ||
| useUpdateView(); | ||
| const { isEnabled } = useUpdateView(); |
There was a problem hiding this comment.
useUpdateView() is called twice in the same component, creating two separate store subscriptions and violating OnceAndOnlyOnce. isEnabled should simply be added to the first destructure.
| const { status, version, availableVersion, downloadPercent } = | |
| useUpdateView(); | |
| const { isEnabled } = useUpdateView(); | |
| const { status, version, availableVersion, downloadPercent, isEnabled } = | |
| useUpdateView(); |
Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/ui/src/features/sidebar/components/UpdateBanner.tsx
Line: 15-17
Comment:
`useUpdateView()` is called twice in the same component, creating two separate store subscriptions and violating OnceAndOnlyOnce. `isEnabled` should simply be added to the first destructure.
```suggestion
const { status, version, availableVersion, downloadPercent, isEnabled } =
useUpdateView();
```
How can I resolve this? If you propose a fix, please make it concise.Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Problem
The move to electron-updater gave us a new set of primitives that were previously unavailable to us: checking for an update without downloading it, byte-level download progress, an explicit download trigger, install-on-quit and release notes at check time. The old experience used none of them. Updates downloaded silently, and the only UI was a bottom-left banner with a "Restart" button that appeared once the download had already finished. There was no opt-in download, no release notes, no progress and no way to browse the changelog.
Changes
Three user-facing additions, built on those primitives:
updates.setAutoDownloadprocedure.GitHubReleasesService(in workspace-server, publicGET /repos/PostHog/code/releases, Zod-parsed and cached). The current version is marked, and the modal auto-shows once on the first launch after an update installs (tracked with a persistedlastSeenChangelogVersion).Plumbing:
IUpdatergainsdownload(),onDownloadProgress()andsetAutoDownload(), andonUpdateAvailablenow carries the release notes. The electron-updater adapter setsautoDownloadto false andautoInstallOnAppQuitto true and wires thedownload-progressevent.UpdatesServicegains an "available" state, download progress and the auto-download decision, and the status payload plus the renderer stores carry the new fields.Auto-update stays macOS and Windows only; the What's New changelog works on every platform.
Stacked on #2817.
How did you test this?
pnpm typecheck(22 of 22),pnpm lintandpnpm buildall pass.pnpm testpasses. New unit tests cover theUpdatesServicetransitions (available, then requestDownload, then downloading, then ready, plus the auto-download branch) with a fakedIUpdater, and theGitHubReleasesServicemapping, caching and error handling with a faked fetch.Automatic notifications