Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 16 additions & 12 deletions src/main/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -800,18 +800,6 @@ ipcMain.handle('focus-comfy-window', async (_event, installationId: string) => {
return false
})

ipcMain.handle('open-install-window', (_event, installationId: string) => {
recordIpcInvocation('open-install-window', { installationId })
const existing = getEntryByInstallationId(installationId)
if (existing && !existing.window.isDestroyed()) {
existing.window.show()
existing.window.focus()
return true
}
openChooserHostWindow()
return true
})

ipcMain.handle(
'close-comfy-window',
(_event, installationId: string, opts?: { skipConfirm?: boolean }) => {
Expand Down Expand Up @@ -1118,6 +1106,22 @@ if (app.isPackaged && !app.requestSingleInstanceLock()) {
}
}

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).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Not changing: the panels that call this channel are created inside the same whenReady body, after this handler is registered, so they cannot call it earlier. A startup failure before that point stops the app anyway.

if (typeof installationId !== 'string' || installationId === '') 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).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 7dcba67: a sender that is not a registered panel now gets false, and nothing opens.

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).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 7dcba67: the requester lookup skips windows that are already destroyed.

(entry) => !entry.window.isDestroyed() && entry.panelView?.webContents === event.sender
)
if (!requester) return false
try {
await openBuild(installationId, requester.windowKey)
return true
} catch (error) {
console.error('open-install-window: could not open the build', { installationId, error })
return false
}
})

registerTitlePopupIpc({
openChooserHostWindow,
returnToDashboard,
Expand Down
6 changes: 5 additions & 1 deletion src/renderer/src/composables/useDeepLinkRouter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,11 @@ export function useDeepLinkRouter(opts: DeepLinkRouterOpts): void {
await opts.bootstrapReady
const id = payload.installationId
if (!id) return
const inst = installationStore.getById(id)
const inst =
installationStore.getById(id) ??
(await installationStore.fetchInstallations().catch(() => [])).find(
(installation) => installation.id === id
)
if (!inst) {
if (payload.startupRestore) {
window.api.resolveStartupRestoreReveal('dashboard-fallback')
Expand Down
21 changes: 21 additions & 0 deletions src/renderer/src/panel/PanelApp.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1320,6 +1320,27 @@ describe('PanelApp', () => {
expect(api.resolveStartupRestoreReveal).toHaveBeenCalledWith('takeover-ready')
})

it('starts a picked build that this window has not loaded yet, such as a copy made a moment ago', async () => {
mockState.installations = []
const api = (window as unknown as { api: Record<string, ReturnType<typeof vi.fn>> }).api
api.getListActions.mockResolvedValue([
{ id: 'launch', label: 'Start', style: 'primary', showProgress: true }
])
api.runAction.mockReturnValueOnce(new Promise(() => {}))
Object.assign(api, { onInstallProgress: vi.fn(() => () => {}) })
window.history.replaceState({}, '', '/?panel=chooser&firstUseCompleted=true')
mountPanel()
await flushPromises()

mockState.installations = [SAMPLE_INSTALL]
mockState.panelTriggerOverlayCallbacks.forEach((cb) =>
cb({ kind: 'picker-pick-install', installationId: 'test-id' })
)
await flushPromises()

expect(api.runAction).toHaveBeenCalledWith('test-id', 'launch')
})

it('Start on a Home build card starts it there and leaves this window on Home', async () => {
mockState.installations = [SAMPLE_INSTALL]
const api = (window as unknown as { api: Record<string, ReturnType<typeof vi.fn>> }).api
Expand Down
Loading