diff --git a/src/main/index.ts b/src/main/index.ts index 6281074df..704dfe53d 100644 --- a/src/main/index.ts +++ b/src/main/index.ts @@ -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 }) => { @@ -1118,6 +1106,22 @@ if (app.isPackaged && !app.requestSingleInstanceLock()) { } } + ipcMain.handle('open-install-window', async (event, installationId: unknown) => { + if (typeof installationId !== 'string' || installationId === '') return false + recordIpcInvocation('open-install-window', { installationId }) + const requester = [...comfyWindows.values()].find( + (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, diff --git a/src/renderer/src/composables/useDeepLinkRouter.ts b/src/renderer/src/composables/useDeepLinkRouter.ts index 8f617ad7c..f040bfe67 100644 --- a/src/renderer/src/composables/useDeepLinkRouter.ts +++ b/src/renderer/src/composables/useDeepLinkRouter.ts @@ -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') diff --git a/src/renderer/src/panel/PanelApp.test.ts b/src/renderer/src/panel/PanelApp.test.ts index 416073e9b..96d4bacb3 100644 --- a/src/renderer/src/panel/PanelApp.test.ts +++ b/src/renderer/src/panel/PanelApp.test.ts @@ -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> }).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> }).api