Skip to content

The agent that grows with you

fix(desktop): offer local setup only for the recommended model

emozilla02118fc2de67
diff --git a/apps/desktop/src/store/local-setup-offer.test.ts b/apps/desktop/src/store/local-setup-offer.test.ts
new file mode 100644
index 00000000000..1f0518ea326
--- /dev/null
+++ b/apps/desktop/src/store/local-setup-offer.test.ts
@@ -0,0 +1,50 @@
+import { beforeEach, describe, expect, it, vi } from 'vitest'
+
+import type { HermesConnection } from '@/global'
+import type * as Hermes from '@/hermes'
+import type { LocalCatalogModel, LocalModelsStatus } from '@/types/hermes'
+
+const backend = vi.hoisted(() => ({ catalog: vi.fn(), status: vi.fn() }))
+
+vi.mock('@/hermes', async importOriginal => ({
+ ...(await importOriginal<typeof Hermes>()),
+ getLocalCatalog: () => backend.catalog(),
+ getLocalModelsStatus: () => backend.status()
+}))
+
+const row = (id: string, recommended: boolean): LocalCatalogModel =>
+ ({ fits: true, id, recommended }) as unknown as LocalCatalogModel
+
+async function eligibilityFor(models: LocalCatalogModel[]) {
+ backend.status.mockResolvedValue({ models: [], runtime_installed: false } as unknown as LocalModelsStatus)
+ backend.catalog.mockResolvedValue({ models })
+ const { $localModelsEnabled } = await import('./local-models-flag')
+ const { $connection } = await import('./session')
+ const { refreshLocalSetupEligibility } = await import('./local-setup-offer')
+
+ $localModelsEnabled.set(true)
+ $connection.set({ baseUrl: 'http://127.0.0.1:9', isFullscreen: false, mode: 'local' } as HermesConnection)
+
+ return refreshLocalSetupEligibility()
+}
+
+describe('local-setup offer eligibility', () => {
+ beforeEach(() => {
+ vi.resetModules()
+ localStorage.clear()
+ })
+
+ it('offers the model the catalog recommends', async () => {
+ const result = await eligibilityFor([row('qwen3.8-27b', false), row('qwen3.6-35b-a3b', true)])
+
+ expect(result.fit?.model.id).toBe('qwen3.6-35b-a3b')
+ })
+
+ it('stays quiet on a machine with no recommendation', async () => {
+ // A GTX 1080 with 16 GB of RAM: the 27B runs only with weights spilled to system memory, so the
+ // catalog recommends nothing and the offer must not name it.
+ const result = await eligibilityFor([row('qwen3.8-27b', false)])
+
+ expect(result.fit).toBeNull()
+ })
+})
diff --git a/apps/desktop/src/store/local-setup-offer.ts b/apps/desktop/src/store/local-setup-offer.ts
index 5b4e1484635..7b7f994c1e1 100644
--- a/apps/desktop/src/store/local-setup-offer.ts
+++ b/apps/desktop/src/store/local-setup-offer.ts
@@ -132,12 +132,13 @@ function pickLocalSetupFit(
return { checkedAt: at, fit: null, reason: 'local models already set up' }
}
- const fitting = catalog.filter(model => model.fits)
- const model = fitting.find(candidate => candidate.recommended) ?? fitting[0]
+ // The offer names the model the catalog recommends. A machine without a recommendation does not
+ // qualify, even when a model would run with part of its weights in system memory.
+ const model = catalog.find(candidate => candidate.recommended && candidate.fits)
return model
? { checkedAt: at, fit: { model }, reason: `fits ${model.id}` }
- : { checkedAt: at, fit: null, reason: 'no catalog model fits this machine' }
+ : { checkedAt: at, fit: null, reason: 'no catalog model is recommended for this machine' }
}
/** One status + catalog read per connection; a transient miss is retried on the next read. */