Skip to content

fix(update): always install the newest build, never a superseded download - #9367

Closed
cixuuz wants to merge 1 commit into
mainfrom
fix/update-always-installs-newest
Closed

cixuuz wants to merge 1 commit into
mainfrom
fix/update-always-installs-newest

Conversation

@cixuuz

@cixuuz cixuuz commented Sep 8, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: an update always installs the newest build the feed serves, never a download the feed has already moved past.

The desktop app downloads an update, then waits for a click on "Install Update & Restart App" or for the next natural quit after "Later". Nothing in that window re-consulted the feed, so when a newer release shipped the app installed the superseded stage anyway:

  1. auto-download stages 1.1.0;
  2. 1.2.0 publishes while the ready card sits unclicked;
  3. the install lands 1.1.0 and the app relaunches on an already-stale build;
  4. the next check finds 1.2.0 and the ~350MB transfer runs again.

The consent path (auto-download off) had the same waste: a click on a stale "found" card fetched the version printed on the card. On the dashboard's in-app update, api_update_arm armed a cached verdict up to 12 hours old, which the apply then refuses once the feed has moved.

Why it matters

Every affected user pays the transfer twice and restarts twice, and the second restart looks unprompted: the app they just updated immediately announces another update. On metered or slow links ~350MB of avoidable traffic is the whole cost. The in-app arm path is worse: it hands the user an approval command that cannot succeed.

Not a goal

What changed (motivation → approach → change)

Root cause. Supersede detection lived only in the update-available handler, which runs only when a check runs (every 4 hours). The install paths committed on updateReady alone.

Approach. Put the freshness question at the last step of every path that spends bytes or commits an install, and answer it with an ordinary check, so the direction gate, retraction path and supersede path decide, not a second copy of the rule.

Change.

  • website/electron/runtime/update/feed-lane.js (the feed lane split out of auto-update.js on main): a freshness gate runs before the consent download, the manual install and the deferred install on quit. It issues a check or waits for the one already in flight, bounded at 8s and failing open (a check it stops waiting for is abandoned, so its late outcome cannot touch the dispatch); only a positive "the stage is gone" refuses an install. A Download click is answered at once with downloading. The quit path signals installing first, holds a second Cmd+Q while it waits, and refuses quietly with a notification.
  • The gate's collisions with ordinary checks are closed: errors are attributed by rejection identity; a held quit is replayed in one finally; a gate that joins an abandoned check lifts the abandonment so its answer counts; a channel switch re-checks the new lane once the old request has settled, and a gate that wakes behind a newer check stands down; the gates' own checking, failure and restated offer stay off the renderer.
  • website/src/hooks/useInstallDispatch.ts (shared by website/src/components/UpdateModal.tsx and the About card in website/src/pages/settings/AboutPanel.tsx) resets the one-way install latch when the handoff is refused or aborted; the modal reports a rejected install request through ErrorNotice under an "Update failed to install" header. The About card's agent-request click is armed only while its download runs, and is released when the gate drops that download.
  • api_update_arm (src/kiro_crew/dashboard/handlers/updates.py) re-checks before arming and returns version_display (typed in website/src/api/client/updates.ts). It restores the pre-check snapshot on a failed check only while _check_generation matches. A positive "no longer offered" answers arm_no_longer_offered, and an upgrade click the re-check turns into a channel-move downgrade answers arm_offer_withdrawn (no "already up to date" claim, since the next frame offers that move).
  • Copy: three armed-panel strings and two localized refusals (arm_no_longer_offered, arm_offer_withdrawn), in all 12 catalogs under website/src/i18n/locales/.

Backwards compatibility

Compatible: api_update_arm keeps every field and code it returned and adds version_display and the arm_no_longer_offered refusal; the renderer tolerates a gateway without the field. The updater's IPC surface is unchanged.

Tests

  • website/electron/test/auto-update-freshness.test.js (new): superseded, latest, retracted and versionless stages on both install paths; fail-open on unreachable, silent and hanging feeds; waiting for an in-flight check; the abandoned-check and straddling-check attribution; the held and replayed quit; no nudge or download while quitting; the Download gate's channel switch, joined-check lift and stand-down, against feedLikeElectronUpdater(), a harness that models electron-updater's in-flight dedupe.
  • website/electron/test/auto-update.test.js: existing straddle tests drive the 8s bound with mocked timers.
  • website/electron/test/electron-updater-error-identity.test.js (new): asserts against the installed electron-updater source that error and the rejection carry the same object; fails under CI when the library is missing, and is visibly skipped elsewhere.
  • test/test_update_stepup.py: re-check pins the newest version, fail-open restore, the generation guard, the downgrade refusal, and both refusal codes.
  • website/src/test/AboutPanel.inAppApply.test.tsx: armed copy, the click-time offered version, an older armed build, both localized refusals, and which notice a new offer retires. AboutPanel.agentUpdateRequest.test.tsx: the agent-request click installs once, and is released by a dropped download but not by the state it was clicked from. AboutPanel.installFailureReplay.test.tsx and UpdateModal.cov80.test.tsx: the latch re-arms after a refused install, and a rejected install request is reported.

