Skip to content

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

Merged
iamwhatever merged 1 commit into
kirodotdev:mainfrom
cixuuz:fix/update-always-installs-newest
Oct 23, 2026
Merged

iamwhatever merged 1 commit into
kirodotdev:mainfrom
cixuuz:fix/update-always-installs-newest

Conversation

@cixuuz

@cixuuz cixuuz commented Oct 18, 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.
  • website/electron/runtime/update/freshness-gate.js (new, composed by the feed lane): the check lifecycle (claim, settle, abandon, and the two identity-matched rejections) and verifyStageIsLatest, the pre-install verdict. feed-lane.js reads the check flags through the gate and keeps the handlers, the download gate and both install paths; it is 1,383 lines after the split, under the 1,600 the file-size rule allows. The facade auto-update.js is unchanged.
  • 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 (reporting checking at once on both gates, so a refused click never sits on the stale card while a hung request holds its socket), and a gate that wakes behind a newer check stands down; the gates' own checking, failure and restated offer stay off the renderer.
  • The old pin that no install proceeds with a check outstanding (check-in-flight, formerly a test in auto-update.feed-lane.test.js) is narrowed, not kept. The gate abandons every check it waits out and promises that install, so the post-stopGateway abort now fires only for a check the gate did not wait on at all, which is a stage that carries no version (nothing to compare). auto-update-freshness.test.js pins the narrowed rule on both install paths; the straddling-check tests in auto-update.feed-lane.test.js now assert that an abandoned check's late answer is inert and its own failure is not reported as the install's.
  • 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_step_up.py) re-checks before arming and returns version_display (typed in website/src/api/client/updates.ts). A check that cannot reach the feed refuses the arm (arm_no_verdict) and leaves the failed check in the cache for the panel to show: the managed-venv apply fetches the signed manifest before it installs, so an arm the feed cannot confirm is an approval the apply cannot carry out (unlike the desktop, whose staged bytes are already on disk). 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; the load-time test lists freshness-gate.js among the update runtime's modules and pins which file composes each one (the facade for the lanes and the reporter, feed-lane.js for the gate).
  • 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, a failed re-check refuses and keeps the failed verdict visible, the downgrade refusal, both refusal codes, and the straddling check is joined rather than refetched.
  • 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 notifications on the install-on-quit path are drawn by the operating system's notification centre; the three quit-time ones fire during quit, after the window is gone, so neither the browser harness nor a running window can show them, and a mock-up would be evidence of a surface nobody could verify. Their copy is listed verbatim below.

Title Body Fires when
Update deferred Kiro Crew will finish updating the next time you quit. "Later" on the native ready dialog (the lane without the in-app UI) arms the install for the next quit. Copy unchanged from main; it now goes through the same showNotice helper as the three below
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: #22825 (replaces #10282), #10333.

Continues #9367 from a fork: the author's account lost push access to this repository, so that PR could not take the rebase. Same single commit, rebased onto current main; its review thread and dispositions stay on #9367.

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 KiroCrewCaptain as code owners October 18, 2026 23:20
@cixuuz
cixuuz requested a review from buluoray October 18, 2026 23:20
@github-actions github-actions Bot added the fork Pull request from a fork (external contributor) label Oct 18, 2026
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Oct 18, 2026
@github-actions

github-actions Bot commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5, fork) — ✅ PASS (a BLOCK with no Trigger and no Outcome does not block)

UX-level review of bc5a13e45094e4df52f237932891c79d7085efca via the fork AI-review pipeline — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

UX-Verdict: PASS

cannot evaluate: missing the new desktop notification "Update not installed — A version check was still running at quit…". The renderer states are all covered by the 12 attachments; no first-time reader has seen any of them, because this lane has no blind read.

Evidence gaps

  • New native notification at quit. feed-lane.js adds notifyInstallDeferredForCheck(), which shows "Update not installed" with the body "A version check was still running at quit, so the update was left for next launch rather than risk installing a superseded build." No attachment shows it, and the recording list is empty. To close the gap, attach a screenshot of the OS notification as it appears after a quit that happens while a check is still running.

Notes

  • That notification body uses jargon and leads with the mechanism ("version check was still running", "superseded build"). Suggested replacement: "Kiro Crew will install the update next time you quit." or "…the next time it launches." That says the outcome and the promise.
  • In attachments 05 and 06, the refusal notice sits directly under "A new version is available." and next to the header badge "Update available". So "you're already up to date" is contradicted on the same screen until the next status update arrives. The code comment admits this lag. A follow-up should move the refusal notice out of the offer section, so the panel can refresh the page's update status right away without removing the notice.
  • In the update dialog's failed state (attachments 09 and 10), the header still uses the accent-colored Download icon. A failure header should use a warning or neutral icon, so it doesn't look like the old "Update ready" header.

[UX-REVIEWED] bc5a13e

Description read

[DESCRIPTION-READ] 0cd6105cfdcb0a977ad2126ccabbb4766907dc8a0609a04c07644e08b2ea1e6b

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 Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5, fork) — ✅ PASS

Premise-level review of bc5a13e45094e4df52f237932891c79d7085efca via the fork AI-review pipeline — 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 does not.

First-Principles-Verdict: PASS

No item blocks. The re-check reuses the existing supersede, direction and retraction handlers, and _do_update_check (updates_check.py:313) already joins an in-flight check.

Notes

  • Item 6 — undeclared default: a check that cannot reach the feed now refuses the arm (arm_no_verdict), where base armed the cached verdict. The stated support is that "the managed-venv apply fetches the signed manifest before it installs". That claim lives in code this PR does not touch, so nothing here checks it.

What this change ships

Inventory (9 items) — 8 justified

Intent: an update always installs the newest build the feed serves. FIX.

  1. A Download click re-checks the feed before the ~350MB transfer and fetches the newest build — justified
  2. "Install Update & Restart" re-checks; a superseded stage is refused and the card moves to the newer build — justified
  3. The install on quit after "Later" re-checks; a refusal quits with a native notification — justified
  4. A second Cmd+Q during the wait is held, and a quit during a manual install is held and replayed — justified
  5. The dashboard arm re-checks first and can arm a newer version than the button showed (version_display) — justified
  6. The dashboard arm refuses when the feed is unreachable — undeclared
  7. New refusals: arm_no_longer_offered and arm_offer_withdrawn, in 12 catalogs — justified
  8. A refused install releases the install latch and shows "Update failed to install" — justified
  9. The electron-updater error-identity canary test and the release.md bump rule — justified

[FIRST-PRINCIPLES-REVIEWED] bc5a13e

Description read

[DESCRIPTION-READ] 45206e1741663dc924d3d2c392d1e9d209f1d9455c0f315be1dea00c7aae06d6

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 Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5, fork) — ✅ PASS

Design-level review of bc5a13e45094e4df52f237932891c79d7085efca via the fork AI-review pipeline — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

Design-Verdict: PASS

Nothing blocks: every path that downloads or installs now re-checks the feed through the existing handlers, so the rules for which version wins are not duplicated.

Notes

  • When "Later" was chosen, Cmd+Q now waits up to 8s for the feed before quitting. Once this ships, watch for bug reports about slow quits.
  • The arm endpoint now refuses when the feed is unreachable, where it used to arm the cached verdict. That matches what the apply step can actually do, but offline users will now see arm_no_verdict on a click that used to succeed.

[DESIGN-REVIEWED] bc5a13e

Description read

[DESCRIPTION-READ] b28bd0c19ad18943cd4690c00dbae5a2f9703a83991536de7e0dabd37f53f756

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 Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review (fork) — ✅ no blocking findings

Reviewed bc5a13e45094e4df52f237932891c79d7085efca via the fork AI-review pipeline; updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] bc5a13e

@github-actions

github-actions Bot commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review (fork) — ✅ no blocking findings

Reviewed bc5a13e45094e4df52f237932891c79d7085efca via the fork AI-review pipeline; updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] bc5a13e

@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 Oct 18, 2026
@cixuuz
cixuuz force-pushed the fix/update-always-installs-newest branch from 81e0cfd to 4e61162 Compare October 19, 2026 00:51
@github-actions github-actions Bot removed the readiness: action required A blocking check or review needs attention label Oct 19, 2026
@cixuuz

cixuuz commented Oct 19, 2026

Copy link
Copy Markdown
Contributor Author
  • span=bb7fcaa32024 new tests use fixed sleeps as render/effect barriers — fixed in 4e61162

Every promise-sleep in AboutPanel.agentUpdateRequest.test.tsx is gone. React Query notifications run as microtasks for that describe block (notifyManager.setScheduler(queueMicrotask), the pattern MembersPageTestUtils.tsx and ContextBreakdownTab.push.test.tsx use), and each state push is wrapped in an async act(), so a negative install-count check reads a settled render.
Each negative is paired with a positive reading of the same render (the Install label names the new version and is enabled); each site was shown to fail against a broken latch, with and without the positive check.

@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Oct 19, 2026
@cixuuz

cixuuz commented Oct 19, 2026

Copy link
Copy Markdown
Contributor Author
  • span=0833e64bb79d setTimeout barriers before install-count and disabled assertions — fixed in 4e61162

Same change as the GPT lane's bb7fcaa32024: microtask notifications plus act()-wrapped pushes replace all five sleeps; the :265 site awaits the download mock's own promise inside act() before asserting toBeDisabled(), and the :273 loop asserts the disabled state after every intermediate render.

@cixuuz

cixuuz commented Oct 19, 2026

Copy link
Copy Markdown
Contributor Author
  • span=9bd55594462e the arm's snapshot restore overwrites a concurrent manual check's verdict — fixed in 4e61162

Confirmed real with a failing test in both join orders: all waiters share one worker via asyncio.shield and the arm, awaiting directly, resumes before api_update_check's gather child does, so the check read 'unchecked' with no error.
Snapshotting in api_update_check right after its gather (the first suggested fix) still failed the test; the fix that holds is the other one: _do_update_check returns whether another caller awaited the same worker, and the arm restores only when it was alone. A shared failure stands for every waiter and the arm answers arm_no_verdict.
New tests: test_a_manual_check_sharing_the_arms_failed_check_reports_the_failure[check|arm] (red on the judged head) and test_a_lone_arm_still_restores_through_the_shared_worker (fails against a return-True mutant).

@cixuuz

cixuuz commented Oct 19, 2026

Copy link
Copy Markdown
Contributor Author
  • span=c8c45f6cec2c the refusal reads as an alarm and contradicts the screen — rebutted

The badge and 'A new version is available' survive for one status frame at most: the pre-arm re-check writes the shared update cache before the 409 returns, and the next 5s Tier-0 frame clears both. The capture freezes the stub's static status, so it shows the worst frame as if it were steady state.
A status refetch on refusal was tried on #9367 and reverted with evidence: it unmounts the offer, and the refusal notice with it, leaving the click unexplained. Hoisting the notice above the offer's mount condition is a page-level change outside this PR's goal (see the onError comment in AboutPanelUpdateFlow.tsx).

@cixuuz

cixuuz commented Oct 19, 2026

Copy link
Copy Markdown
Contributor Author
  • span=3b5a663cb796 the modal's failure state does not say what to do next — rebutted

A rejected update:install IPC carries no cause the user can act on; the one action is the button already shown, which reads 'Try again' in that state, and askAgent hands the message to the agent. The header is now the only 'failed to install' line (its ErrorNotice title was dropped on #9367 for the restating finding).
A new cause-and-remedy string in 12 catalogs for a rare, already-recoverable state is outside the PR's goal (the stale-install waste).

@cixuuz

cixuuz commented Oct 19, 2026

Copy link
Copy Markdown
Contributor Author
  • span=9193250dc340 the quit-time notifications are not shown and use words a user may not know — rebutted

They are native OS notifications fired after before-quit, so no dashboard capture harness can frame them; their exact copy is pinned by auto-update-freshness.test.js (lines 461, 482, 823), which also pins that the two refusals must NOT share a reason.
'Withdrawn or superseded' is the one true statement on that path: the gate reports 'superseded' for a build the feed moved past AND one it retracted, so 'a newer version came out' would be false on the retraction half (the doc comment on notifyInstallCanceled). Rewording three strings is advisory and does not move the goal.

@cixuuz

cixuuz commented Oct 19, 2026

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

This PR rewrote the modal's install dispatch into the shared useInstallDispatch latch, and the GPT lane blocked that head on #9367 because the rewrite left a rejected IPC silent (AUTOSDE errors-use-error-notice, blocking). A defect in code this PR changes is in scope; the branch reuses existing catalog keys and adds no new surface.
Removing it reopens that blocking finding; the gate never rejecting install() is why the state is rare, not why it may be silent.

@cixuuz

cixuuz commented Oct 19, 2026

Copy link
Copy Markdown
Contributor Author
  • span=93c9b1b4a063 the state machine is too hard to change safely — accepted-and-deferred

Agreed. The flag lattice is what #10282 (phase enum; tier:T2, deferred-finding, assignee chenmingwei23, Due 2026-11-14) replaces; it closed as COMPLETED on 2026-10-08 via #17752, which landed only the startDownload guard, so the enum work still needs a home. The gate's own flags move into a per-check record there.
Doing that restructure inside this PR would re-open whole-design review on a fix whose waste ships today; the canary test and docs/build/release.md keep the lattice honest until then.

@cixuuz

cixuuz commented Oct 19, 2026

Copy link
Copy Markdown
Contributor Author
  • span=13bdc4056c3d error attribution depends on undocumented library behaviour — rebutted

The fallback the item asks for is already the code: on an identity mismatch both deferred paths fall through to reportUpdaterFailure(err, phase), the installer's visible side (feed-lane.js, the two setTimeout blocks after 'No rejection carrying this object'). Only an exact object match is suppressed.
Pinned by the straddling-check tests in auto-update.feed-lane.test.js ('an abandoned straddling check's own failure fires no recovery, while a genuine installer failure still does') and electron-updater-error-identity.test.js, which fails CI on a library bump that stops emit-then-reject pairing.

@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 Oct 19, 2026
@cixuuz
cixuuz force-pushed the fix/update-always-installs-newest branch from 4e61162 to f32b549 Compare October 19, 2026 00:54
@github-actions github-actions Bot removed the readiness: action required A blocking check or review needs attention label Oct 19, 2026
@cixuuz
cixuuz force-pushed the fix/update-always-installs-newest branch from e052e63 to b0b066f Compare October 21, 2026 21:51
@cixuuz

cixuuz commented Oct 21, 2026

Copy link
Copy Markdown
Contributor Author
  • span=e66ae19b3aaf Timeout bypasses the channel-change install guard — fixed in b0b066f

The finding holds: verifyStageIsLatest returned "unknown" from four exits (joined-check timeout, own-check timeout, own-check failure, configureFeed throw) and only the two stageVerdict returns compared feedChannel with currentChannel(), so a channel switch during a hung or failed check installed the old lane's stage.
One helper, refuseStageFromChangedChannel, now sits on every exit including stageVerdict: a channel mismatch returns "superseded" (the install path's existing refusal), and a manual caller queues the selected lane's check behind the outstanding request via checkInFlight.then(safeCheck) so safeCheck does not stand down; a quiet (quitting) caller refuses without starting a download as the app exits.
Tests in auto-update-freshness.test.js: own timeout + switch, joined timeout + switch, own failure + switch (install refused, insider lane asked after the stable request settles), and timeout with the channel unchanged still installs fail-open. Revert proof: with the guard removed, the own-timeout test fails a stage from the abandoned stable lane must not install — 1 !== 0. auto-update*: 285/285.

@cixuuz

cixuuz commented Oct 21, 2026

Copy link
Copy Markdown
Contributor Author
  • span=c078f191f4a7 Batched update events leave a canceled agent-request click armed — fixed in b0b066f

The finding holds: agentArmSawDownload was set from a render effect, and useUpdateSubscription writes each IPC payload with queryClient.setQueryData, whose observer notifications React Query batches, so downloading followed by not-available in one tick skipped the render that armed the drop detection and left the click armed for a later unrelated downloaded.
AboutPanel now subscribes to the query cache's updated events for ['update-state'] while a click is armed, tracking download-start and the drop (not-available / checking after it) in refs at the event boundary, so every payload is observed whether or not it renders; the render-effect path stays as the ordinary case and every release site clears both refs and state.
Regression test pushes downloading then not-available inside one act() with no render between and asserts both request actions re-enable and a later downloaded dispatches no install; with the production hunk removed it fails at AboutPanel.agentUpdateRequest.test.tsx:284 expect(element).not.toBeDisabled() — Received element is disabled. Touched vitest files 74/74, tsc clean.

@cixuuz

cixuuz commented Oct 21, 2026

Copy link
Copy Markdown
Contributor Author

Repaired: e052e63 -> b0b066f, rebased onto main 3897633. Both GPT BLOCKING findings on e052e63 are fixed (see the two disposition records): verifyStageIsLatest's timeout/failure exits go through the channel guard, and AboutPanel observes the armed click's downloading at the query-cache event boundary. Local: auto-update* 285/285, touched vitest 74/74, tsc, eslint, flake ratchet, comment-history gate.

@github-actions github-actions Bot added readiness: passed Eligible automated validation passed for the current revision and removed readiness: checking Automated validation is still running labels Oct 21, 2026

@iamwhatever iamwhatever left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Request changes at b0b066f.

  • File-size rule. feed-lane.js goes from 780 to 1,663 lines. AGENTS.md requires a change past 1,600 lines to split the file in the same PR. The Design lane raised this on this head and there is no reply. The smallest fix is to move the freshness gate (withinFreshnessBound, verifyStageIsLatest, refuseStageFromChangedChannel, stageVerdict and the abandonment helpers) into a sibling module under runtime/update/ and keep feed-lane.js as the caller.
  • Unanswered current-head notes. Please add the Update deferred notification to the description's quit-time table (UX). Also name in the description that the removed "no install proceeds with a check outstanding" pin is now narrowed to a versionless stage (First Principles item 3).
  • Human review needed. Separately, api_update_arm can now arm a newer version than the one the user clicked (L260), and the quit path holds and replays Cmd+Q around an install. Both touch the update approval and process lifecycle, so a human reviewer should sign off.

The freshness design itself reads sound. Both GPT blockers from e052e63 are fixed with tests, the flag-lattice deferral is tracked in #22825, and CI is green. I read CI and source and ran nothing.

— crew-pr-reviewer (r119)

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: passed Eligible automated validation passed for the current revision labels Oct 22, 2026
chenmingwei23
chenmingwei23 previously approved these changes Oct 22, 2026
@cixuuz

cixuuz commented Oct 22, 2026

Copy link
Copy Markdown
Contributor Author

Re: review 5610368221 (crew-pr-reviewer r119, head b0b066f).

Addressed at 8d387f1 (rebased onto main 95531ce; the only overlap was the 13 locale catalogs, merged clean).

  • File-size rule. The check lifecycle (claimCheck, checkSettled, abandonCheck, liftAbandonment, ownsCheck, the eight check flags and the two identity-matched rejections), withinFreshnessBound, verifyStageIsLatest, refuseStageFromChangedChannel and stageVerdict moved to the new sibling website/electron/runtime/update/freshness-gate.js (367 lines). feed-lane.js composes one gate and reads the flags through it; it is 1,383 lines (was 1,663). auto-update.js is unchanged. package.json build.files lists the module, and the load-time test in auto-update.test.js now pins which file composes each module (the facade for the lanes and the reporter, feed-lane.js for the gate). Behaviour is unchanged: the 286 update tests pass without edits, and the electron suite is green.
  • Description. The quit-time table has the Update deferred row (copy predates this PR; it only moved to showNotice). "What changed" now names the narrowed pin: the check-in-flight abort fires only for a check the gate did not wait on at all, which is a stage that carries no version, with the tests that pin it.
  • Human review. @chenmingwei23 approved after this review (2026-10-22 14:17 UTC). The two points you flagged, api_update_arm arming the re-checked newest version and the held-and-replayed Cmd+Q, are called out in the description for that sign-off.

@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 Oct 23, 2026
@cixuuz
cixuuz force-pushed the fix/update-always-installs-newest branch from 8d387f1 to ba7868d Compare October 23, 2026 01:56
@cixuuz

cixuuz commented Oct 23, 2026

Copy link
Copy Markdown
Contributor Author

Rebased: main moved in the 12 locale catalogs under website/src/i18n/locales/ since 8d387f1 went green (95531ce -> c9603a9); CI re-running. The same rebase re-runs the lanes that could not run on 8d387f1: the GitHub App hit its installation rate limit at 23:48-23:51 UTC, so Fork PR Description, Screenshot Evidence, both Sensitive Change Review legs, Internal Content Scan, Security Scope Review and the fork GPT 6.1 lane all failed on API rate limit exceeded for installation before reading the PR, while the full test matrix, Design, First Principles, UX and Opus passed on that head.

…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>
@cixuuz
cixuuz force-pushed the fix/update-always-installs-newest branch from ba7868d to bc5a13e Compare October 23, 2026 02:19
@cixuuz

cixuuz commented Oct 23, 2026

Copy link
Copy Markdown
Contributor Author
  • A manual Install refused for a channel change after the freshness check timed out sends nothing to the renderer — fixed in bc5a13e

Confirmed against the code: refuseStageFromChangedChannel only chained safeCheck() behind the hung request, the abandoned request's handlers are inert, and applyUpdateAndRestart returns on "superseded" without a state, so the renderer kept the clicked downloaded and useInstallDispatch kept its latch until the request settled.
Fix as prescribed: emit is a dependency of createFreshnessGate, and the non-quiet refusal emits checking at once when a check is still pending, the same shape as startDownload's channel-change branch. The quiet (quit-time) path and the no-pending-check path (where safeCheck emits checking itself) are unchanged.
Two regression tests in auto-update-freshness.test.js cover the own-check and joined-check timeouts: the only state after the click is checking, quitAndInstall is not called, and the new lane is asked once the old request settles. Both fail with the emit removed. useInstallDispatch resets its latch on any state other than installing or the clicked version's downloaded, so checking releases the button.

@github-actions github-actions Bot added readiness: passed Eligible automated validation passed for the current revision and removed readiness: checking Automated validation is still running labels Oct 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fork Pull request from a fork (external contributor)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants