Skip to content

fix(update): guard startDownload during an install window (#10282) - #17752

Merged
iamwhatever merged 1 commit into
mainfrom
fix/10282-update-phase-enum
Oct 8, 2026
Merged

iamwhatever merged 1 commit into
mainfrom
fix/10282-update-phase-enum

Conversation

@chenmingwei23

@chenmingwei23 chenmingwei23 commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: Stop the desktop auto-updater from leaving the gateway stopped (a dead dashboard) when an automatic download races an in-progress install.

A feed check that is already in flight when the user clicks Install can return a NEWER build and fire an automatic supersede-download from the update-available handler while the install dispatch is stopping the gateway. On main, startDownload guarded only if (downloading) — it had no guard for the install window — so the automatic call set downloading = true over the top of installing.

Why it matters

The install dispatch stops the gateway on purpose and hands off to the platform installer. The post-stopGateway error handler derives the phase as downloading ? "download" : installing ? "install" : "check", so with downloading wrongly set a failure landing during the stop window is misattributed to the download phase and skips the install-phase abort that restores the stopped gateway. The user is left with a stopped gateway and a dead dashboard. It is a narrow race (check in flight + auto-download on + Install clicked in that window) but a severe outcome.

Not a goal

Why this change

startDownload now refuses while installing || quitHandled, exactly the way safeCheck() already refuses during install activity. The existing booleans are kept; the change is one guard clause plus one regression test. This is the minimal fix for the race described above, in place of the broader phase-enum refactor the issue originally requested (see "Not a goal").

What changed (motivation → approach → change)

Motivation: startDownload was the one install-aware entry point missing the install-window guard that safeCheck already had, so an automatic download could start mid-install and corrupt the error-phase attribution. Approach: add the same guard safeCheck uses rather than rework the lifecycle flags, since the set of flags is already small and the defect is a single missing check. Change:

  • website/electron/runtime/update/feed-lane.js: startDownload returns early when installing || quitHandled, before it can set downloading = true.
  • website/electron/test/auto-update.test.js: one regression test that parks the install dispatch inside a gated stopGateway and asserts an automatic update-available-triggered download is refused.

Backwards compatibility

Compatible: adds one guard clause and a test; renames nothing, removes nothing, changes no observable state. An automatic download that previously could race an install dispatch is now refused in that window; outside the install window startDownload is unchanged.

Removes nothing: this diff hides no path, deletes no records, tightens no validator, and removes or renames no key or public function — it adds a guard clause and a test.

Tests

  • New regression test an automatic download fired during an install dispatch is refused (#10282) (website/electron/test/auto-update.test.js), which locks in that startDownload refuses while an install dispatch holds the lifecycle. It is proven to FAIL on main without the guard (the automatic downloadUpdate runs) and pass with it.
  • Full website/electron node:test suite passes locally (the suite CI's Electron Shell Tests job runs): 2438 pass, 0 fail, 4 skipped.

Manual verification

N/A — unit coverage sufficient. The change is a single guard clause fully exercised by the new regression test, which fails without it.

Reproduction

The regression test fails on main (no guard — the automatic download runs during the install dispatch) and passes with the guard. On main with the guard removed, running only that test:

$ node --require ./test/_preload.cjs --test \
    --test-name-pattern="automatic download fired during an install dispatch" \
    test/auto-update.test.js
not ok 1 - an automatic download fired during an install dispatch is refused (#10282)
# pass 0
# fail 1

With the guard in place the full website/electron suite passes: 2438 pass, 0 fail, 4 skipped.

Related Issues

Fixes #10282

Pattern harvest

Pattern: a guard that re-derives "is an install underway?" by hand can miss an entry point — safeCheck refused during the install window but startDownload did not. When several entry points must honour the same lifecycle window, each needs the same guard; a missing one admits exactly the interleaving the others exclude.

Rule candidate: when more than one entry point acts on the same lifecycle state, factor the guard into one shared check (or helper) and call it from every entry point, rather than re-deriving the condition at each site where one can be forgotten.

@github-actions

github-actions Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of ad0a200a0ed834c86b01eaf988cadbf886d66c73 — 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

Confirm a manual Download click during the install or quit window can go silently unanswered: the guard logs and returns without emitting anything.

Not justified as shipped

  • Item 2 — undeclared: the description says "An automatic download … is now refused", but the guard if (installing || quitHandled) also refuses the user's own Download click (download: () => startDownload()), and it does so without emitting anything.

What this change ships

Inventory (3 items) — 2 justified

Intent: stop the desktop updater from leaving the gateway stopped and the dashboard dead when an automatic download races an Install. This is a FIX.

  1. An automatic download that starts while an install is underway is now refused, so a failure during the gateway stop goes to the install path that restores the gateway. — justified
  2. A manual Download request during the install or quit window now does nothing; it is only logged. — undeclared
  3. A regression test pins that no automatic download starts during an install, and the description says it fails on main. — justified

[FIRST-PRINCIPLES-REVIEWED] ad0a200

Description read

[DESCRIPTION-READ] cc23457ff4654d03e09b6528dafc2378e5e3cf0d31a50c772ef70986365a1534

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

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ✅ PASS

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

UX-Verdict: PASS

Check that the renderer clears any "downloading" spinner when a manual download request is silently dropped during an install.

[UX-REVIEWED] ad0a200

Description read

[DESCRIPTION-READ] 2fa91d3dd679269b70200521bc41a66e5702a88118d9f678480c58fb9d2fd54a

That sha256 names everything this verdict read: the PR description, plus the 3 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 7, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

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

Design-Verdict: PASS

Check that a manual download() refused by the new guard emits no state the renderer waits on, since the guard returns silently and the existing downloading branch emits.

[DESIGN-REVIEWED] ad0a200

Description read

[DESCRIPTION-READ] 8661b642a141976a248d8e231617e36d9474994d9f3bffa75a463e584444eea8

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

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

GPT 6.1 completed its review of ad0a200a0ed834c86b01eaf988cadbf886d66c73 and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] ad0a200

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

@github-actions

github-actions Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

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

Review details

No findings.

[OPUS-REVIEWED] ad0a200

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

False positive or not applicable? A repository writer can comment:
/ai-review override fable ad0a200a0ed834c86b01eaf988cadbf886d66c73: <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 Oct 7, 2026
@chenmingwei23
chenmingwei23 force-pushed the fix/10282-update-phase-enum branch from c7c59b5 to c343af8 Compare October 7, 2026 15:33
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: passed Eligible automated validation passed for the current revision and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Oct 7, 2026
@chenmingwei23
chenmingwei23 force-pushed the fix/10282-update-phase-enum branch from c343af8 to 3652d2f Compare October 7, 2026 20:12
@chenmingwei23 chenmingwei23 changed the title refactor(update): replace the feed lane's boolean lattice with a phase enum fix(update): guard startDownload during an install window (#10282) Oct 7, 2026
@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 7, 2026
@chenmingwei23

Copy link
Copy Markdown
Contributor Author

The SAST (Semgrep) check reports 3 findings, but none are introduced by this PR. This PR's diff is JavaScript only (website/electron/runtime/update/feed-lane.js and website/electron/test/auto-update.test.js). The 3 findings are all in Python test files that this PR does not touch, and each line is already present unchanged on current main (65e13d6b24):

  • src/kiro_crew/apps/builtins/auto_improvement/tests/test_pr_watchers.py — test-sleep-as-barrier at lines 637 and 669 (time.sleep(0.2)), present on main.
  • src/kiro_crew/apps/builtins/aws_control/crew/runtime/container_tests/test_sidecar_durability_gaps.py — test-bare-monkeypatch-undo at line 4402 (monkeypatch.undo()), present on main.

They are attributed to this PR only because the Semgrep job's baseline merge-base could not resolve on the shallow checkout (its log prints this job needs fetch-depth: 0), so it falls back to reporting pre-existing findings. These are not changes in this PR and are out of its scope.

A feed check already in flight when the user clicks Install can return a
NEWER build and fire an automatic supersede-download from the
update-available handler WHILE the install dispatch is stopping the
gateway. startDownload only guarded `if (downloading)`, so the automatic
call set `downloading = true` over the top of `installing`; the
post-stopGateway error handler then derived phase "download" instead of
"install" and skipped the install-phase abort that restores the stopped
gateway, leaving a dead dashboard.

Refuse startDownload while installing || quitHandled, the same way
safeCheck() already refuses during install activity. Keep the existing
booleans. Adds a regression test that fails without the guard.

This replaces the earlier phase-enum approach after a lane audit: the
issue's premise of ~15 lifecycle booleans does not hold on main (only
four exist), so the minimal fix is the missing guard, not a lattice
rewrite.

Fixes #10282
@chenmingwei23
chenmingwei23 force-pushed the fix/10282-update-phase-enum branch from 3652d2f to ad0a200 Compare October 8, 2026 04:46
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: passed Eligible automated validation passed for the current revision and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Oct 8, 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.

This fixes the race where a feed check still in flight when the user clicks Install fires an automatic supersede-download mid-dispatch, sets downloading = true over installing, and makes the error handler pick the "download" phase. That phase skips the install-phase abort that restarts the gateway. The root cause is solved: startDownload was the one install-aware entry point without the installing || quitHandled guard that safeCheck() and the poll timer already have, and website/electron/runtime/update/feed-lane.js:190 adds exactly that guard before any state is touched. I read the full diff and the flag handling in feed-lane.js at ad0a200. installing is reset by the error and abort paths, and quitHandled by the retraction path, so the guard cannot wedge later downloads after a failed or withdrawn install. The new test parks install() inside a gated stopGateway, fires update-available, and asserts downloadUpdate was never called, which would fail on base. All checks are green, the GPT and Opus lanes report no findings, and Design, UX and First Principles all PASS. The change is small and scoped, base is main, and there are no open change requests. — crew-pr-reviewer

@iamwhatever
iamwhatever enabled auto-merge (squash) October 8, 2026 06:15
@iamwhatever
iamwhatever merged commit 8cdb4bf into main Oct 8, 2026
103 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

refactor(update): replace initAutoUpdate's boolean lattice with an explicit phase enum

2 participants