Each fix added in the last two rounds was mutation-checked: reverting it fails its test.

Manual verification

The armed panel was captured against the built SPA with the gateway stubbed by website/scripts/capture-update-freshness-armed.mjs. Its copy is unchanged by the latest round; the refusal now renders from the catalog with the same English text. The native quit-time notifications are drawn by the operating system's notification centre during quit, after the window is gone, so neither the browser harness nor a running window can show them; a mock-up would be evidence of a surface nobody could verify. Their copy is listed verbatim below.

Title Body Fires when
Update canceled The staged update was withdrawn or superseded, so it was not installed. You'll be offered the latest version next launch. the quit-time gate finds the stage is no longer the newest
Update not installed The update could not be installed on quit. You'll be offered it again next launch. the installer refuses during a deferred quit-install
Update not installed A version check was still running at quit, so the update was left for next launch rather than risk installing a superseded build. defensive: a check the gate did not wait out is still running once the gateway has stopped

Screenshots / video

The offer, from a verdict up to 12h old:

in-app update offer, light

Armed after the pre-arm re-check found a newer version; the note replaces the plain line and explains the change:

armed panel naming v0.4.8 with the changed-version note, light

Armed on the version the button offered; no note, one declarative line:

armed panel when the armed version matches the offer, note absent

The arm button while the re-check runs:

arm button pending, spinner and Checking for updates

The refusal when the offer is gone (now rendered from the catalog):

arm refused — this update is no longer offered, you are already up to date

The refusal when the clicked upgrade became a channel-move downgrade; it names the withdrawal and the offer that replaces it, and stays up when that offer arrives:

arm refused — this update is no longer offered

Channel move, armed as offered (armed_switches_to_version):

armed channel move — this switches to v0.4.7, the release on the channel you chose

Channel move whose target moved between the offer and the arm (armed_version_changed_channel_move):

armed channel move — this switches to v0.4.6, the channel you chose now serves that instead of the v0.4.7 shown before

The desktop "update ready" modal when the install request itself is rejected (the main process threw before pushing any state). The header and the notice both say it failed, and the primary action says it retries:

update modal reporting a rejected install request

Dark mode

update modal reporting a rejected install request, dark

in-app update offer, dark

armed panel naming v0.4.8 with the changed-version note, dark

Related Issues

No linked issue: reported directly by a user in a chat session. Follow-up refactors: #10282, #10333.

Pattern harvest

Rule candidate: review-prompt

Pattern: a bounded wait (Promise.race against a timeout) that clears flags owned by the request in its timeout branch. The wait ended; the request did not, so its late outcome lands in a window the code believes is impossible. Release request-owned state from the request's own continuation.

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title (feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable)
  • No secrets, credentials, or internal references in the diff

@cixuuz
cixuuz requested review from a team and smeyffret September 8, 2026 03:44
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Sep 8, 2026
@github-actions

github-actions Bot commented Sep 8, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Fable 5) — 🟡 CONCERNS

Design-level review of 4748901a49f1ade4da628832fa8dcd9b241192bf — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

Design-Verdict: CONCERNS

Install-failure attribution now hinges on an undocumented electron-updater emit/reject identity pairing, policed only by a canary test until the tracked refactor removes it.

Watch

  • The identity scheme (abandonedError/inFlightCheckError, the setTimeout(0) deferrals in the shared error handler) depends on checkForUpdates() emitting and rejecting the same object — the diff itself concedes "Nothing in the library documents that pairing." If a bump rewraps the error, a check's feed failure is reported as the installer's (or vice versa) with the gateway deliberately stopped, exactly the misattribution the scheme exists to prevent. The canary test and the release.md note are good mitigations, but they make every electron-updater bump a manual re-verification event; the deferred side-effect-free feed query (refactor(update): make the still-latest verdict a pure function a quiet feed read can share #10333) would eliminate the scheme and roughly eight of the new interacting flags.
    Clears when: refactor(update): make the still-latest verdict a pure function a quiet feed read can share #10333/refactor(update): replace initAutoUpdate's boolean lattice with an explicit phase enum #10282 land, or a maintainer explicitly accepts the canary-guarded identity scheme as the enduring shape.
  • The abandoned-check exemption narrows a prior guarantee: pre-PR, the manual path aborted on any check in flight at dispatch ("no check outcome … can land in the middle of an actual bundle swap"); now a feed that hangs past 8s installs the stage even if a retraction was published in that window — the diff accepts it in-code ("a withdrawn build can still install. That is fail-open behaving as specified"). The purpose of the old pin is preserved via handler neutralization, but the retraction half is consciously traded away for one window.
    Clears when: a maintainer confirms the hung-feed fail-open trade against the retraction guarantees release.md documents.

[DESIGN-REVIEWED] 4748901

Description read

[DESCRIPTION-READ] b7c0eb8e880d215753d3c97cd5fe5640c21801d53dcb9539ad1ffa9e59354993

That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Sep 8, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Fable 5) — ✅ PASS

Premise-level review of 4748901a49f1ade4da628832fa8dcd9b241192bf — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

First-Principles-Verdict: PASS

Verify the accepted fail-open consequence: a retraction the feed delivers after the 8s abandonment window still installs the withdrawn build — stated only in a code comment.

Not justified as shipped

  • Item 6 — rides along: a quit-time installer rejection now quits with an "Update not installed" notice; on base that failure was mislabeled check with the gateway stopped — a sibling defect the quit path's new installing claim forced this PR to define.
  • Item 9 — rides along: the modal's ErrorNotice for a rejected install IPC fixes silent re-arming, not the superseded-stage defect; the shared latch reset in useInstallDispatch is the part the fix needs.

What this change ships

Inventory (10 items) — 8 justified

Intent: an update must always install the newest build the feed serves, never a superseded download — a FIX, with the defect reproduced in the description and pinned by tests that fail on base.

  1. "Install Update & Restart" re-checks the feed; a superseded stage is refused and the newer build pursued — justified
  2. Install-on-quit re-checks; a stale stage quits uninstalled with a native "Update canceled" notice — justified
  3. A Download click re-checks before spending the transfer and fetches what the feed now offers — justified
  4. A hung feed no longer dead-ends the install: 8s bound, fail-open, late check outcomes made inert (replaces the abort-on-checking pin, whose own stated purpose — no check outcome lands mid-swap — the abandonment and error-identity mechanism preserves, with new pins) — justified
  5. A second Cmd+Q during an install's gate is held and replayed, never silently dropped — justified
  6. A quit-time installer rejection finishes the quit with an "Update not installed" notice — rides along, declared in the notification table and tests
  7. Arming re-checks the feed; two new 409 refusal codes; the armed panel names the version that actually installs (version_display, strings in all catalogs) — justified
  8. A void offer stands down the panel's intro and button, leaving the refusal the only claim — justified
  9. UpdateModal reports a rejected install request ("Install failed" / Try again) instead of silently re-arming — rides along; the latch reset it shares is the fix
  10. The error-object-identity premise is pinned against the installed electron-updater source and documented as a bump re-verification event — justified

Capped at 10: the agent-request arming narrowing, the arm button's checking spinner, and the showNotice refactor are smaller consequences of items 3, 7 and 2. Counts run: supersede logic existed only in update-available (the gates reuse it via an ordinary check rather than a second spelling); useInstallDispatch has 2 consumers and deletes a duplicated latch; version_display and both refusal codes each have 1 real consumer, ungeneralized; 734 capture-*.mjs siblings make the capture script house convention; compareVersions and ErrorNotice are reused, not re-invented.

[FIRST-PRINCIPLES-REVIEWED] 4748901

Description read

[DESCRIPTION-READ] 29feaa77b48a51bda8c6deb32f1581a2cba90156be2f7a4cde86ad5b3065a3e9

That sha256 names the PR description this verdict read. Recompute it with .github/scripts/pr-description-capture.sh; if it differs, the description changed after this verdict was formed and any finding drawn from the description is unproven.

@github-actions

github-actions Bot commented Sep 8, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Fable 5) — 🟡 CONCERNS

UX-level review of 4748901a49f1ade4da628832fa8dcd9b241192bf — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

UX-Verdict: CONCERNS

The withdrawn-offer explanation lives inside the offer it refutes: the next ≤5s status frame unmounts both, so the refusal can vanish mid-read.

Watch

  • Shot-05: "This update is no longer offered — you're already up to date" renders beneath badges still saying "Update available", and the diff's own comment concedes the next ≤5s status frame unmounts the offer and the notice inside it — a user who clicked sees a red flash, then an empty panel. The blind reader: "I cannot reconcile those." Rare (offer withdrawn between poll and click) but every occurrence; smallest fix is the hoist the comment in AboutPanel.tsx's onError already names — render the refusal above the offer's mount condition so it outlives the frame.
  • Same one-frame lag makes shot-08 self-contradict: the channel warning still says "stable currently publishes v0.4.7" while the fresh armed note says it serves v0.4.6. Self-heals on the next frame; worth a human confirming 5s is the real ceiling on a live gateway.

[UX-REVIEWED] 4748901

Description read

[DESCRIPTION-READ] 8413bf8fc88931c20877509a630cbac4d92b8669bb2cab7c0123b59f9d15d52c

That sha256 names everything this verdict read: the PR description, plus the 15 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Sep 8, 2026 •

Copy link
Copy Markdown
Contributor

GPT 5.6 Review — ✅ no blocking findings

GPT 5.6 completed its review of 4748901a49f1ade4da628832fa8dcd9b241192bf and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 4748901

False positive or not applicable? A repository writer can comment:
/ai-review override gpt 4748901a49f1ade4da628832fa8dcd9b241192bf: <one-sentence reason>

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Sep 8, 2026
@github-actions

github-actions Bot commented Sep 8, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5 Review — ✅ no blocking findings

Reviewed 4748901a49f1ade4da628832fa8dcd9b241192bf — this comment is updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] 4748901

Verdict parsed from the review's SHA-scoped output markers for commit 4748901a49f1ade4da628832fa8dcd9b241192bf.

False positive or not applicable? A repository writer can comment:
/ai-review override fable 4748901a49f1ade4da628832fa8dcd9b241192bf: <one-sentence reason>

@cixuuz
cixuuz force-pushed the fix/update-always-installs-newest branch 2 times, most recently from 537d995 to fc9dab2 Compare September 10, 2026 22:21
@cixuuz

cixuuz commented Sep 10, 2026

Copy link
Copy Markdown
Contributor Author

Answering every raised concern. Head is now fc9dab2e8 (rebased onto 9d72a705).

GPT — F1 [BLOCK-MERGE]: a deferred install's failure leaves the gateway stopped

Fixed, but deliberately not the way the finding prescribed, and that difference is worth a look.

The prescription was "mark the deferred dispatch as installing so genuine installer errors trigger recovery." The first half is done — deferredInstalling = true is claimed at auto-update.js:2281, right beside installing = true, so reportUpdaterFailure now derives phase: "install" instead of misreading the failure as a check's.

The second half cannot work on this path, so I did something else:

  • onInstallFailed → recoverWedgedGateway is gated at gateway-recovery.js:326 — if (!isMac || quitting || installingUpdate) return "none"; — and again at gateway-supervisor.js:1272. isQuitting is already latched by the time this failure arrives, so recovery is a guaranteed no-op.
  • The quit path also never calls onInstallDispatched() (see the note at auto-update.js:2230), so installingUpdate was never set for it in the first place.

So firing recovery would be a no-op that leaves the app alive holding a window the user asked to close, on a quit that was preventDefault'ed and is still parked. Instead the failure finishes the quit (auto-update.js:2381-2396): reset the flag, log, notify, emit error/phase: "install" to the renderer, app.quit(). The staged build survives on disk and is re-offered next launch, which is exactly what its notification promises — deliberately separate copy from the superseded-refusal string, whose "withdrawn or superseded" would be a false statement here.

Making recovery actually work on this path would mean editing main.js's quit lifecycle, which is outside this PR.

Design — the discriminator rests on the library's emit/reject ordering

This is answered by the exact mechanism the concern named as its clearing condition: "capture the abandoned request's rejection error in its continuation and compare inside the macrotask."

That is abandonedError (auto-update.js:1619, captured at :1957, compared at :2450 as if (err === abandonedError)). Identity, not ordering — so it is the only read that survives two errors landing in one tick, in either order.

The Suggestion (known gaps live only in the PR description) is also done: all three are now carried at their own site in the code, not just here. Gap 1 was already documented; gaps 2 and 3 have new comments in the update-not-available abandoned-check branch and in updates.py respectively.

First Principles — same ordering claim, plus "the harness bakes that ordering in"

Same abandonedError answer for the first half. For the second: the harness now has a seam that drives the opposite order — failsRejectFirst (electron/test/auto-update-freshness.test.js:129, exercised at :831), which rejects before emitting. The discrimination holds under both, which is the point of using identity rather than sequence.

UX — the armed panel can silently name a different version than the one clicked

Implemented as the concern's own "smallest fix": one muted sentence, rendered only when the two versions actually differ.

armed_version_changed — "The feed was re-checked while arming, so this installs v{{version}} — not the v{{offered}} offered a moment ago."

Note for reviewers: rebase interaction with #9304

This branch was rebased onto 9d72a705, which conflicted with #9304 (allow managed-venv channel downgrades) in updates.py. Resolving it surfaced a real bug in this PR, caught by that PR's new test:

test_arm_refuses_when_check_reports_nothing_to_apply sets resolve_provider to None, so the pre-arm re-check fails and the handler falls back to the cached verdict. My new arm_no_longer_offered branch fired on that cached available is False — claiming "the feed no longer offers this update" on a path where no feed answer was ever obtained.

The branch is now gated on not check_failed as well as move_pending is not True: a positive retraction from a successful re-check gets the new code, while a stale cached False keeps the older arm_no_verdict. #9304's test passes unmodified — I did not adjust its assertion. 212 tests green across the five affected update suites.

@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Sep 10, 2026
@cixuuz
cixuuz force-pushed the fix/update-always-installs-newest branch from fc9dab2 to 92e6513 Compare September 10, 2026 22:49
@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Sep 10, 2026
@cixuuz
cixuuz force-pushed the fix/update-always-installs-newest branch from 92e6513 to dbadda5 Compare September 11, 2026 00:03
@cixuuz

cixuuz commented Sep 11, 2026

Copy link
Copy Markdown
Contributor Author

CodeQL finding on website/scripts/capture-update-freshness-armed.mjs (incomplete string escaping) is fixed in dbadda5f5.

The button lookup escaped only dots (OFFERED.replace(/\./g, '\\.')), so a backslash in the input could change what the pattern matches. Replaced with a full metacharacter escape:

const escapeRe = (s) => String(s).replace(/[.*+?^${}()|[\]\\]/g, '\\$&')

Not exploitable as written — OFFERED is the literal '0.4.7' — but the partial escape was wrong on its own terms, and a silent miss here would screenshot the wrong panel and quietly weaken the evidence this PR rests on. Verified the escape still matches the real button text and rejects a non-literal variant.

@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Sep 11, 2026
@cixuuz
cixuuz force-pushed the fix/update-always-installs-newest branch from dbadda5 to c652171 Compare September 11, 2026 00:40
@cixuuz

cixuuz commented Sep 11, 2026

Copy link
Copy Markdown
Contributor Author

Acted on the remaining advisories in c652171e1. All four were worth taking rather than deferring.

The single-flight gap is now closed, not deferred. GPT flagged it and First Principles asked for a tracked follow-up; three lanes converging on the gap I self-disclosed was enough signal that "follow-up" was the wrong call.

_do_update_check takes wait: bool = False, and a new _check_done event gives an in-flight check something to await. api_update_arm passes wait=True, so a status poll holding the guard no longer turns the re-check into a no-op that arms the stale verdict. Background pollers keep the no-op deliberately — awaiting there would serialize the status frame behind a CDN fetch, which is what the single-flight guard exists to prevent. Same contract checkInFlight already gave the Electron click.

Pinned by test_a_straddling_check_is_awaited_rather_than_arming_the_stale_verdict. Reverting just the wait=True kwarg fails it with AssertionError: assert '0.4.7' == '0.4.8' — literally the stale version being armed. A second test asserts the default still returns rather than parking, so the poll path stays fire-and-forget.

UX — the false notification is fixed. Correct catch: !updateReady || (checking && !abandonedCheck) called one notifyInstallCanceled() for two different facts, and on the straddling-check arm "withdrawn or superseded" was untrue — the same build is re-offered next launch, contradicting the notice. Split into notifyInstallDeferredForCheck(). The existing test for that path counted the notification but never read its body, which is exactly how the wrong copy survived; it now asserts the retraction wording is absent and the real reason is present.

UX — took your copy verbatim for armed_version_changed: "A newer version was found just now, so this installs v{{version}} — not the v{{offered}} offered a moment ago." Your blind-reader result on "arming" is more authoritative than my wording, and the string exists precisely to be readable at that moment. Also applied the styling suggestion (text-[13px] text-text) and regenerated the pseudolocale.

CodeQL — incomplete escaping fixed with a full metacharacter escape.

Green locally: 292 Python tests across the affected update suites, 1890/1891 electron (1 skipped), 41/41 freshness, 12/12 AboutPanel, and i18n 19/19 checks PASS.

Not addressed — your evidence gaps, and I want to be straight about why. The armed-panel-with-matching-versions capture and the two OS notifications are all genuinely missing. Capturing them needs a live pod plus a way to photograph native notifications, which I could not stand up here. That is a real hole in the evidence, not a resolved item — flagging it rather than quietly closing it.

@cixuuz
cixuuz force-pushed the fix/update-always-installs-newest branch from c652171 to 4e8982b Compare September 11, 2026 00:57
@cixuuz

cixuuz commented Sep 11, 2026

Copy link
Copy Markdown
Contributor Author

Frontend Tests failure fixed in 4e8982b56 — and it was a real hole in this PR, not a flake.

catalogParity.test.ts failed for 11 locales: pages.settings.aboutPanel.armed_version_changed existed in en.manual.json but in none of the translated catalogs. Every sibling key in that block (armed_run_on_host, in_app_update_intro, or_update_manually) is present and genuinely translated in all 11, so English passthrough would not have matched the convention here.

Added real translations for de, es, fr, it, pt, ru, ja, ko, zh-CN, hi, bn — inserted next to armed_run_on_host to preserve key ordering, with {{version}} / {{offered}} placeholders intact and each file re-parsed as JSON before writing. catalogParity is now 77/77 and the i18n gate is 19/19 PASS with the base resolved.

Worth flagging that this was latent from the moment the string was introduced — earlier rounds reported 0 failing only because Frontend Tests had not finished yet, so my "green" claims in this thread were premature on that check. A translator should still review the 11 strings; they are my translations, not a native speaker's.

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Sep 11, 2026
@bolichen97

Copy link
Copy Markdown
Contributor
  • span=443943f3035a 'which appears here' promises something not yet on screen — fixed in c886872

Future tense in all 12 catalogs: '…your channel now offers a different version, which will appear here in a moment.' The notice stays up when that offer arrives. Screenshot refreshed.

@bolichen97

Copy link
Copy Markdown
Contributor
  • span=78b1cd82c7ce the modal says 'will close and relaunch automatically' beside the failure — fixed in c886872

While the install request has failed, the modal no longer renders the relaunch-timing paragraph; only the true 'downloaded and ready' headline, the failure notice and the retry remain. Pinned in UpdateModal.cov80.test.tsx; light and dark captures refreshed.

@bolichen97

Copy link
Copy Markdown
Contributor
  • span=a7b82f90fbd9 stale status copy for one frame after a refusal or arm — rebutted

One frame IS the worst case: the pre-arm re-check writes the shared update cache BEFORE the arm answers, and the Tier-0 status push that renders the badge, pill and channel-move intro reads that cache every 5s, so the very next frame carries the fresh verdict. The screenshots freeze the stub's static status, which a real gateway refreshes.
Closing even that frame means hoisting the refusal above the offer's mount condition, a page-level restructure of Settings > About outside this PR's goal.

@bolichen97

Copy link
Copy Markdown
Contributor
  • span=3936ee44a23f modal ErrorNotice for a rejected install IPC rides along — rebutted

This PR rewrote the modal's install dispatch (the shared useInstallDispatch latch), and the GPT lane blocked that head because the rewritten dispatch left a rejected IPC silent (AUTOSDE errors-use-error-notice, blocking: true); a defect in code this PR changes is in scope. It reuses existing catalog keys and adds no surface.

@bolichen97

Copy link
Copy Markdown
Contributor

Retrospective (round 3; span b62fe08b529e recurred ×3). The recurring span is path-scoped to feed-lane.js, so it groups three DIFFERENT GPT findings: a joined check left live past the bound, a channel switch during the install gate, and the same switch during the download gate. All three are siblings of one mechanism, the freshness gate, found at different entry points. Ruling per mechanism added since the first judged head:

  • abandon-what-you-stop-waiting-for (joined check, download gate): keep. Removing it reopens the aborted install after a wasted gateway stop, and the dead Download click.
  • channel-vs-verdict guard (install and download): keep. It is one comparison per entry point; removing it installs or downloads a lane the user left.
  • event-time failure phase: keep. Removing it reopens the download-failure-reported-as-check regression the deferral introduced.
  • modal rejected-IPC notice + Try again, arm_offer_withdrawn + notice retention: keep. Each is a small fix for a blocking or upheld finding.

The closing invariant: every gate entry point (download, manual install, quit install) waits through withinFreshnessBound, abandons a check it stops waiting for, and checks the verdict's channel against the current one. All three now hold, each pinned by a test. Goal unchanged.

@bolichen97

Copy link
Copy Markdown
Contributor
  • span=b62fe08b529e a channel switch during the Download gate lets the old lane's result reach downloadUpdate — fixed in a3a07b4

After the bounded wait the download gate compares feedChannel with the current preference and, when they differ, re-checks the new lane instead of downloading; the same guard the install gate got last round. Pinned by 'a channel switch during the Download click's check does not download the old lane's build' (mutation-checked).

@bolichen97

Copy link
Copy Markdown
Contributor
  • span=a14f366b3cab a download failure during the abandoned check is re-reported as a check failure — fixed in a3a07b4

The error listener now reads the failure phase when the event fires (failurePhase()) and passes it to the deferred reportUpdaterFailure(err, phase), so a download failure stays a download failure after downloading is cleared. Pinned by a test that emits-then-rejects a download failure under an abandoned check (mutation-checked).

@bolichen97

Copy link
Copy Markdown
Contributor
  • span=eecae205f184 the failed-install modal says ready and failed at once — fixed in a3a07b4

While the install request has failed, the modal drops the 'downloaded and ready to install' line and the relaunch-timing line, so 'Update failed to install' is the only status claim, and the primary button reads 'Try again'. Not install_failed_body: it says the gateway is being restored, which is false for a request the main process rejected before stopping anything. Captures refreshed (light and dark).

@bolichen97

Copy link
Copy Markdown
Contributor
  • span=1aa0de741b8d the up-to-date refusal beside the header badge for one frame — rebutted

Same one-status-frame lag already answered on earlier heads: the re-check writes the cache before the 409 returns and the next 5s Tier-0 frame clears the badge. Closing that frame needs the refusal hoisted above the offer's mount condition, a page-level restructure of Settings > About outside this PR's goal.

@bolichen97

Copy link
Copy Markdown
Contributor
  • span=eb71bb38d2ed the stale channel-pending note beside the armed switch for one frame — rebutted

The note is rendered from the status push, which the arm's own re-check refreshes before it answers, so the next frame names the armed version. In the capture it is the stub's static status. Re-keying the parent's note off the flow's armed state means lifting that state out of InAppUpdateFlow, a page-level change outside this PR's goal.

@bolichen97

Copy link
Copy Markdown
Contributor
  • span=654f34c30646 the rejected-IPC ErrorNotice in UpdateModal rides along — rebutted

This PR rewrote the modal's install dispatch (the shared useInstallDispatch latch), and the GPT lane BLOCKED that head because the rewrite left a rejected IPC silent (AUTOSDE errors-use-error-notice, blocking: true); a defect in code this PR changes is in scope. It reuses existing catalog keys and adds no surface.

…load

The desktop updater committed to an install on `updateReady` alone.
Supersede detection lived only in the `update-available` handler,
reachable only when a check ran -- every 4 hours. A download that waited
(auto-download stages eagerly, then the install waits for a click or the
next natural quit) installed whatever had been staged back then: the app
relaunched on an already-superseded build, the next check found the
newer one, and the ~350MB transfer ran again.

The feed lane (website/electron/runtime/update/feed-lane.js) now
re-consults the feed as the last step of every path that spends bytes or
commits an install: the consent download, the manual install and the
deferred install on quit. The gate drives an ordinary check, or waits
for the one already in flight (abandoning it if the wait runs out),
bounded at 8s and failing OPEN; a verdict about a lane the user switched
away from mid-check authorizes nothing. A feed
that cannot answer never makes downloaded bytes uninstallable, and a
hanging feed cannot hold a quitting app open. Only a positive "the stage
is gone" stops an install; a superseded stage is refused and the newest
build pursued, and the quit path refuses quietly with a notification.

A gate that issues a check is a second writer of updater state, so its
collisions with the first are closed explicitly: an abandoned check's
late failure is recognised by the rejection object rather than by flag
timing; a check straddling an install dispatch has its own failure
reported as the check's; a Cmd+Q while an install path owns the stage is
held and replayed; a gate (an install, or a Retry of the download) that
joins a check an earlier click abandoned lifts the abandonment so its
answer still counts; a re-check after a channel switch waits until
electron-updater has released its in-flight request, and a second click
that wakes behind it stands down; and the gates' own re-checks keep
their `checking`, their failure and a restated offer off the renderer,
which would unmount the card the user just clicked or the installing
overlay. A Download
click is answered at once with `downloading`. A failed install recovers
in place on the manual path and finishes the quit on the deferred one.

The renderer resets its one-way install latch when the main process
refuses or aborts the handoff (shared by UpdateModal and the About card
through useInstallDispatch), so the newer build's Install button is not
left disabled, and the modal reports a rejected install request under
a failure header. An agent request's install click stays armed only
while it waits for a download, and is released when that download is
dropped (a retraction or a channel switch), so it cannot re-fire on a
later build. A click made while the state is already `checking` or
`not-available` is not a dropped download: only those states after the
click's own `downloading` release it.

On the dashboard, `api_update_arm` re-checks before arming and returns
`version_display`. The re-check fails open by restoring the pre-check
snapshot only while `_check_generation` still matches, so a channel
switch cannot resurrect the previous lane's verdict. A positive "no
longer offered" answers `arm_no_longer_offered`, and an upgrade click
the re-check turns into a channel-move downgrade is refused with
`arm_offer_withdrawn` rather than armed; the panel localizes both, and
only the "no longer offered" notice is retired by a newer offer.

Co-authored-by: Bolin Chen <bolichen@amazon.com>
@bolichen97

Copy link
Copy Markdown
Contributor
  • span=b62fe08b529e a channel switch after a timed-out Download wait leaves the new lane unasked — fixed in 4748901

When the channel moved during the wait and the abandoned check still holds checking, the gate emits checking at once and queues safeCheck() on checkInFlight, which the check's owner releases only after electron-updater has dropped its in-flight request, so the re-check sends a new request to the new lane. A gate that later wakes behind that newer check stands down instead of downloading the old lane's build.
Pinned by 'a channel switch during a Download wait that timed out still asks the new lane once the old check ends' and a stand-down test on feedLikeElectronUpdater(), a harness that models the library's in-flight dedupe (both mutation-checked).

@bolichen97

Copy link
Copy Markdown
Contributor
  • span=b3c3fa36a41e an install from the agent request leaves the click armed — fixed in 4748901

installFromAgentRequest now arms the click only on the download branch; on a downloaded state it retires the request and dispatches without arming, so nothing can re-fire on a later downloaded once useInstallDispatch resets its latch. The armed click is also released when the gate drops its download (a retraction or channel switch after its own downloading).
Pinned by 'an install the main process refused does not re-fire on a later download' and the dropped-download tests in AboutPanel.agentUpdateRequest.test.tsx (mutation-checked).

@bolichen97

Copy link
Copy Markdown
Contributor
  • span=bac33f415133 the modal header says ready above a failed install — fixed in 4748901

When the install request is rejected, the dialog header and its aria-label read 'Update failed to install' instead of 'Update ready', and the ErrorNotice title is dropped so the failure is not stated twice. The fresh light and dark captures are in the PR body. Pinned in UpdateModal.cov80.test.tsx (mutation-checked).

@bolichen97

Copy link
Copy Markdown
Contributor
  • span=dce157613860 the no-longer-offered refusal under a still-lit badge for one frame — rebutted

One status frame is the worst case: the pre-arm re-check writes the shared update cache before the 409 returns, and the next 5s Tier-0 frame clears the badge and header button. The capture freezes the stub's static status.
Refetching status on refusal was tried: it unmounts the offer, and the refusal notice with it, which leaves the click unexplained. Closing the frame means hoisting the notice above the offer's mount condition, a page-level change outside this PR's goal (see AboutPanel.tsx onError).

@bolichen97

Copy link
Copy Markdown
Contributor
  • span=6551ba6eb68f the modal's install-error message restates the title — rebutted

The ErrorNotice title is gone, so the header is now the only 'failed to install' line and the message is the only body text. The message stays: ErrorNotice renders nothing without one, and askAgent hands that message to the agent.
A rejected install IPC carries no cause the user can act on, and 'Try again' is the action. A new string in 12 catalogs for this advisory suggestion is outside the PR's goal.

@bolichen97

Copy link
Copy Markdown
Contributor
  • span=b1b7343a19e7 item 8: the modal reporting a rejected install IPC rides along — rebutted

This PR rewrote the modal's install dispatch (the shared useInstallDispatch latch), and the GPT lane blocked that head because the rewrite left a rejected IPC silent (AUTOSDE errors-use-error-notice, blocking: true). A defect in code this PR changes is in scope. The change reuses existing catalog keys and adds no new surface.

@bolichen97

Copy link
Copy Markdown
Contributor
  • span=c4bb3abe5632 item 9: the deferred quit-install finishing the quit on an installer refusal rides along — rebutted

This PR moves the deferred install on quit behind its freshness gate, so that path's failure handling is code this PR rewrites. On that path the quit was preventDefault'ed and the gateway is already stopped, and before-quit-for-update never fires for a refused installer. In-place recovery would leave the app running with the window the user asked to close.
Finishing the quit with the 'Update not installed' notice (in the body's notification table) is what makes the gated path end. It is not separate hardening, and it is declared in the body.

@bolichen97

Copy link
Copy Markdown
Contributor

Pushed 4748901 (still one commit; Chen Tong is the author, Co-authored-by Bolin Chen; rebased onto main 57d71bb). This push covers the review on a3a07b4 plus two rounds of internal review:

  • Download-click freshness gate (feed-lane.js): the click is answered at once with downloading. A gate that joins a check an earlier click abandoned lifts the abandonment, so a retraction or a newer build in that answer still counts (Retry included). A channel switch re-checks the new lane only after the old request has settled. A gate that wakes behind a newer check stands down instead of downloading the old lane's build. The gates' own checking, check failure and restated downloaded stay off the renderer, so the clicked card and the installing overlay are not replaced.
  • Agent-request card (AboutPanel.tsx): the click is armed only while its download runs. It is released when the gate drops that download, but not by the checking/not-available state it was clicked from. Only an arm_no_longer_offered notice is retired by a new offer; other arm failures stay up until the next click.
  • Update modal: on a rejected install the header reads 'Update failed to install', and the ErrorNotice title is dropped. The modal captures in the body are refreshed.
  • Identity canary: electron-updater-error-identity.test.js fails under CI when the library is missing, and is visibly skipped elsewhere.
  • docs/build/release.md documents the Download gate, and the manual-path refusal is corrected (the card moves to what the feed serves, with no separate notice).
  • Simplify pass: the abandon and lift flag pairs go through abandonCheck() / liftAbandonment(), and the agent card's two release effects are now one.

Each behavioural fix has a test that fails without it. Local: static gates, docs-lint, eslint, tsc, i18n gates, Electron update tests 290/290, targeted backend update tests 672 passed, and the frontend AboutPanel/Update/hooks/i18n/settings subset 1889 passed. The full suite is left to CI. I posted a disposition for each finding on a3a07b4.

Copy link
Copy Markdown
Contributor

PR triage (automated, 2026-10-05) — REBASE needed

Checked head 4748901a49 against origin/main a97659dfc3. The merge base 57d71bb54e is 364 commits behind, and git merge-tree now reports a content conflict in website/src/components/UpdateModal.tsx. It comes from #16245 (a38c37a263, fix(settings): label the update switches by what each one does, merged 2026-10-04), which rewrote the modal's update-switch rows while this PR moves the install dispatch into useInstallDispatch. Everything else still merges cleanly, including handlers/updates.py after #16202, #16252 and #15838 landed, because api_update_arm itself is unchanged on main.

Triage result: DISTINCT. No other open PR touches feed-lane.js, UpdateModal.tsx, AboutPanel.tsx or api_update_arm. Main still has only the passive stage re-check after stopGateway(), and there's no active freshness check before download or install, so this fix is not covered by main. I found no breaking change (the /api/update/arm change only adds version_display and the arm_no_longer_offered/arm_offer_withdrawn refusals) and no P0 bug.

Recommendation: rebase onto current main and resolve UpdateModal.tsx against #16245's switch rows. Then re-run Frontend Tests (UpdateModal.cov80, AboutPanel.*). Heads-up: Issue Gate (#16241) is paused for now. Once it's enabled, a body with "No linked issue" will need a triaged issue reference.

@cixuuz

cixuuz commented Oct 18, 2026

Copy link
Copy Markdown
Contributor Author

Superseded by #21979, the same single commit rebased onto current main (4748901a49 → 81e0cfdc82) and pushed from a fork, because this account no longer has push access to the repository and this branch could not take the rebase. The review thread and disposition records here remain the history for that PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge conflict Branch has merge conflicts with its base — author must resolve before merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants