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
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
address review (codex): refuse a quant-less LM Studio redownload
[._.]/ Adam Eivyb7ceb85efa9e
diff --git a/client/src/components/settings/LocalLlmTab.jsx b/client/src/components/settings/LocalLlmTab.jsxindex 4fbd796ae3..e32f93884b 100644--- a/client/src/components/settings/LocalLlmTab.jsx+++ b/client/src/components/settings/LocalLlmTab.jsx@@ -28,8 +28,12 @@ const labelFor = (id) => BACKENDS.find((b) => b.id === id)?.label || id;// `quantization` field. A force redownload has to target a tagged id so the// server evicts that GGUF instead of no-op'ing on a bare repo.const redownloadInstallId = (model, backend) => {- if (backend !== 'lmstudio' || !model?.quantization || /@/.test(model.id || '')) return model.id;- return `${model.id}@${model.quantization}`;+ if (backend !== 'lmstudio') return model.id;+ if (/@/.test(model.id || '')) return model.id;+ if (model?.quantization) return `${model.id}@${model.quantization}`;+ // /v1/models fallback has no quantization — a bare repo force-redownload+ // would skip existing GGUFs and still toast success.+ return null;};// The speculative-decoding presets come from the server@@ -1578,7 +1582,7 @@ export function LocalLlmTab() {{chosenInstalled ? (<><span className="text-xs px-2 py-1 text-port-success">Installed</span>- {!isAudio && (+ {!isAudio && (selected !== 'lmstudio' || /@/.test(chosenId || '')) && (<buttononClick={() => install(chosenId, { force: true })}disabled={busy}@@ -1700,6 +1704,7 @@ export function LocalLlmTab() {<FlaskConical size={12} />Chat</Link>+ {redownloadInstallId(m, selected) && (<buttononClick={() => install(redownloadInstallId(m, selected), { force: true })}disabled={busy}@@ -1707,9 +1712,10 @@ export function LocalLlmTab() {className="px-2.5 py-1 text-xs bg-port-accent/20 hover:bg-port-accent/30 text-port-accent rounded disabled:opacity-50 flex items-center gap-1 shrink-0"aria-label={`Redownload ${m.name || m.id}`}>- {actionInProgress === `install-${m.id}` ? <BrailleSpinner /> : <RefreshCw size={12} />}+ {actionInProgress === `install-${redownloadInstallId(m, selected)}` ? <BrailleSpinner /> : <RefreshCw size={12} />}Redownload</button>+ )}{isConfirmingDelete(m.id) ? (<ConfirmButtonPairprompt="Delete?"diff --git a/client/src/components/settings/LocalLlmTab.test.jsx b/client/src/components/settings/LocalLlmTab.test.jsxindex 283e07986d..dbda0da2f0 100644--- a/client/src/components/settings/LocalLlmTab.test.jsx+++ b/client/src/components/settings/LocalLlmTab.test.jsx@@ -167,6 +167,26 @@ describe('LocalLlmTab installed models', () => {expect.objectContaining({ force: true }),));});++ it('hides redownload when LM Studio did not report a quantization', async () => {+ getLocalLlmStatus.mockResolvedValue({+ backend: 'lmstudio',+ ollama: { installed: false, available: false, modelCount: 0, models: [] },+ lmstudio: {+ installed: true,+ available: true,+ modelCount: 1,+ models: [{ id: 'unsloth/Qwen3.8-27B-GGUF', name: 'Qwen3.8 27B' }],+ },+ });+ render(+ <MemoryRouter>+ <LocalLlmTab />+ </MemoryRouter>,+ );+ await waitFor(() => expect(screen.getByText(/Installed on LM Studio/)).toBeTruthy());+ expect(screen.queryByRole('button', { name: /Redownload/ })).toBeNull();+ });});describe('LocalLlmTab recommendations', () => {diff --git a/server/services/lmStudioManager.js b/server/services/lmStudioManager.jsindex a15c3f0d5a..3e217e1fe7 100644--- a/server/services/lmStudioManager.js+++ b/server/services/lmStudioManager.js@@ -601,16 +601,25 @@ function ggufMatchesQuant(filename, quant) {/*** Remove on-disk LM Studio files so a subsequent `lms get` actually re-fetches* them. A quant-tagged id (`repo@UD-Q4_K_M` / `hf.co/repo:UD-Q4_K_M`) evicts- * only matching GGUFs and leaves sibling quants alone. A bare repo id is a- * no-op (`missing: true`) rather than wiping every quant in the folder — pick- * a tagged variant to redownload a specific build. Missing files are success- * so a first-time install can share this path. Ambiguous ids refuse, same as- * deleteModel.+ * only matching GGUFs and leaves sibling quants alone. A bare repo id fails —+ * we cannot name the file to replace, and wiping the folder would drop sibling+ * quants. Missing files are success (`missing: true`) so a first-time install+ * can share this path. Ambiguous ids refuse, same as deleteModel.* @returns {Promise<{ success: boolean, modelId: string, missing?: boolean, error?: string }>}*/async function evictDownloadedQuant(modelId) {const repoId = repoIdFromInstallId(modelId)const quant = quantFromInstallId(modelId)+ // A bare `publisher/repo` cannot name the GGUF to replace. Evicting the whole+ // folder would drop sibling quants; leaving files in place makes `lms get`+ // skip them and report a fake success. Callers must pass `repo@QUANT`.+ if (!quant) {+ return {+ success: false,+ error: 'Redownload needs a quantization tag (e.g. repo@UD-Q4_K_M). A bare repo id would skip existing GGUFs without replacing them.',+ modelId+ }+ }const modelsDir = await getModelsDir()const matches = await findDeletableModelDirs(modelsDir, repoId)if (matches === null) return { success: false, error: `Invalid model id "${modelId}".`, modelId }@@ -622,12 +631,6 @@ async function evictDownloadedQuant(modelId) {if (!isModelLeafDir(modelsDir, dir)) {return { success: false, error: `Refusing to evict "${dir}" — not a model folder under ${modelsDir}.`, modelId }}- if (!quant) {- // Bare `publisher/repo` would otherwise rm every quant in the folder. The- // caller still runs `lms get`; without a tag we cannot know which file to- // replace, so leave the disk alone rather than delete sibling builds.- return { success: true, missing: true, modelId }- }if (await checkLMStudioAvailable()) await unloadModel(modelId).catch(() => {})diff --git a/server/services/lmStudioManager.test.js b/server/services/lmStudioManager.test.jsindex b681109ffc..4f38fb833a 100644--- a/server/services/lmStudioManager.test.js+++ b/server/services/lmStudioManager.test.js@@ -225,14 +225,15 @@ describe('lmStudioManager evictDownloadedQuant', () => {expect(fs.existsSync(path.join(tempDir, 'unsloth', 'Qwen3.8-27B-GGUF', 'Qwen3.8-27B-UD-Q8_K_XL.gguf'))).toBe(true);});- it('does not wipe sibling quants when the id has no quant tag', async () => {+ it('refuses a bare repo id so a force redownload cannot skip existing GGUFs', async () => {writeFile('unsloth/Qwen3.8-27B-GGUF/Qwen3.8-27B-UD-Q4_K_M.gguf');writeFile('unsloth/Qwen3.8-27B-GGUF/Qwen3.8-27B-UD-Q8_K_XL.gguf');const { evictDownloadedQuant } = await import('./lmStudioManager.js');const result = await evictDownloadedQuant('unsloth/Qwen3.8-27B-GGUF');- expect(result).toMatchObject({ success: true, missing: true });+ expect(result.success).toBe(false);+ expect(result.error).toMatch(/quantization tag/i);expect(fs.existsSync(path.join(tempDir, 'unsloth', 'Qwen3.8-27B-GGUF', 'Qwen3.8-27B-UD-Q4_K_M.gguf'))).toBe(true);expect(fs.existsSync(path.join(tempDir, 'unsloth', 'Qwen3.8-27B-GGUF', 'Qwen3.8-27B-UD-Q8_K_XL.gguf'))).toBe(true);});diff --git a/server/services/localLlm.test.js b/server/services/localLlm.test.jsindex c574efb13b..046592e7f7 100644--- a/server/services/localLlm.test.js+++ b/server/services/localLlm.test.js@@ -250,6 +250,15 @@ describe('localLlm', () => {expect(result).toMatchObject({ success: false, error: 'ambiguous' });expect(mocks.lmstudio.downloadModel).not.toHaveBeenCalled();});+ it('does not download a force LM Studio redownload of a bare repo id', async () => {+ mocks.lmstudio.evictDownloadedQuant.mockResolvedValueOnce({+ success: false,+ error: 'Redownload needs a quantization tag'+ });+ const result = await svc.installModel('lmstudio', 'unsloth/Qwen3.8-27B-GGUF', undefined, { force: true });+ expect(result.success).toBe(false);+ expect(mocks.lmstudio.downloadModel).not.toHaveBeenCalled();+ });it('force is a no-op for Ollama beyond a regular pull', async () => {await svc.installModel('ollama', 'hf.co/unsloth/Qwen3.8-27B-GGUF:UD-Q4_K_M', undefined, { force: true });expect(mocks.ollama.pullModel).toHaveBeenCalledWith('hf.co/unsloth/Qwen3.8-27B-GGUF:UD-Q4_K_M', undefined);