Skip to content

fix(desktop): keep checking for updates after one is offered - #298

Merged
hadrysm merged 2 commits into
mainfrom
fix/updates-supersede-stale-offer
Oct 16, 2026
Merged

hadrysm merged 2 commits into
mainfrom
fix/updates-supersede-stale-offer

Conversation

@hadrysm

@hadrysm hadrysm commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Why

When a nightly was published while Voice already offered an earlier one, Voice installed the earlier nightly. Fifteen seconds after relaunch it offered the newer one, so the user restarted twice. check() returned early while the status was available or ready, so the startup check, the poll, the tray item, and Settings never saw the newer release. #154 added that rule to keep a background poll from closing the release card.

Now every check runs. While an offer is on screen, a check publishes only when the result changes the offer, so the card stays open. T3 Code fixed the same bug the same way in pingdotgg/t3code#6269.

Scope

  • reconcile() in apps/desktop/src/main/updates.ts takes the status the user sees and a check outcome (offer, none, or error) and returns the next status.
    • A newer release replaces an available offer.
    • A newer release replaces a ready download and starts to download at once, because the user already chose to download. The status leaves ready before electron-updater deletes the staged file.
    • A ready download survives a failed check and an empty check.
  • download() reads the feed again before it downloads, because electron-updater downloads whatever its last successful check stored. If the read fails or the feed no longer offers the update, nothing downloads.
  • After restart() starts, a late check result or download progress publishes nothing. restart() waits for a check still in flight before quitAndInstall, and onError reports an install failure only when no check or download runs. Without that, a failed hourly check during Restart showed an install-failure dialog while the install went ahead.
  • download() waits for a background check in flight, then reads the status again. Before, a click during a check did nothing.
  • generation alone marks stale results. restart() and dispose() increase it, the same way setChannel() does, which removes the restarting flag.
  • The poll interval drops from 4 hours to 1 hour.

Tradeoffs

T3 Code sends a superseded download back to a Download button. This change downloads the newer release at once, so the user still restarts only once.

Blast Radius

The change touches update checks in packaged builds on both channels. Development and test-mode builds have updates disabled. restart() now waits for a check still in flight before quitAndInstall. A check takes about a second, and a hung check delays the restart at most until its request times out.

Verification

  • The fake engine in updates.test.ts models electron-updater 6.8.9. A check compares the feed with the installed version, and downloadUpdate stages the release from the last check that found one. The regression test failed on main with expected [] to deeply equal [ { kind: 'downloading', … } ] (1 failed, 21 passed). It passes now (38 tests in the file).
  • Each of these mutations fails its test: no restart guard, checking published on every check, a download after a failed re-read, no wait for the in-flight check in restart() and in download(), and an onError that ignores a running check. The fake engine emits error when a check or download rejects, as electron-updater does.
  • A three-model review (structure, correctness, adversarial) found the Restart and Download races. Both are fixed in the second commit.
  • tsc --noEmit, vp lint, and vp fmt --check pass.
  • Not run against a live feed, because updates are disabled outside packaged builds.

check() returned early while an update was available or ready, so a
nightly published after the offer stayed unseen until the next launch.
Users installed the older nightly and then updated a second time.
@github-actions github-actions Bot added the size:M 30-99 effective changed lines (test files excluded in mixed PRs). label Oct 16, 2026
@hadrysm
hadrysm added this pull request to stack #300 October 16, 2026 18:45
…load

Since updates kept polling while an offer or a download stood, a click
could land while the hourly check was mid-flight. Clicking Restart and
then losing the network made electron-updater emit "error" from that
check; the install-failure listener saw the installing status, showed the
"could not be installed" dialog and queued a relaunch while quitAndInstall
still ran. Clicking Download during the same silent check was coalesced
into it: nothing was published and nothing was downloaded.

restart() now bumps the generation like setChannel and dispose, so the
check's late result is discarded, and waits for the check to settle before
quitAndInstall. The error listener treats an error as an install failure
only when nothing of ours is running. download() waits for a running check
and then decides again from the status it left behind.

The restarting flag is gone: "installing" is read from the status, and
stillApplies is the generation alone. publish() skips a status object that
already stands, which is reconcile's contract for "no change", and carries
the channel so a disabled build still broadcasts a channel switch. The
unreachable disabled guard in readFeed is replaced by narrowing once at
construction, and the download-failure status is one constant.

The fake updater emits "error" before any rejected check or download, as
AppUpdater does. That gap is what hid the first bug from the suite.
@github-actions github-actions Bot added size:L 100-499 effective changed lines (test files excluded in mixed PRs). and removed size:M 30-99 effective changed lines (test files excluded in mixed PRs). labels Oct 16, 2026
@hadrysm
hadrysm merged commit 1a1bfa2 into main Oct 16, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L 100-499 effective changed lines (test files excluded in mixed PRs).

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant