Skip to content

fix(onboarding): Set up no longer misses a legacy ComfyUI Desktop install found at startup - #2131

Merged
benceruleanlu merged 3 commits into
mainfrom
bl/setup-offers-migration-after-detection
Nov 16, 2026
Merged

benceruleanlu merged 3 commits into
mainfrom
bl/setup-offers-migration-after-detection

Conversation

@benceruleanlu

@benceruleanlu benceruleanlu commented Nov 15, 2026 •

Copy link
Copy Markdown
Member

What this is about

Two specs in the Lifecycle suite failed once and passed on retry in run 43676395717, which failOnFlakyTests turns into a red job. The run was for #2115, which touches neither spec, and it was built from main at 5d85efd8.

Both failures are the app, not the specs:

Spec Cause Fixed in
e2e/lifecycle-first-use-migrate.test.ts:44 Set up can open before the legacy ComfyUI Desktop install has been added to the builds list, and it never asks again this PR (src/main/installations.ts)
e2e/lifecycle-delete-untrack.test.ts:119 A build's own update check blocked Delete #2117, merged 40 minutes after that run. This PR only changes how the spec reports such a failure

1. Set up did not offer to migrate

cold start with legacy desktop offers to migrate it on Set up, ticked by default

What was on screen

From the failure artifact's trace and screenshots (times from the start of the test's beforeAll):

  • Electron launched by 0.4 s, the first window existed at 1.09 s, and Set up was visible on the first look at 1.29 s.
  • Set up was fully drawn: "Install ComfyUI on this PC", the runner's CPU, CPU hardware, the install location, "ComfyUI v0.45.3 · Stable", the three consent boxes.
  • There was no "Bring over workflows, models and settings from ComfyUI Desktop" row. The spec looked 8 times between 1.29 s and 6.0 s.
  • On the retry the row was there on the first look and the test took 59 ms.

(error-context.md for this test is a snapshot of a different page, an empty menu. The panel is test-failed-4.png.)

Cause

Set up shows the row when it is told there is a legacy install. It asks the main process once when it opens (get-first-use-state; PanelApp asks twice in quick succession while it loads) and never again. The answer is read from the builds list on disk.

The legacy install gets into that list at startup: ipc.register() detects it and requests a write, without waiting for it, behind three other startup writes to the same file. Reads of the list did not wait for requested writes. The first window starts loading about 75 ms after the first of those writes begins, so the write and the Set up screen's question race on every cold start. If the question is answered first, the screen shows a plain Install and stays that way however long anyone waits. The spec's 5 second wait was never the problem.

This is older than the new Set up screen: the one-time question has been in usePanelOverlays since May. The spec that looks for the row is from #2072.

What a user would see

Someone upgrading from the old ComfyUI Desktop opens the app for the first time. When the write loses the race, Set up has no migrate row and its button says Install instead of Migrate. Agreeing to the EULA and pressing it downloads a fresh install. Their old install still turns up under Builds afterwards, with its own Migrate action, so nothing is lost, but the offer the screen exists to make is skipped.

Fix

Reads of the builds list (list, get, hasNameConflict, getRecent, getRecentByCategory) now wait for the writes that had been requested before them, then read. Writes are unchanged and do not wait for reads, and a write that fails does not hold up or fail the reads behind it.

Two things follow for a cold start:

  • Startup reads the list (migrateDefaults) before it opens the first window, so the window now opens after the legacy install is in the list.
  • The answer to the Set up screen's question cannot come from a list older than a write that was already requested.

A narrower fix would be to have startup wait for its own four writes. I changed the read instead because the read is what was wrong: the app could be handed a list older than a write it had already asked for, and that holds for every reader, not only this one. Every reader of the builds list in the main process is affected: each now waits for writes already in the queue. Measured below, that wait is a median of 6 ms at startup.

The spec is unchanged.

Evidence

All on GitHub's Windows runner, on the throwaway branch bl/diag-lifecycle-migrate-windows: this spec file repeated with no retries, and the spec printing when installations.json was written, when the panel loaded, and what the app said afterwards.

main (run 43751943810) this fix (run 43753127555)
Repeats with no migrate row 10 of 60 0 of 60
Repeats where the window started loading before the legacy install was in the list 60 of 60 0 of 60
When the list was written, against the window starting to load 37 to 1285 ms after 56 to 79 ms before
Startup writes, from the first temp file being created to the last write landing (median) 160 ms when the row showed, 704 ms when it did not 6 ms
Window started loading, after launch (median) 1.18 s 1.00 s
  • In the 10 failing repeats on main the legacy install was in the builds list and in installations.json when the test looked afterwards, and the app log had no failed write. The registration was late, not missing: the list was written 99 to 299 ms after the panel finished loading. In the 50 that passed it was written a median of 426 ms before.
  • On main the startup writes overlap the creation of the window and take a median of 160 ms even when the row shows. With the fix they finish before the window is created, in a median of 6 ms, so waiting for them costs nothing that shows: the window did not start later. (Runners differ from run to run, so read the last row as "no slower", not "faster".)
  • In one repeat on the fix the startup writes took 1.6 s. The window waited for them and the row was there on the first look.

With the legacy registration held for 3 seconds on purpose (one setTimeout in the queued write, on the throwaway branch only), 10 repeats each:

  • Without the fix (run 43754035747): no migrate row in 10 of 10. The window opened while the write was held, Set up asked, and the row never came, although the legacy install was in the list in all 10 when the test looked afterwards.
  • With the fix (run 43753774982): the row was there on the first look in 10 of 10. The window started loading 50 to 72 ms after the held write landed.

Unit tests (src/main/installations.test.ts, new src/main/lib/firstUseDetection.test.ts), with the real builds list in a real temporary folder and one write held at its rename:

  • A build that is still being added is listed, and a change that is still being saved is returned.
  • Set up is told about a legacy install that startup is still adding.
  • A failed write does not stop the list from being read.

Without the change to installations.ts the first three fail: the list comes back empty, the build comes back with its old name, and Set up is told hasLegacyDesktop: false.

2. Delete did not remove the build

kebab Delete drops the record AND removes the install directory

What was on screen

From the trace (times from the start of the test):

  • The kebab was clicked by 57 ms, the Delete item was visible on the first look and clicked by 144 ms, the confirm dialog's button was visible on the first look and clicked by 166 ms. All three clicks landed.
  • The card was then polled 39 times over 29.6 s and never went away.
  • At failure the Builds page had no dialog and the "Delete Me" card showed a red Error badge. That badge is only set when an operation's call comes back refused or failed, so the kebab did reach the delete confirm, the confirm was the delete's, the delete was sent, and the main process refused it.
  • The build settings popup's page, hidden by then, was on "Delete Me" with "Up to date · Last Checked Just now". The Untrack test before this one removes a build in that popup, the popup moves to "Delete Me" and starts that build's update check.

Cause

On 5d85efd8 a build's update check held the build's operation slot and Delete was refused while it ran. This is exactly what #2117 found on this spec and fixed (2 of 20 repeats failed before it, 40 of 40 passed after, 14 of those with the check still in flight). With #2117 in the build, its own PR run, the nightly on main and one other PR's run have passed this spec.

Change here

The spec used to wait 30 seconds for the card to go away and then fail with "deleted tile never disappeared from chooser", which says nothing about why. It now stops waiting as soon as the card shows Error, opens the error, and fails with the message the app gives.

Not in this PR

  • Set up still decides once, when it opens. With this fix nothing at startup can change the answer after that.
  • detectDesktopInstall() throws when the old install's folder and its parent folder are both gone, and ipc.register() calls it unguarded before the first window opens. Read from the code, not reproduced.
  • From fix(builds): a build's update check no longer blocks Delete, Copy or Start #2117's own list, still open: the refusal message names the action that was asked for, not the one that is running; and a second source action can overwrite a running action's operation slot.
  • The throwaway branch bl/diag-lifecycle-migrate-windows is still on the remote. It was never a PR.

Checks

Only the changed test files were run locally. CI runs the rest, and the Lifecycle suite runs on this PR through the run-lifecycle label.

Lifecycle suite on this PR's head (fc737582), twice:

Run Result The two specs
43753558479, from the run-lifecycle label 73 of 73 passed on the first attempt, none flaky migrate offer 46 ms, delete 418 ms
43754429469, dispatched by hand on the branch 73 of 73 passed on the first attempt, none flaky migrate offer 62 ms, delete 414 ms

