Skip to content

fix(windows): Open after a copy or update starts the build in its own window - #2158

Open
PabloWiedemann wants to merge 2 commits into
mainfrom
PabloWiedemann/open-after-copy-own-window
Open

PabloWiedemann wants to merge 2 commits into
mainfrom
PabloWiedemann/open-after-copy-own-window

Conversation

@PabloWiedemann

@PabloWiedemann PabloWiedemann commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

TL;DR: Open on a finished Copy now starts the new copy in its own window. It no longer leaves an empty Desktop window behind.

Why: open-install-window focused the build's window when there was one. Otherwise it opened an empty Desktop window that stayed behind, and from a build window it never started the build.

Can affect: only the open-install-window handler in src/main/index.ts.

A follow-up to #2147, and the part of #2027 that #2147 did not cover.

Changes

  • open-install-window now goes through the same openBuild router as the picker (routeBuildOpen, tested in registry.test.ts). A build that has a window comes to the front. Any other build starts from the home window that asked, or from the home window when a build window asked, then opens in its own window.

Not changed

  • Open on a build window's own build (for example after an Update in that window) still only brings that window forward, as before.

Checks

  • typecheck, lint, format and the src/main/host tests pass.
  • e2e/copy-update-destination.test.ts still records the call. It was not run.

… window

Open on a finished operation (the new copy after Copy, a build after
Update) called open-install-window. For a build that was not running it
opened an empty Desktop window that stayed behind, and from a build window
it never started the build.

open-install-window now goes through the same openBuild router as the
picker (#2147): a running build comes to the front,
and any other build starts from the window that asked, or from the home
window when a build window asked, then opens in its own window.

This is the part of #2027 that #2147 did not cover.
@coderabbitai

coderabbitai Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The open-install-window handler no longer focuses an installation window or opens a chooser. The replacement validates the installation ID, identifies the requesting panel when available, and passes the request to openBuild.

Changes: Installation Request Routing

Layer / File(s) Summary
Validate and route installation requests
src/main/index.ts
The handler rejects non-string installation IDs. It passes the matching panel key, or -1 if no panel matches, to openBuild and returns true. The previous handler’s direct window focus and chooser behavior was removed.

Possibly related PRs

Suggested reviewers: deepme987, alexisrolland, benceruleanlu

Merge Risk: Minimal · up to f0ab1

Open after a copy or update now goes through the same build router as the picker, so the build opens in its own window or the existing window is brought forward. No concrete defect was found. The one unchecked piece is the end-to-end test of this flow, which the author did not run.

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: 838dd2e9-b270-4759-be50-36648d3d08f5
Commits

Reviewing files that changed from the base of the PR and between 7a2b1bd and f0ab1ab.

Files selected for processing: 1

  • src/main/index.ts

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

@PabloWiedemann
PabloWiedemann marked this pull request as ready for review November 16, 2026 22:27
@PabloWiedemann
PabloWiedemann requested review from a team as code owners November 16, 2026 22:27
@PabloWiedemann PabloWiedemann added the cursor-review Trigger multi-model Cursor code review label Nov 16, 2026

@github-actions github-actions Bot 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.

🔍 Cursor Review — Consolidated panel

Triggered by @PabloWiedemann.

Found 8 finding(s).

Severity Count
🟡 Medium 3
🟢 Low 5

Panel: 8/8 reviewers contributed findings.

Comment thread src/main/index.ts
ipcMain.handle('open-install-window', async (event, installationId: unknown) => {
if (typeof installationId !== 'string') return false
recordIpcInvocation('open-install-window', { installationId })
const requester = [...comfyWindows.values()].find(

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.

🟡 Medium — Unlike sibling handlers in this file (close-host-window, return-to-dashboard, transfer-host-bounds-to-install), this one does not reject an unrecognized sender: when event.sender is not a registered panel view, the lookup falls through to the -1 sentinel and openBuild treats the call as having no requester, routing to start-from-home and opening/focusing Home for an arbitrary build. Return false for unmatched senders instead of granting the more privileged no-requester path. Raised by 3 of 8 reviewers (claude-opus-5-thinking-max adversarial, kimi-k2.7-code adversarial, gemini-3.1-pro edge-case).

Comment thread src/main/index.ts
const requester = [...comfyWindows.values()].find(
(entry) => entry.panelView?.webContents === event.sender
)
await openBuild(installationId, requester?.windowKey ?? -1)

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.

🟡 Medium — await openBuild(...) is unguarded, and its start-from-home branch awaits getInstallation(), which reads and parses installations.json and can reject; the rejection now crosses ipcMain.handle back to the renderer with the main-process message and stack. Both call sites (ProgressModal.vue handleDone, PanelApp.vue handleProgressSuccessChoice) use void window.api.openInstallWindow(...) with no .catch, so it becomes an unhandled rejection with no user feedback; wrap in try/catch and return false. Raised by 3 of 8 reviewers (claude-opus-5-thinking-max edge-case, claude-opus-5-thinking-max adversarial, kimi-k2.7-code edge-case).

Comment thread src/main/index.ts
const requester = [...comfyWindows.values()].find(
(entry) => entry.panelView?.webContents === event.sender
)
await openBuild(installationId, requester?.windowKey ?? -1)

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.

🟡 Medium — Routing through openBuild replaces "show/focus a window" with delivering a picker-pick-install message, and useDeepLinkRouter silently returns when installationStore.getById(id) misses. After a copy/convert, ProgressModal fires openInstallWindow(newInstallationId) immediately and races the renderer's installations-changed store refresh, so a brand-new id can be dropped and no window opens — the old handler at least fell back to openChooserHostWindow(). Raised by 2 of 8 reviewers (claude-opus-5-thinking-max edge-case, gpt-5.6-sol-max edge-case).

Comment thread src/main/index.ts
(entry) => entry.panelView?.webContents === event.sender
)
await openBuild(installationId, requester?.windowKey ?? -1)
return true

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.

🟢 Low — return true is unconditional even though openBuild has several no-op paths: the ignore route (requester already hosts that build) and the start-from-home bailouts that only console.error for an unknown installation or a window missing from the registry. The declared openInstallWindow(id): Promise<boolean> contract therefore reports success for requests that did nothing, leaving callers unable to fall back. Raised by 2 of 8 reviewers (claude-opus-5-thinking-max edge-case, claude-opus-5-thinking-max adversarial).

Comment thread src/main/index.ts
ipcMain.handle('open-install-window', async (event, installationId: unknown) => {
if (typeof installationId !== 'string') return false
recordIpcInvocation('open-install-window', { installationId })
const requester = [...comfyWindows.values()].find(

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.

🟢 Low — The requester lookup does not skip entries whose window is already destroyed, unlike the sibling handlers. A destroyed-but-still-registered entry hosting the same build yields the ignore route and silently drops the request; add an !entry.window.isDestroyed() guard to the find predicate. Raised by 2 of 8 reviewers (claude-opus-5-thinking-max edge-case, kimi-k2.7-code edge-case).

Comment thread src/main/index.ts
}

ipcMain.handle('open-install-window', async (event, installationId: unknown) => {
if (typeof installationId !== 'string') return false

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.

🟢 Low — The guard checks the type but not emptiness or shape, so '' passes through to openBuild(''), which finds no hosting window and delivers a picker-pick-install for a nonexistent id while still returning true. Unbounded strings also flow into recordBuildOpen telemetry (to_installation_id) and the openBuild: unknown installation log line; validating against the expected inst-<ts> shape closes both. Raised by 2 of 8 reviewers (claude-opus-5-thinking-max edge-case, claude-opus-5-thinking-max adversarial).

Comment thread src/main/index.ts
}
}

ipcMain.handle('open-install-window', async (event, installationId: unknown) => {

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.

🟢 Low — Registration moved from module scope into the app.whenReady() body, behind awaits like initDeviceId() and initUserTier(), and that promise chain has no .catch. Any earlier startup rejection now leaves open-install-window permanently unregistered, so every later invoke rejects with Electron's "No handler registered" error rather than the channel being inert. Raised by 1 of 8 reviewers (claude-opus-5-thinking-max adversarial).

Comment thread src/main/index.ts
const requester = [...comfyWindows.values()].find(
(entry) => entry.panelView?.webContents === event.sender
)
await openBuild(installationId, requester?.windowKey ?? -1)

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.

🟢 Low — The handler is re-entrant with no dedupe for an in-flight installationId: routing is decided synchronously before the await getInstallation(...) in the start-from-home branch, and the launching-id set is only populated once the renderer starts the build, so two rapid invocations for the same id both route to start-from-home and deliver two picker-pick-install messages. Raised by 1 of 8 reviewers (claude-opus-5-thinking-max adversarial).

This branch has not been deployed

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

Labels

cursor-review Trigger multi-model Cursor code review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant