Skip to content

The all-in-one local AI studio for your desktop: chat, image and video generation and a coding agent in one free, open source app. Windows and Linux. No Docker, no terminal, no cloud required.

fix(models): a bundle install that does not start gives the Get button back

purpleba7dcbb7583a
diff --git a/src/components/models/DiscoverModels.tsx b/src/components/models/DiscoverModels.tsx
index c54fba0b..8645ec78 100644
--- a/src/components/models/DiscoverModels.tsx
+++ b/src/components/models/DiscoverModels.tsx
@@ -490,20 +490,13 @@ export function DiscoverModels({ category, search = '', searchSubmitToken = 0 }:
log.error('[DiscoverModels] Bundle install failed', { err })
setInstallError(`${bundle.name}: ${err instanceof Error ? err.message : String(err)}`)
}
- // Wait for polling to pick up at least one active download before clearing spinner
- // This prevents the "disappearing" UI — spinner stays until downloads are visible
- const waitForDownloads = () => {
- const active = filenames.some(fn => {
- const dl = dlStore.getState().downloads[fn]
- return dl && (dl.status === 'downloading' || dl.status === 'connecting' || dl.status === 'complete')
- })
- if (active) {
- setInstallingBundle(null)
- } else {
- setTimeout(waitForDownloads, 500)
- }
- }
- setTimeout(waitForDownloads, 1000)
+ // One poll, so the rows of the downloads that did start are in the store
+ // before the card stops saying "Installing" on its own account. From here
+ // the card shows what the rows say: nothing started (no space, no network,
+ // cancelled) is "Get" again at once, a failed file is "Retry". The loop
+ // that stood here waited for a running row and never ended without one.
+ await dlStore.getState().refresh().catch(() => {})
+ setInstallingBundle(null)
}
// The three card states live in lib/bundle-state.ts, pure, because bundles
diff --git a/src/components/models/__tests__/a-refused-install-gives-the-get-button-back.test.tsx b/src/components/models/__tests__/a-refused-install-gives-the-get-button-back.test.tsx
new file mode 100644
index 00000000..8cf4ede1
--- /dev/null
+++ b/src/components/models/__tests__/a-refused-install-gives-the-get-button-back.test.tsx
@@ -0,0 +1,90 @@
+/**
+ * @vitest-environment jsdom
+ *
+ * Box probe 4 (04.10.2026): the drive check refused "LTX 2.5 · Small" with
+ * "Not enough free space: 0.5 GB short. ..." and the card stayed on
+ * "Installing…" with no Get button until the Models page was left. The card
+ * waited for a running download row that a refused install never creates.
+ *
+ * Measured on the rendered page: click Get, the install is refused, the card
+ * says Get again and the reason stands above the cards.
+ *
+ * Run: npx vitest run src/components/models/__tests__/a-refused-install-gives-the-get-button-back.test.tsx
+ */
+import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest'
+import { render, screen, cleanup, waitFor, fireEvent, within } from '@testing-library/react'
+import type { ModelBundle } from '../../../api/model-bundles'
+
+const installBundleComplete = vi.fn(async (_b: ModelBundle): Promise<{ remote?: never }> => ({}))
+
+vi.mock('../../../api/backend', async (importOriginal) => ({
+ ...(await importOriginal<typeof import('../../../api/backend')>()),
+ backendCall: vi.fn(async () => []),
+ openExternal: vi.fn(),
+ isTauri: () => false,
+ isMacOS: () => false,
+}))
+vi.mock('../../../api/comfyui', async (importOriginal) => ({
+ ...(await importOriginal<typeof import('../../../api/comfyui')>()),
+ getSystemVRAM: vi.fn(async () => 24),
+ readComfyFolderLists: vi.fn(async () => ({})),
+ refreshComfyModels: vi.fn(async () => {}),
+}))
+vi.mock('../../../api/discover', async (importOriginal) => ({
+ ...(await importOriginal<typeof import('../../../api/discover')>()),
+ installBundleComplete: (b: ModelBundle) => installBundleComplete(b),
+}))
+vi.mock('../../../lib/hardware', async (importOriginal) => ({
+ ...(await importOriginal<typeof import('../../../lib/hardware')>()),
+ getMaxVramGb: vi.fn(async () => 24),
+ getTotalRamGb: vi.fn(async () => 64),
+}))
+vi.mock('../CivitaiSearchPanel', () => ({ CivitaiSearchPanel: () => null }))
+vi.mock('../../chat/LuEngineSwitchBar', () => ({ LuEngineSwitchBar: () => null }))
+
+import { DiscoverModels } from '../DiscoverModels'
+
+const NAME = 'LTX 2.5 · Small (GGUF Q4)'
+const REFUSAL = 'Not enough free space: 0.5 GB short. The download is 27.1 GB, LU keeps 2.0 GB of the drive free, and the drive has 28.6 GB free. Free up some space and start it again.'
+const tile = () => document.querySelector(`[data-bundle-tile="${NAME}"]`) as HTMLElement
+const getButton = () => within(tile()).queryByRole('button', { name: /^Get/ })
+
+beforeEach(() => {
+ cleanup()
+ installBundleComplete.mockReset()
+ vi.stubGlobal('ResizeObserver', class { observe() {} unobserve() {} disconnect() {} })
+})
+afterEach(() => { cleanup(); vi.unstubAllGlobals() })
+
+async function clickGet() {
+ render(<DiscoverModels category="video" />)
+ await waitFor(() => expect(tile()).toBeTruthy())
+ fireEvent.click(getButton()!)
+}
+
+describe('an install that does not start', () => {
+ it('refused by the drive check: the reason is shown and the card says Get again', async () => {
+ installBundleComplete.mockRejectedValue(new Error(REFUSAL))
+ await clickGet()
+ expect(await screen.findByText(`${NAME}: ${REFUSAL}`)).toBeTruthy()
+ await waitFor(() => expect(getButton()).toBeTruthy())
+ expect(within(tile()).queryByText(/Installing/)).toBeNull()
+ })
+
+ it('started nothing because every file was cancelled before its first byte: Get again, no endless spinner', async () => {
+ installBundleComplete.mockResolvedValue({})
+ await clickGet()
+ await waitFor(() => expect(installBundleComplete).toHaveBeenCalledTimes(1))
+ await waitFor(() => expect(getButton()).toBeTruthy())
+ expect(within(tile()).queryByText(/Installing/)).toBeNull()
+ })
+
+ it('says Installing while the install call is still open', async () => {
+ let settle: (v: { remote?: never }) => void = () => {}
+ installBundleComplete.mockImplementation(() => new Promise((r) => { settle = r }))
+ await clickGet()
+ expect(await within(tile()).findByText(/Installing/)).toBeTruthy()
+ settle({})
+ await waitFor(() => expect(getButton()).toBeTruthy())
+ })
+})