Two green runs of a spec that failed one time in six say little by themselves. The repeats above are the evidence for the migrate spec, and #2117's repeats are the evidence for the delete spec.

…tall found at startup

On a cold start the app looks for an old ComfyUI Desktop install and, when
it finds one, adds it to the builds list. The Set up screen then offers
"Bring over workflows, models and settings from ComfyUI Desktop" and its
button reads Migrate instead of Install.

The screen asks for that once, when it opens, and the answer is read from
the builds list on disk. The legacy install is added by a write that
startup requests and does not wait for, queued behind three other startup
writes, and reads of the list did not wait for queued writes. The first
window is created about 70 ms after those writes are requested, so the
two race on every cold start. When the read comes first the screen shows
a plain Install with no offer and never asks again.

Reads of the builds list now wait for the writes that were requested
before them. Startup reads the list before it opens the first window, so
the window now opens after the legacy install is in the list, and the
Set up screen's question cannot be answered from an older list either.

Seen as a flaky e2e/lifecycle-first-use-migrate.test.ts on Windows. On
main, 10 of 60 repeats of that spec had no offer; in all 10 the legacy
install was in the list afterwards, written 100 to 300 ms after the panel
had loaded (run 43751943810, throwaway branch
bl/diag-lifecycle-migrate-windows).
When the app refused the delete, the build's card showed Error and the
spec waited 30 seconds for the card to go away, then failed with "deleted
tile never disappeared from chooser". That is what happened in run
43676395717: the delete was refused because the build's own update check
held its operation slot, which #2117 has since fixed.

The spec now stops waiting when the card shows Error, opens it, and fails
with the message the app gives.
@benceruleanlu
benceruleanlu requested review from a team as code owners November 15, 2026 19:35
@benceruleanlu benceruleanlu added the run-lifecycle Run the CPU lifecycle E2E chain on this PR label Nov 15, 2026
@coderabbitai

coderabbitai Bot commented Nov 15, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Installation reads now wait for queued writes before loading records. New tests cover concurrent reads, write failures, and first-use detection. The lifecycle deletion test now checks for an error badge as well as tile removal.

Changes: Installation Read Consistency

Layer / File(s) Summary
Queued-write-aware installation reads
src/main/installations.ts, src/main/installations.test.ts, src/main/lib/firstUseDetection.test.ts
Read methods wait for queued writes before loading installation records. Tests check reads during pending additions and updates, failed writes, and first-use detection results for Cloud, legacy desktop, and standalone installations.

Lifecycle Delete Error Check

Layer / File(s) Summary
Delete error assertion
e2e/lifecycle-delete-untrack.test.ts
The test waits for the deleted tile to disappear or an error badge to appear. It opens the badge if present and asserts that no deletion error is reported.

Suggested reviewers: kosinkadink, deepme987

Merge Risk: Minimal · up to fc737

Installation reads now wait for writes that were already requested, which fixes the startup race where Set up could miss a legacy install. No concrete merge-blocking risk was found, and the change is easy to revert.

Pre-merge checks: Passed 2

Check name Status Explanation
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
Simplify code

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: c319de92-5969-47f2-9849-aedd6fdee4d5
Commits

Reviewing files that changed from the base of the PR and between 4913388 and fc73758.

Files selected for processing: 4

  • e2e/lifecycle-delete-untrack.test.ts
  • src/main/installations.test.ts
  • src/main/installations.ts
  • src/main/lib/firstUseDetection.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 0 remain after this review.

…folder on Linux

On Linux the builds list lives under XDG_DATA_HOME when that is set, so
the new test could have read and written the real app data folder of
whoever ran it. It now runs with the same platform stub as
installations.test.ts, which puts the list in the test's temporary
folder on every platform.
@benceruleanlu benceruleanlu added run-lifecycle Run the CPU lifecycle E2E chain on this PR and removed run-lifecycle Run the CPU lifecycle E2E chain on this PR labels Nov 15, 2026
@benceruleanlu
benceruleanlu merged commit 5a3c71b into main Nov 16, 2026
30 of 37 checks passed
@benceruleanlu
benceruleanlu deleted the bl/setup-offers-migration-after-detection branch November 16, 2026 09:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

run-lifecycle Run the CPU lifecycle E2E chain on this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant