fix(desktop): keep polling after an update is staged - #76331
Merged
Conversation
|
😎 Merged successfully - details. |
charlesvien
marked this pull request as ready for review
August 1, 2026 08:04
Contributor
Prompt To Fix All With AI### Issue 1
products/desktop/apps/code/src/renderer/platform-adapters/updates.ts:137-146
**Failed flag sync blocks retries**
When the first `setStagedUpdates` mutation fails, `lastSyncedStagedUpdates` still records the value as synchronized, so later callbacks with the same flag value skip retrying and the main process keeps staged-update polling disabled for the session.
```suggestion
function syncStagedUpdates(): void {
const enabled = posthogFeatureFlags.isEnabled(STAGED_UPDATES_FLAG);
if (enabled === lastSyncedStagedUpdates) return;
lastSyncedStagedUpdates = enabled;
void hostTrpcClient.updates.setStagedUpdates
.mutate({ enabled })
.catch((error: unknown) => {
if (lastSyncedStagedUpdates === enabled) {
lastSyncedStagedUpdates = null;
}
log.error("Failed to sync staged-updates flag", { error });
});
}
```
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.Reviews (1): Last reviewed commit: "keep polling for updates after staging" | Re-trigger Greptile |
tatoalo
approved these changes
Aug 1, 2026
charlesvien
force-pushed
the
fix/desktop-update-repolling
branch
from
August 1, 2026 08:42
78b2874 to
7357942
Compare
charlesvien
force-pushed
the
fix/desktop-update-repolling
branch
from
August 1, 2026 09:20
7357942 to
bf188ae
Compare
Contributor
PR overviewAll previously flagged issues have been addressed. No open security concerns remain on this pull request. Security reviewNo open security issues remain on this pull request. Fixed/addressed: 1 · PR risk: 0/10 |
|
Note 🤖 stamphog reviewed Gates denied this PR (CI workflow change hit the infra_cicd deny-list, and size/scope classify it T2-never); it also touches security-relevant auto-update/rollback logic, so it needs human sign-off despite bot review coverage.
Gate mechanics and policy version
|
gantoine
approved these changes
Aug 3, 2026
Closed
2 tasks
Member
Author
|
/trunk merge |
joethreepwood
added a commit
that referenced
this pull request
Aug 5, 2026
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.
Port of PostHog/code#3860 into the monorepo (
products/desktop/), remade here because desktop now lives in posthog.Problem
Once an update downloads, the app stops its hourly update poll and ignores every later update event. Users update, restart and immediately get another "update available" prompt because a newer release shipped while the staged one sat waiting. Fixes the update chain reaction reported on Discord and Slack.
Changes
posthog-desktop-staged-updatesfeature flag, off by default. The renderer syncs the flag to the main process once posthog flags load. Flag off keeps the legacy flow. Flag on after staging restarts the poll.UpdatesServicekeeps the hourly poll running in theavailableandreadystates. Periodic checks run silently with no UI flicker.autoUpdater.autoDownloadis now permanently false andIUpdater.setAutoDownloadis removed. The service is the sole caller ofdownload()and downloads are serialized (queueDownload) because electron-updater silently no-ops adownloadUpdate()while a previous one is still in flight.deriveUpdateUiStatusclears the stale staged version on the newly reachable transitions out ofready.desktop-update-e2e.ymlgains the chained re-stage leg (stage 2.0.0, bump feed to 3.0.0, re-stage, restart lands on 3.0.0), re-derived from the source workflow per the MIGRATION.md transform rules rather than patched.Port notes:
apps/code/snapshots.ymlfrom the original PR is intentionally skipped. It is the PostHog/code VR baseline and desktop storybook CI was removed from the monorepo (see MIGRATION.md).How did you test this code?
Automated only, run from
products/desktop/:pnpm typecheck: 24/24 packages pass.pnpm --filter @posthog/core test: 2880 tests pass, including the new suites for background polling, re-staging, the downgrade guard, download serialization, rollback and error fallbacks, plus flag-off coverage of the legacy flow.pnpm --filter @posthog/shared test: 769 tests pass.pnpm exec biome lint packages/core: clean.actionlintandhogli lint:workflows: clean.The chained e2e leg passed on the source repo's Code Update E2E (macOS) workflow (run 30349976739, chain proof PASS). Here it runs in the nightly
desktop-update-e2e.yml, which I did not trigger.Automatic notifications
Docs update
N/A
🤖 Agent context
Autonomy: Human-driven (agent-assisted)
Claude Code ported the open PR PostHog/code#3860 onto
products/desktop/at Charles's direction. The tree diff applied cleanly via 3-way apply against the pinned import SHA. Decisions: skipped thesnapshots.ymlVR baseline (storybook CI removed post-import, per MIGRATION.md) and re-derived thedesktop-update-e2e.ymlchanges using the MIGRATION.md transform rules instead of hand-merging the source diff.