Skip to content

fix(session): a window opened while an install starts shows it as running - #2145

Merged
vqt123 merged 1 commit into
mainfrom
vinh/session-store-subscribe-first
Nov 16, 2026
Merged

vqt123 merged 1 commit into
mainfrom
vinh/session-store-subscribe-first

Conversation

@vqt123

@vqt123 vqt123 commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

TL;DR: a Desktop window that opens while a ComfyUI install starts or stops now shows that install's state correctly.

Why When a window opens, its builds list reads the running installs, then four more lists, and only then starts listening for "started" and "stopped" messages. An install that starts or stops during those reads is missed, and that window stays wrong until the app restarts. A running install shows as "Ready" with a Start button. Picking it launches it again instead of switching to its window. The macOS end-to-end test "Instance B (running elsewhere): focus its existing window" hit this on its first try in both CI runs of #2134. It opens a second window and marks B as running about 2 seconds later, while that window can still be loading on a cold CI Mac.

Before / After

  • Before: sessionStore.init() subscribed to the install events after its five hydration reads. After: it subscribes first, then reads. Each read only adds entries and reflects main's state at the time of the reply, so an event that arrives first is not undone.
  • Two new unit tests send a "started" and a "stopped" event while init() is still waiting on its reads.

Seen in production by: no user report found; CI found it (#2134, E2E (macos 3/3), e2e/nav-matrix-instance.test.ts:105).

Run: pnpm exec vitest run src/renderer/src/stores/sessionStore.test.ts on an Apple silicon Mac, 34 of 34 passed. Against the old sessionStore.ts, both new tests fail. Not run: the end-to-end suite, which CI runs; the CI failure did not happen on this Mac in 40 local runs, so the e2e evidence is #2134 going green after this merges.

Rule bent: none.

Ref DESK-305

Video: E2E_VIDEO=1 pnpm exec playwright test e2e/nav-matrix-instance.test.ts --project=macos on this PR's head, 2 of 2 passed. Top row: the two Desktop windows. Bottom row: their two build pickers; the second picker shows Nav Inst B as running (green dot) after the test marks it running, and picking it switches to B's window.

nav-matrix-instance-macos-2145.mp4

@vqt123
vqt123 requested review from a team as code owners November 16, 2026 16:07
@coderabbitai

coderabbitai Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

Explain Change →

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

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: 5b95df30-f190-499a-a19e-a62a5d26d82e
Commits

Reviewing files that changed from the base of the PR and between 8bc4cee and 69d0123.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review

No actionable comments were generated in the recent review.

Walkthrough

Session initialization now registers IPC listeners before restoring running, launching, stopping, active-operation, and crash state. Added tests verify that instance start and stop events received during hydration are reflected alongside the running-instance snapshot.

Changes: Session hydration

Layer / File(s) Summary
Register listeners before restoring state
src/renderer/src/stores/sessionStore.ts
init now registers listeners before restoring the existing state snapshots and crash entries.
Test lifecycle events during hydration
src/renderer/src/stores/sessionStore.test.ts
Tests verify that an instance-started event for inst-2 is retained alongside snapshot instance inst-1, and that an instance-stopped event for inst-1 leaves it not running after hydration.

Suggested reviewers: benceruleanlu, maanilverma, kosinkadink

Merge Risk: Minimal · previous review 8bc4c

This change fixes a startup race where an install that started or stopped during hydration could appear as "Ready" and launch a second time. No actionable merge-blocking risk was found. The new tests cover the start and stop cases.

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: 8348f61f-d357-46e0-90bb-f3a12df09e26
Commits

Reviewing files that changed from the base of the PR and between 5a3c71b and 8bc4cee.

Files selected for processing: 2

  • src/renderer/src/stores/sessionStore.test.ts
  • src/renderer/src/stores/sessionStore.ts

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

@vqt123 vqt123 self-assigned this Nov 16, 2026
@vqt123
vqt123 requested a review from benceruleanlu November 16, 2026 16:26
@vqt123

vqt123 commented Nov 16, 2026

Copy link
Copy Markdown
Contributor Author

@benceruleanlu could you review this one? It's a two-file renderer fix: a window now starts listening for install started/stopped before it reads the running list. It's also the cause of the macOS e2e failure blocking #2134.

@comfy-greenlight-bot

comfy-greenlight-bot commented Nov 16, 2026 •

Copy link
Copy Markdown

Swarmhost agentic review

The detailed evaluation is available to employees in the internal Slack review thread.

Evaluation budget remaining for this pull request: 98 automatic and 99 manual.

Updated by Swarmhost's agentic review process.

@vqt123

vqt123 commented Nov 16, 2026

Copy link
Copy Markdown
Contributor Author

/swarmhost evaluate

@vqt123
vqt123 force-pushed the vinh/session-store-subscribe-first branch from 8bc4cee to 69d0123 Compare November 16, 2026 21:13

@comfy-greenlight-bot comfy-greenlight-bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This pull request at head commit 69d0123 has been reviewed and approved by Swarmhost's agentic review process.

The detailed evaluation is available to employees in the internal Slack review thread.

@vqt123

vqt123 commented Nov 16, 2026

Copy link
Copy Markdown
Contributor Author

Merging on greenlight approval.

@vqt123
vqt123 added this pull request to the merge queue Nov 16, 2026
Merged via the queue into main with commit 7a2b1bd Nov 16, 2026
21 checks passed
@vqt123
vqt123 deleted the vinh/session-store-subscribe-first branch November 16, 2026 21:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants