Skip to content

Commit 0e7217a

Browse files
committed
fix: bind the access-page bridge call and cover Download all fully
Extracting openModelAccessPage into a local detached it from its receiver, so a host that reads this on the method would throw and the flow would fall to the system-browser anchor, stranding provider cookies. Call it on the bridge object. The Download all test drove a single downloadable model, so it could not tell "downloads all" from "downloads the first". Drive two models and assert each is dispatched once with its own arguments; reducing the component to the first model now fails the call count.
1 parent 9e502a9 commit 0e7217a

2 files changed

Lines changed: 20 additions & 6 deletions

File tree

src/platform/missingModel/components/MissingModelCard.test.ts

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -359,15 +359,29 @@ describe('MissingModelCard (OSS)', () => {
359359

360360
it('routes Download all through the shared missing-model download handler', async () => {
361361
mountCard({
362-
missingModelGroups: [makeGroup({ withDownloadUrls: true })]
362+
missingModelGroups: [
363+
makeGroup({
364+
withDownloadUrls: true,
365+
modelNames: ['first.safetensors', 'second.safetensors']
366+
})
367+
]
363368
})
364369

365370
await userEvent.click(screen.getByTestId('missing-model-download-all'))
366371

372+
expect(mockDownloadModel).toHaveBeenCalledTimes(2)
373+
expect(mockDownloadModel).toHaveBeenCalledWith(
374+
{
375+
name: 'first.safetensors',
376+
url: 'https://huggingface.co/comfy/test/resolve/main/first.safetensors',
377+
directory: 'checkpoints'
378+
},
379+
{}
380+
)
367381
expect(mockDownloadModel).toHaveBeenCalledWith(
368382
{
369-
name: 'model.safetensors',
370-
url: 'https://huggingface.co/comfy/test/resolve/main/model.safetensors',
383+
name: 'second.safetensors',
384+
url: 'https://huggingface.co/comfy/test/resolve/main/second.safetensors',
371385
directory: 'checkpoints'
372386
},
373387
{}

src/platform/missingModel/composables/useMissingModelDownload.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ export function useMissingModelDownload() {
3030
// anchor fallback inside Electron hits shell.openExternal and strands the
3131
// provider cookies in the system browser.
3232
async function openModelAccessPage(repoUrl: string): Promise<void> {
33-
const openInHost = window.__comfyDesktop2?.openModelAccessPage
34-
if (openInHost) {
33+
const bridge = window.__comfyDesktop2
34+
if (bridge?.openModelAccessPage) {
3535
try {
36-
if ((await openInHost(repoUrl)) === true) return
36+
if ((await bridge.openModelAccessPage(repoUrl)) === true) return
3737
} catch (error: unknown) {
3838
console.error('Failed to open model access page in Desktop:', error)
3939
}

0 commit comments

Comments
 (0)