Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

fix: click the download confirm button only once it is enabled (#6266)

[._.]/ Adam Eivyd5eb028cdb7e
diff --git a/client/src/components/settings/LocalLlmLibraryView.test.jsx b/client/src/components/settings/LocalLlmLibraryView.test.jsx
index e73ff6888a..ef57bb17a0 100644
--- a/client/src/components/settings/LocalLlmLibraryView.test.jsx
+++ b/client/src/components/settings/LocalLlmLibraryView.test.jsx
@@ -66,6 +66,7 @@ import {
upgradeLocalLlmBackend,
} from '../../services/api';
import socket from '../../services/socket';
+import { clickStartDownload } from '../../test/downloadPreflightConfirm.js';
import LocalLlmLibraryView from './LocalLlmLibraryView.jsx';
// A realistically long HF model id — the shape that got ellipsised to
@@ -166,7 +167,7 @@ describe('LocalLlmLibraryView Ollama auto-upgrade', () => {
await renderLibrary();
fireEvent.change(screen.getByLabelText('Install a Ollama model by id'), { target: { value: 'llama3.2' } });
fireEvent.click(screen.getByRole('button', { name: 'Install' }));
- fireEvent.click(await screen.findByRole('button', { name: 'Start download' }));
+ await clickStartDownload();
expect(await screen.findByText('Upgrading Ollama')).toBeInTheDocument();
expect(screen.getByText(/llama3.2 needs a newer Ollama/)).toBeInTheDocument();
@@ -248,7 +249,7 @@ describe('LocalLlmLibraryView installed models', () => {
installLocalLlmModel.mockResolvedValue({ success: true });
await renderLibrary();
fireEvent.click(screen.getByRole('button', { name: `Redownload ${LONG_ID}` }));
- fireEvent.click(await screen.findByRole('button', { name: 'Start download' }));
+ await clickStartDownload();
await waitFor(() => expect(installLocalLlmModel).toHaveBeenCalledWith(
'ollama',
LONG_ID,
@@ -315,7 +316,7 @@ describe('LocalLlmLibraryView installed models', () => {
);
await waitFor(() => expect(screen.getByText(/Installed on LM Studio/)).toBeTruthy());
fireEvent.click(screen.getByRole('button', { name: 'Redownload Qwen3.8 27B' }));
- fireEvent.click(await screen.findByRole('button', { name: 'Start download' }));
+ await clickStartDownload();
await waitFor(() => expect(installLocalLlmModel).toHaveBeenCalledWith(
'lmstudio',
'unsloth/Qwen3.8-27B-GGUF@UD-Q4_K_M',
@@ -418,7 +419,7 @@ describe('LocalLlmLibraryView recommendations', () => {
await renderLibrary();
expect(await screen.findByText('Qwen3.8 27B')).toBeTruthy();
fireEvent.click(screen.getByRole('button', { name: /^Redownload$/ }));
- fireEvent.click(await screen.findByRole('button', { name: 'Start download' }));
+ await clickStartDownload();
await waitFor(() => expect(installLocalLlmModel).toHaveBeenCalledWith(
'ollama',
'hf.co/unsloth/Qwen3.8-27B-GGUF:UD-Q4_K_M',
diff --git a/client/src/components/settings/LocalLlmRuntimesView.test.jsx b/client/src/components/settings/LocalLlmRuntimesView.test.jsx
index 81926b2a5e..dcaf4ad5fd 100644
--- a/client/src/components/settings/LocalLlmRuntimesView.test.jsx
+++ b/client/src/components/settings/LocalLlmRuntimesView.test.jsx
@@ -64,6 +64,7 @@ import {
patchSettingsSlice,
} from '../../services/api';
import socket from '../../services/socket';
+import { clickStartDownload } from '../../test/downloadPreflightConfirm.js';
import LocalLlmRuntimesView from './LocalLlmRuntimesView.jsx';
import {
appleGpuBudgetGib,
@@ -265,7 +266,7 @@ describe('LocalLlmRuntimesView runtime servers', () => {
await renderRuntimes();
fireEvent.click(screen.getByRole('button', { name: /Download default checkpoint/ }));
- fireEvent.click(await screen.findByRole('button', { name: 'Start download' }));
+ await clickStartDownload();
await waitFor(() => expect(toast.error).toHaveBeenCalledWith(expect.stringMatching(/no space left on device/)));
expect(toast.success).not.toHaveBeenCalled();
@@ -280,7 +281,7 @@ describe('LocalLlmRuntimesView runtime servers', () => {
await renderRuntimes();
fireEvent.click(screen.getByRole('button', { name: /Download default checkpoint/ }));
- fireEvent.click(await screen.findByRole('button', { name: 'Start download' }));
+ await clickStartDownload();
// `null` (not a repo id the card invented) = MTPLX's own verified default.
await waitFor(() => expect(pullMtplxModel).toHaveBeenCalledWith(null));
@@ -626,7 +627,7 @@ describe('LocalLlmRuntimesView llama-server management', () => {
expect(screen.getByText(/Downloaded \(1\.1 GB\)/)).toBeInTheDocument();
const downloadBtn = screen.getByRole('button', { name: /^Download$/ });
fireEvent.click(downloadBtn);
- fireEvent.click(await screen.findByRole('button', { name: 'Start download' }));
+ await clickStartDownload();
await waitFor(() => {
expect(downloadSpecDecodeModel).toHaveBeenCalledWith('qwen3.8-27b-dspark', 'model', { silent: true });
@@ -653,7 +654,7 @@ describe('LocalLlmRuntimesView llama-server management', () => {
await renderRuntimes();
fireEvent.click(await screen.findByRole('button', { name: /^Download$/ }));
- fireEvent.click(await screen.findByRole('button', { name: 'Start download' }));
+ await clickStartDownload();
await waitFor(() => {
expect(toast.warning).toHaveBeenCalledWith(expect.stringMatching(/still running in the background/));
diff --git a/client/src/pages/Loras.test.jsx b/client/src/pages/Loras.test.jsx
index 9fb134c159..51af0f7986 100644
--- a/client/src/pages/Loras.test.jsx
+++ b/client/src/pages/Loras.test.jsx
@@ -6,6 +6,7 @@
import { describe, it, expect, vi, beforeEach } from 'vitest';
import { render, screen, waitFor, fireEvent } from '@testing-library/react';
import { MemoryRouter } from 'react-router';
+import { clickStartDownload } from '../test/downloadPreflightConfirm.js';
import Loras from './Loras';
import {
listLorasFull, deleteLoraFull, installLoraFromHuggingfaceStream, probeLoraEffect,
@@ -134,7 +135,7 @@ describe('Loras HuggingFace family picker', () => {
const input = await screen.findByLabelText('HuggingFace LoRA URL');
fireEvent.change(input, { target: { value: 'https://huggingface.co/Alissonerdx/CharacterSheet' } });
fireEvent.submit(input.closest('form'));
- fireEvent.click(await screen.findByRole('button', { name: 'Start download' }));
+ await clickStartDownload();
expect(await screen.findByRole('button', { name: 'Install as Flux 2' })).toBeInTheDocument();
expect(screen.getByRole('button', { name: 'Install as Flux 1' })).toBeInTheDocument();
expect(screen.getByRole('button', { name: 'Install as LTX-Video' })).toBeInTheDocument();
@@ -191,7 +192,7 @@ describe('Loras suggestion card busy state', () => {
// "Installing…", not have reverted to "Quick install" already.
expect(await screen.findByRole('button', { name: 'Installing…' })).toBeInTheDocument();
- fireEvent.click(screen.getByRole('button', { name: 'Start download' }));
+ await clickStartDownload();
expect(await screen.findByRole('button', { name: 'Installing…' })).toBeInTheDocument();
resolveInstall({ name: 'lora-example.safetensors' });
@@ -247,7 +248,7 @@ describe('Loras video suggestion quick-install preflight', () => {
}));
expect(installLoraFromHuggingfaceStream).not.toHaveBeenCalled();
- fireEvent.click(screen.getByRole('button', { name: 'Start download' }));
+ await clickStartDownload();
await waitFor(() => expect(installLoraFromHuggingfaceStream).toHaveBeenCalledWith(
expect.objectContaining({ url: VIDEO_CARD.installUrl, family: VIDEO_CARD.runnerFamily, file: VIDEO_CARD.file }),
));
diff --git a/client/src/test/downloadPreflightConfirm.js b/client/src/test/downloadPreflightConfirm.js
new file mode 100644
index 0000000000..d084afb5cc
--- /dev/null
+++ b/client/src/test/downloadPreflightConfirm.js
@@ -0,0 +1,24 @@
+import { act, fireEvent, screen, waitFor } from '@testing-library/react';
+import { expect } from 'vitest';
+
+// DownloadPreflightConfirm renders its confirm button the instant the modal
+// opens — disabled, mid-`loading` — and only enables it once the preview()
+// promise settles the size/destination assessment (#6266). `findByRole`
+// matches a disabled button too, so `fireEvent.click(await
+// screen.findByRole('button', { name: 'Start download' }))` can land on the
+// still-disabled button under CPU contention and silently no-op. Wait for
+// enabled, not just present, before clicking — then settle with
+// `act(async () => {})`, because waiting the extra tick for "enabled" is
+// itself enough to leave the confirm handler's own promise chain (e.g. the
+// status reload a successful install kicks off) unflushed past whatever the
+// caller asserts next.
+export async function clickStartDownload(name = 'Start download') {
+ const button = await waitFor(() => {
+ const el = screen.getByRole('button', { name });
+ expect(el).toBeEnabled();
+ return el;
+ });
+ fireEvent.click(button);
+ await act(async () => {});
+ return button;
+}