Skip to content

The ultimate harness for coding agents and beyond. All your agents. All your machines. One command center. Start with code, then follow your curiosity and build across disciplines: CAD, circuits, robots, games and music.

feat(models picker): rank local downloads for coding, show what each costs

bitcoinbuilder933e79768b5a
diff --git a/cli/src/lib/localModels.spec.ts b/cli/src/lib/localModels.spec.ts
index 5098ede4c..9918d13d2 100644
--- a/cli/src/lib/localModels.spec.ts
+++ b/cli/src/lib/localModels.spec.ts
@@ -5,7 +5,7 @@ import { tmpdir } from 'node:os'
import { createHash } from 'node:crypto'
import { rmSync, writeFileSync } from 'node:fs'
import { spawnSync } from 'node:child_process'
-import { compatibleModels, contextLadder, LocalModels, readRunRecords, type GridInventory } from './localModels.js'
+import { baseModel, compatibleModels, contextLadder, LocalModels, modelFamily, rankForCoding, readRunRecords, type GridInventory } from './localModels.js'
import { GridFleetRpc, type GridFleetResult } from './gridFleetRpc.js'
import { encryptDownFrame, encryptRpcResult } from './e2ee/applicationFrames.js'
@@ -429,8 +429,8 @@ describe('local model discovery and lifecycle', () => {
expect(JSON.stringify(snapshot)).not.toContain('private detail')
})
- it('supports an unpaginated catalog, prefers a useful small download, and skips unfitted versions', async () => {
- const large = card('org/Large-GGUF'), small = card('org/Fast-GGUF')
+ it('supports an unpaginated catalog, offers a fast model before a big slow one, and skips unfitted versions', async () => {
+ const large = card('org/Large-GGUF'), small = { ...card('org/Fast-GGUF'), fit: { ...card().fit, est_tok_s: 30 } }
large.versions[0].size_bytes = 20 * 1024 ** 3
small.versions[0].size_bytes = 2 * 1024 ** 3
small.versions.push({ ...small.versions[0], version: 'Q8', size_bytes: 4 * 1024 ** 3 })
@@ -439,6 +439,59 @@ describe('local model discovery and lifecycle', () => {
expect((await service.list('home')).models.map(m => [m.name, m.recommended])).toEqual([['Fast', true], ['Large', false]])
})
+ it('offers what a coding agent can work with first: fast enough, then bigger, then the catalog order', async () => {
+ // [id, estimated tok/s, billions of parameters] in the catalog's own order.
+ const rows: [string, number | undefined, number | undefined][] = [
+ ['org/Dense-70B-GGUF', 8, 70], // big, and slow on this machine
+ ['org/Qwen-35B-A3B-GGUF', 21, 35],
+ ['org/Qwen-35B-A3B-MTP-GGUF', 21, 35], // a variant of the one above
+ ['org/Tiny-4B-GGUF', 17, 4],
+ ['org/Other-35B-A3B-GGUF', 22, 35], // as big as Qwen, later in the catalog
+ ['org/Coder-Next-GGUF', 25, undefined], // no count: read off 48 GB of MXFP4 weights
+ ['org/Unknown-9B-GGUF', undefined, 9], // no estimate: not known to be fast
+ ['org/gpt-oss-safeguard-20b-GGUF', 24, 20], // a safety classifier, not a coding model
+ ]
+ catalogCards = rows.map(([id, estimate, params]) => {
+ const row: Record<string, any> = card(id)
+ const file = `${id.split('/')[1]}.gguf`
+ row.versions[0].pull_spec = `${id}:${file}`
+ if (estimate !== undefined) row.fit = { ...row.fit, est_tok_s: estimate }
+ if (params !== undefined) row.params_b = params
+ if (id.includes('Coder-Next')) {
+ row.fit = { ...row.fit, version: 'MXFP4_MOE' }
+ row.versions[0] = { ...row.versions[0], version: 'MXFP4_MOE', size_bytes: 48e9 }
+ }
+ return row as ReturnType<typeof card>
+ })
+ const snapshot = await service.list('home')
+ expect(snapshot.models.map(model => model.name)).toEqual([
+ 'Coder-Next', 'Qwen-35B-A3B', 'Other-35B-A3B', 'Tiny-4B',
+ 'Dense-70B', 'Unknown-9B',
+ 'Qwen-35B-A3B-MTP',
+ ])
+ expect(snapshot.models[0].recommended).toBe(true)
+ })
+
+ it('ranks without regard to where a model was in the catalog once speed or size tells them apart', () => {
+ const at = (name: string, estTokS: number, paramsB: number) =>
+ ({ id: `org/${name}`, name, pull: `org/${name}:${name}.gguf`, file: `${name}.gguf`, files: [`${name}.gguf`], size: 1, quant: 'Q4', estTokS, paramsB })
+ expect(rankForCoding([at('Slow-Big', 5, 70), at('Fast-Small', 20, 4), at('Fast-Big', 20, 30)]).map(c => c.name))
+ .toEqual(['Fast-Big', 'Fast-Small', 'Slow-Big'])
+ // At exactly the floor a model counts as fast enough.
+ expect(rankForCoding([at('Slow', 14.9, 30), at('Enough', 15, 4)]).map(c => c.name)).toEqual(['Enough', 'Slow'])
+ })
+
+ it('names one base model across its variants, and a fine-tune under its own name apart', () => {
+ for (const name of ['Qwen3.6-35B-A3B', 'Qwen3.6-35B-A3B-MTP', 'unsloth/Qwen3.6-35B-A3B-MTP-GGUF', 'Qwen3.6-35B-A3B-UD-Q5_K_XL.gguf']) {
+ expect(baseModel(name)).toBe('qwen3.6-35b-a3b')
+ }
+ expect(baseModel('gemma-4-E4B-it-qat')).toBe(baseModel('gemma-4-E4B-it'))
+ expect(baseModel('GLM-4.7-Flash-REAP-23B-A3B')).toBe(baseModel('GLM-4.7-Flash'))
+ expect(baseModel('Qwen3-VL-30B-A3B-Thinking')).toBe(baseModel('Qwen3-VL-30B-A3B-Instruct'))
+ expect(baseModel('Qwen-AgentWorld-35B-A3B')).not.toBe(baseModel('Qwen3.6-35B-A3B'))
+ expect(baseModel('Qwen3.5-9B')).not.toBe(baseModel('Qwen3.5-4B'))
+ })
+
it.each(['failed command', 'invalid json'])('disables actions when inventory returns %s', async scenario => {
await service.list('home')
const original = run.getMockImplementation()!
@@ -738,6 +791,50 @@ describe('local model discovery and lifecycle', () => {
expect(calls.filter(args => args.includes('join'))).toHaveLength(1)
})
+ it('tells, per model, the window and speed the catalog expects on this machine, and the free disk', async () => {
+ catalogCards = [{ ...card(), params_b: 9, fit: { ...card().fit, est_tok_s: 21.3 } } as ReturnType<typeof card>, card('org/Bare-GGUF')]
+ catalogCards[1].versions[0].pull_spec = 'org/Bare-GGUF:Bare-Q4.gguf'
+ const snapshot = await service.list('home')
+ expect(snapshot.models[0]).toMatchObject({ name: 'Small', contextWindow: 131072, estTokS: 21.3, paramsB: 9 })
+ // A catalog row that does not say is shown without, never as zero.
+ expect(snapshot.models[1]).not.toHaveProperty('estTokS')
+ expect(snapshot.models[1]).not.toHaveProperty('paramsB')
+ expect(snapshot.freeDiskBytes).toBeGreaterThan(0)
+ })
+
+ it('names one model the same whatever its quantization', () => {
+ for (const name of ['Qwen3.6-35B-A3B', 'unsloth/Qwen3.6-35B-A3B-GGUF', 'Qwen3.6-35B-A3B-UD-Q5_K_XL.gguf', 'Qwen3.6-35B-A3B-Q4_K_M',
+ 'qwen3.6-35b-a3b-bf16', 'Qwen3.6-35B-A3B-IQ4_XS', 'Qwen3.6-35B-A3B-MXFP4_MOE']) {
+ expect(modelFamily(name)).toBe('qwen3.6-35b-a3b')
+ }
+ // Another model of the family stays another model.
+ expect(modelFamily('Qwen3.6-35B-A3B-MTP')).not.toBe(modelFamily('Qwen3.6-35B-A3B'))
+ })
+
+ it('does not offer to download another quantization of a model this machine already has', async () => {
+ catalogCards = [card(), card('org/Other-GGUF')]
+ catalogCards[1].versions[0].pull_spec = 'org/Other-GGUF:Other-Q4.gguf'
+ // Small at Q8, imported from an existing setup and serving: the catalog's Q4 of it is a second copy.
+ serving = true
+ await writeFile(join(home, 'models', 'Small-Q8_0.gguf'), Buffer.alloc(96))
+ await writeFile(join(records, 'remote.json'), JSON.stringify({ node_id: 'local-node',
+ engines: [{ endpoint_url: null, models: ['Small-Q8_0.gguf'] }], advertise_as: [] }))
+ await writeFile(join(records, 'remote.heartbeat'), '')
+ run.mockImplementation(async (args: string[]) => {
+ calls.push(args)
+ if (args[0] === 'device-info') return ok({ device_class: 'apple-silicon', backend: 'metal', usable_bytes: 54 * 1024 ** 3, memory: { total_gb: 64 } })
+ if (args.includes('ls')) return ok([{ grid: 'home', id: 'grid-home' }])
+ if (args.includes('info') && args.includes('--json')) return ok({ grid: 'home', status: 'running' })
+ if (args.includes('engines')) return ok([{ node_id: 'local-node', online: true, models: ['Small-Q8_0.gguf'] }])
+ return ok()
+ })
+ const snapshot = await service.list('home')
+ expect(snapshot.models.map(model => [model.id, model.state])).toEqual([
+ ['org/Other-GGUF', 'available'],
+ ['local:Small-Q8_0.gguf', 'running'],
+ ])
+ })
+
it('keeps imported downloads visible, merges catalog matches, and removes deleted files', async () => {
catalogCards = []
await writeFile(join(home, 'models', 'Small-Q4.gguf'), Buffer.alloc(64))
diff --git a/cli/src/lib/localModels.ts b/cli/src/lib/localModels.ts
index 5879afd3f..2ae57ea46 100644
--- a/cli/src/lib/localModels.ts
+++ b/cli/src/lib/localModels.ts
@@ -64,6 +64,10 @@ export interface LocalModel {
id: string; name: string; state: 'available' | 'downloaded' | 'running'
sizeBytes?: number; quant?: string; recommended?: boolean; canStart: boolean; canStop: boolean
tokensPerSecond?: number; requests?: number; windowSeconds?: number
+ /** What the catalog says of this model on THIS machine, for choosing between models before any
+ * download: the window it will be given, its estimated speed, and its size in billions of
+ * parameters. Absent for a model found on disk, which the catalog never sized. */
+ contextWindow?: number; estTokS?: number; paramsB?: number
operation?: ModelOperation
/** Running here, parked while its grid sleeps (additive: an older desktop reads plain `running`). */
gridAsleep?: boolean
@@ -81,14 +85,18 @@ export interface LocalModelsSnapshot {
notice?: string
observedAt: string; busy: boolean
supportsDownload?: boolean
+ /** Free space where downloads land, so a download's size can be read against it. */
+ freeDiskBytes?: number
}
-interface Candidate {
+export interface Candidate {
id: string; name: string; pull: string; file: string; files: string[]; size: number; quant: string
/** The window to pin at start: the catalog's fit for this machine, which is the largest it can
* hold. Absent for a model found on disk, which the catalog never sized — the engine then measures
* free memory at load and takes the largest window that fits (`grid join` without `--ctx-size`). */
context?: number
aliases?: string[]
+ /** The catalog's estimate for this machine, and the model's size in billions of parameters. */
+ estTokS?: number; paramsB?: number
}
/** `live`: its heartbeat sidecar is fresh (the grid is hearing from it). `pidAlive`: the process its run
* record names exists — the only liveness that holds while the grid sleeps and the sidecar goes stale. */
@@ -137,11 +145,87 @@ export function compatibleModels(raw: unknown): Candidate[] {
try { return [basename(decodeURIComponent(new URL(str(url)).pathname))] } catch { return [] }
})
seen.add(id)
+ const estTokS = num(fit.est_tok_s), paramsB = num(row.params_b)
return [{ id, name: cleanName(id), pull, file, files: files.length ? files : [file], size,
- quant: str(fit.version), context: fitted }]
+ quant: str(fit.version), context: fitted,
+ ...(estTokS ? { estTokS } : {}), ...(paramsB ? { paramsB } : {}) }]
})
}
+/** One model, whatever its quantization: `Qwen3.6-35B-A3B`, `Qwen3.6-35B-A3B-UD-Q5_K_XL.gguf` and
+ * `unsloth/Qwen3.6-35B-A3B-GGUF` are the same model. */
+export function modelFamily(name: string): string {
+ return cleanName(name).toLowerCase()
+ .replace(/[-_.](?:ud[-_])?(?:iq\d\w*|q\d\w*|mxfp\d\w*|bf16|fp16|f16)$/, '')
+}
+
+/** A catalog download is not offered for a model this machine already has in another quantization:
+ * running Qwen3.6-35B-A3B at Q5_K_XL, the catalog's Q4_K_M of it is a second copy, 20 GB of it, of
+ * the same model. A download already under way stays listed, so its progress has a row. */
+export function withoutCopiesOfOwned(models: LocalModel[]): LocalModel[] {
+ const owned = new Set(models.filter(model => model.state !== 'available').map(model => modelFamily(model.name)))
+ return models.filter(model => model.state !== 'available' || model.canStop || model.operation?.phase === 'running' ||
+ !owned.has(modelFamily(model.name)))
+}
+
+/** The speed a coding agent can work at: an agent waits on every token it writes, and below this the
+ * catalog's estimate for this machine reads as a model that crawls. */
+export const USABLE_TOK_S = 15
+
+/** Catalog models that are not for running an agent on: safety classifiers such as gpt-oss-safeguard
+ * or Llama Guard, which answer "safe"/"unsafe" rather than code. */
+const NOT_FOR_AGENTS = /(?:^|[-_/])(?:safeguard|guard|shieldgemma)(?:[-_.]|$)/i
+
+/** Roughly how many bits a weight takes at [quant]: Q4 about 4.8, IQ4 about 4.3, MXFP4 4.25. */
+function bitsPerWeight(quant: string): number {
+ const q = quant.toUpperCase()
+ if (/MXFP4/.test(q)) return 4.25
+ if (/BF16|FP16|F16/.test(q)) return 16
+ const digit = /(IQ|Q)(\d)/.exec(q)
+ return digit ? Number(digit[2]) + (digit[1] === 'IQ' ? 0.3 : 0.8) : 4.8
+}
+
+/** A model's size in billions of parameters: the catalog's count, else read off its weights and quant. */
+function paramsOf(candidate: Candidate): number {
+ return candidate.paramsB ?? candidate.size * 8 / bitsPerWeight(candidate.quant) / 1e9
+}
+
+/** A model and its variants — MTP, QAT, REAP-pruned, instruct/thinking/`-it` — as one base model:
+ * `Qwen3.6-35B-A3B-MTP` and `Qwen3.6-35B-A3B`, `gemma-4-E4B-it-qat` and `gemma-4-E4B-it`. A fine-tune
+ * under its own name (`Qwen-AgentWorld-35B-A3B`) is a model of its own. */
+export function baseModel(name: string): string {
+ let base = modelFamily(name)
+ for (;;) {
+ const next = base.replace(/[-_](?:mtp|qat|reap(?:-\d+b)?(?:-a\d+b)?|instruct|thinking|it)$/, '')
+ if (next === base) return base
+ base = next
+ }
+}
+
+/** The order the Get list offers a machine's downloads in. Every candidate already fits the machine
+ * with a coding agent's context ([compatibleModels]); among them:
+ * 1. fast enough to work with first — the catalog's estimate for this machine at [USABLE_TOK_S] or
+ * more. That is what preferring MoE models on a bandwidth-bound Mac comes to, read per machine, and
+ * it lets dense models in on a machine fast enough for them;
+ * 2. then bigger first, the better model;
+ * 3. then the catalog's own order, which is popularity among what fits.
+ * And one version of each base model ([baseModel]) before any second one, so MTP, QAT and pruned
+ * copies of one model never fill the top of the list: they follow every other model, in this order. */
+export function rankForCoding<T extends Candidate>(candidates: T[]): T[] {
+ const fast = (candidate: Candidate): number => (candidate.estTokS ?? 0) >= USABLE_TOK_S ? 1 : 0
+ const sorted = candidates.map((candidate, index) => ({ candidate, index })).sort((a, b) =>
+ fast(b.candidate) - fast(a.candidate) ||
+ Math.round(paramsOf(b.candidate)) - Math.round(paramsOf(a.candidate)) ||
+ a.index - b.index).map(({ candidate }) => candidate)
+ const seen = new Set<string>(), first: T[] = [], again: T[] = []
+ for (const candidate of sorted) {
+ const base = baseModel(candidate.name)
+ ;(seen.has(base) ? again : first).push(candidate)
+ seen.add(base)
+ }
+ return [...first, ...again]
+}
+
export class LocalModels {
private readonly processEnv: NodeJS.ProcessEnv
private readonly home: string
@@ -215,7 +299,7 @@ export class LocalModels {
try {
this.device = obj(await this.json(['device-info', '--json']))
const catalog = obj(await this.catalog(this.device))
- this.candidates = compatibleModels(catalog)
+ this.candidates = rankForCoding(compatibleModels(catalog).filter(candidate => !NOT_FOR_AGENTS.test(candidate.id)))
// Prefer an already downloaded fitting quant rather than downloading
// the catalog's default version of the same model again.
for (let i = 0; i < this.candidates.length; i++) {
@@ -228,10 +312,6 @@ export class LocalModels {
if (alternate && await this.downloaded(alternate)) { this.candidates[i] = alternate; break }
}
}
- // A useful small download makes the first reply arrive sooner. Keep
- // the catalog's relevance order within that group, and show all others.
- const suggested = this.candidates.findIndex(c => c.size <= 8 * GiB && c.size >= GiB)
- if (suggested > 0) this.candidates.unshift(...this.candidates.splice(suggested, 1))
this.catalogError = undefined
this.catalogAt = Date.now()
} catch (error) {
@@ -464,6 +544,9 @@ export class LocalModels {
const single = Array.isArray(node?.models) && node.models.length === 1
return { id: candidate.id, name: candidate.name, state: running ? 'running' : available ? 'downloaded' : 'available',
sizeBytes: candidate.size, quant: candidate.quant, recommended: index === 0,
+ ...(candidate.context ? { contextWindow: candidate.context } : {}),
+ ...(candidate.estTokS ? { estTokS: candidate.estTokS } : {}),
+ ...(candidate.paramsB ? { paramsB: candidate.paramsB } : {}),
canStart: !inventoryError && (!this.catalogError || !candidate.pull) && !instance, canStop: !inventoryError && !!instance,
// Device memory is deliberately not presented as this model's memory.
tokensPerSecond: single && running ? num(node?.throughput_tok_s) : undefined,
@@ -479,9 +562,12 @@ export class LocalModels {
operation: operation?.modelId === `local:${instance.file}` ? operation : undefined,
...(!serving && parked(instance) ? { gridAsleep: true } : {}) })
}
- const value: LocalModelsSnapshot = { models, memoryBytes: num(obj(this.device.memory).total_gb) === undefined ? undefined : this.device.memory.total_gb * GiB,
+ const freeDiskBytes = await statfs(join(this.home, 'models')).catch(() => statfs(this.home))
+ .then(disk => disk.bavail * disk.bsize, () => undefined)
+ const value: LocalModelsSnapshot = { models: withoutCopiesOfOwned(models), memoryBytes: num(obj(this.device.memory).total_gb) === undefined ? undefined : this.device.memory.total_gb * GiB,
hardware: str(obj(this.device.machine).model || obj(this.device.cpu).brand), notice: inventoryError || this.catalogError,
- observedAt: new Date().toISOString(), busy: !!this.active, supportsDownload: true }
+ observedAt: new Date().toISOString(), busy: !!this.active, supportsDownload: true,
+ ...(freeDiskBytes === undefined ? {} : { freeDiskBytes }) }
this.cached = { grid, at: Date.now(), value }
this.runningAtLastRead.set(grid, new Set(models.filter(model => model.state === 'running').map(model => model.id)))
return value
diff --git a/desktop/design/terminal-dialogs.md b/desktop/design/terminal-dialogs.md
index ee87b21af..ff63f134b 100644
--- a/desktop/design/terminal-dialogs.md
+++ b/desktop/design/terminal-dialogs.md
@@ -136,13 +136,25 @@ muted text: `@ machines`, `# projects`, `: models`,
Each hint is also a plain-text button: clicking it inserts the prefix into the
same editor and keeps typing focus there. Selected harnesses open with Enter.
Machines use Enter to **Manage**: focus moves to their controls without invoking
-one. Models use four sections: **Subscriptions**, **APIs**, **Your local AI
-models**, and **Shared with you**. Headers are plain muted text and never take
-selection. Put **[ Add ]** within APIs. Your local AI models puts downloaded
-models first, followed by models served on the user's machines. Keep the
-undownloaded catalog collapsed behind **[ Get models ]**; Enter expands it in
-place and selects the first catalog row. **[ Hide catalog ]** collapses it.
-Explicit searches also include matching catalog models. Shared rows show only
+one. Models use five sections: **Subscriptions**, **APIs**, **Your models**,
+the downloads, and **Shared with you**. Headers are plain muted text and never
+take selection. Put **[ Add ]** within APIs. Your models puts downloaded models
+first, followed by models served on the user's machines. The downloads are
+headed with the machine they are for and its memory (`Get for this Mac · 64 GB`),
+and a machine with nothing to download has no such heading. They are ordered
+for a coding agent on that machine: the ones the catalog estimates at 15 tok/s
+or more first, then bigger models first, then the catalog's own (popularity)
+order, with one version of each base model before any MTP, QAT or pruned
+variant; safety classifiers are never offered. The list shows the first five;
+the rest stay behind **[ More models (N) ]**, where Enter
+expands them in place and selects the first catalog row, and **[ Show fewer ]**
+collapses them. The catalog never offers another quantization of a model the
+machine already has. Explicit searches also include matching catalog models.
+A model row names its model alone; the quantization is in the preview, and on
+the row only when two versions of one model share a name. Ahead of its last
+word a model of yours lines up two columns, its size and its speed (measured
+while it runs, else the catalog's estimate, `~10 tok/s`); a list too narrow to
+keep the name readable drops them. Shared rows show only
the model and sharing machine's label, separated by ` · `. An API heads its models:
`▸`/`▾` before its name says whether they are listed, and the end of its row says
how many (`378 models`) or `Tools` for one no harness can run on. Its models
@@ -153,7 +165,13 @@ harness on this computer. Filtering
preserves the groups.
A plain right-aligned **Use** identifies a model the current pane can use;
-**Get** identifies a model that can be downloaded. Other model rows are dimmed,
+**Get** identifies a model that can be downloaded. A model of yours says what
+Enter does unless something is happening to it (**Downloading**, **Starting**),
+and the one the pane is on says **● In use**. Only a live row's word is green —
+running, in use, or under way; an action is plain, a failure a warning. Get on
+a model the pane can run downloads it, starts it and moves the pane onto it in
+one step, with the hint following it (`Downloading 42%…`); closing the picker
+stops the switch, never the download. Other model rows are dimmed,
remain selectable for inspection, and have no action badge. Enter does nothing
on these rows; it must never silently become Manage. Show the reason in the
preview when it helps. Subscription names include the account label; only an
diff --git a/desktop/design/terminal-review-checklist.md b/desktop/design/terminal-review-checklist.md
index 8b7c88607..e8036c0e3 100644
--- a/desktop/design/terminal-review-checklist.md
+++ b/desktop/design/terminal-review-checklist.md
@@ -192,15 +192,23 @@ Escape or Cmd-Shift-J closes the experimental prompt.
Cmd-Shift-arrows to move a pane, and Cmd-Enter to zoom/restore. Run Return
to the last pane to switch back. Moves should preserve the other panes and
the running sessions. Cmd-I opens Models in Cmd-P with `:` already entered.
- Models have Subscriptions, APIs, Your local AI models, and Shared with you sections,
- with downloaded models first in Your local AI models. Undownloaded models
- appear when expanding [ Get models ] or searching explicitly; [ Hide catalog ]
- collapses them. Usable rows say Use, downloadable rows Get. Other models
+ Models have Subscriptions, APIs, Your models, the downloads (headed
+ `Get for this Mac · 64 GB`) and Shared with you sections, with downloaded
+ models first in Your models. The top five downloads are listed — fast
+ enough (~15 tok/s or more) first, then bigger, one version per model; the rest
+ appear when expanding [ More models (N) ] or searching explicitly;
+ [ Show fewer ] collapses them. No download is another quantization of a
+ model already there. Rows line up size and speed columns; usable rows say
+ Use, downloadable rows Get, the pane's own model ● In use, and only live
+ rows are green. Other models
are dimmed; Enter must not switch focus or operate on them. Duplicate
subscriptions include their account label. Shared rows include the machine
name. From a live harness, Enter uses a model for that pane, starting
installed weights when needed; Get prepares uninstalled weights and stays
- open. The right pane has one contextual Get/Use/Stop button. Tab switches
+ open — unless a live harness can run the model, when Get downloads, starts
+ and switches in one step and Esc stops only the switch. The right pane
+ shows the download size against free disk, whether it fits in memory, the
+ estimated speed and context, and has one contextual Get/Use/Stop button. Tab switches
panes; arrows navigate within the active pane. Verify this in Cmd-N as well
as Cmd-P's model and machine scopes, including inline API and machine forms.
Search a host by either its Harness name (M2) or Grid hostname (mac.lan);
diff --git a/desktop/lib/models/local_model.dart b/desktop/lib/models/local_model.dart
index 2c44ee519..5724b8fed 100644
--- a/desktop/lib/models/local_model.dart
+++ b/desktop/lib/models/local_model.dart
@@ -15,6 +15,9 @@ class LocalModel {
this.windowSeconds,
this.operation,
this.gridAsleep = false,
+ this.contextWindow,
+ this.estTokS,
+ this.paramsB,
});
final String id, name, state;
final String? quant;
@@ -22,6 +25,11 @@ class LocalModel {
final bool recommended, canStart, canStop;
final LocalModelOperation? operation;
+ /// What the grid catalog expects of this model on its machine, for choosing before a download:
+ /// the window it is given, its estimated speed, and its size in billions of parameters. Absent
+ /// for weights found on disk, which the catalog never sized, and from an older daemon.
+ final double? contextWindow, estTokS, paramsB;
+
/// Running here, parked while the account's own grid sleeps (`gridAsleep`). It answers again by
/// itself on the next message, so the row says so rather than reading as a plain `running`. An
/// older daemon never sends it.
@@ -65,6 +73,9 @@ class LocalModel {
windowSeconds: _number(data['windowSeconds']),
operation: LocalModelOperation.parse(data['operation']),
gridAsleep: data['gridAsleep'] == true,
+ contextWindow: _number(data['contextWindow']),
+ estTokS: _number(data['estTokS']),
+ paramsB: _number(data['paramsB']),
);
}
diff --git a/desktop/lib/models/model_manager_controller.dart b/desktop/lib/models/model_manager_controller.dart
index 768e8f65a..7b9f2b5b6 100644
--- a/desktop/lib/models/model_manager_controller.dart
+++ b/desktop/lib/models/model_manager_controller.dart
@@ -60,6 +60,9 @@ class ModelManagerController extends ChangeNotifier {
GridModels? models;
List<LocalModel> localModels = const [];
double? memoryBytes;
+
+ /// Free space where downloads land, or null when the daemon did not say.
+ double? freeDiskBytes;
String? hardware, error, _managerError;
bool preparing = false, opening = false, scanning = false, loaded = false;
bool inventoryAvailable = false, operationBusy = false;
@@ -171,6 +174,7 @@ class ModelManagerController extends ChangeNotifier {
models = null;
localModels = const [];
memoryBytes = null;
+ freeDiskBytes = null;
hardware = null;
error = null;
_managerError = null;
@@ -443,6 +447,10 @@ class ModelManagerController extends ChangeNotifier {
memoryBytes = memory is num && memory.isFinite && memory > 0
? memory.toDouble()
: null;
+ final disk = answer['freeDiskBytes'];
+ freeDiskBytes = disk is num && disk.isFinite && disk >= 0
+ ? disk.toDouble()
+ : null;
hardware = answer['hardware'] as String?;
operationBusy = answer['busy'] == true;
supportsDownload = answer['supportsDownload'] == true;
diff --git a/desktop/lib/models/model_search_catalog.dart b/desktop/lib/models/model_search_catalog.dart
index c73684bb5..8cde7b754 100644
--- a/desktop/lib/models/model_search_catalog.dart
+++ b/desktop/lib/models/model_search_catalog.dart
@@ -13,7 +13,11 @@ import 'model_manager_controller.dart';
enum ModelSearchSection {
subscriptions('Subscriptions'),
apis('APIs'),
- local('Your local AI models'),
+ local('Your models'),
+
+ /// Models a machine of yours can download: the grid catalog's picks for it. Its heading names the
+ /// machine and its memory ([ModelSearchCatalog.catalogHeading]); this label is its search word.
+ catalog('Get models'),
shared('Shared with you');
const ModelSearchSection(this.label);
@@ -58,10 +62,20 @@ class ModelSearchEntry {
? ModelSearchSection.subscriptions
: api != null
? ModelSearchSection.apis
+ : isDownload
+ ? ModelSearchSection.catalog
: own
? ModelSearchSection.local
: ModelSearchSection.shared;
+ /// A catalog model a machine of yours does not have yet — downloading, or not started on.
+ /// An engine of yours that is not serving is still yours ([LocalModel.canStop]).
+ bool get isDownload =>
+ local != null &&
+ !local!.downloaded &&
+ !local!.canStop &&
+ gridModel == null;
+
bool get needsDownload =>
local != null &&
!local!.downloaded &&
@@ -246,8 +260,6 @@ class ModelSearchCatalog extends ChangeNotifier {
words.subtitle ??
(manager.models?.reachable == false
? 'Unavailable'
- : section.own
- ? 'Suggested'
: 'Available'),
),
);
@@ -268,9 +280,9 @@ class ModelSearchCatalog extends ChangeNotifier {
local.sort((a, b) {
final state = rank(a.owner, a.model).compareTo(rank(b.owner, b.model));
if (state != 0) return state;
- // Preserve the daemon's grid-ranking order (the order the catalog
- // service returned), not an alphabetised re-sort — so the top models
- // match `grid catalog` / `list` instead of listing alphabetical first.
+ // Preserve the daemon's order, not an alphabetised re-sort: it ranks the
+ // catalog's downloads for a coding agent on that machine (`rankForCoding`
+ // in the CLI's localModels.ts), so its first are the ones to offer.
final aIndex = a.owner.localModels.indexOf(a.model);
final bIndex = b.owner.localModels.indexOf(b.model);
final order = aIndex.compareTo(bIndex);
@@ -285,6 +297,16 @@ class ModelSearchCatalog extends ChangeNotifier {
a.model,
).compareTo(_managedKey(b.owner, b.model));
});
+ // A row names its model alone; the quantization is in the preview. Only two versions of one
+ // model on one machine need it to be told apart.
+ final named = <String, int>{};
+ for (final (:owner, :model) in local) {
+ final key = '${identityHashCode(owner)}:${model.name.toLowerCase()}';
+ named[key] = (named[key] ?? 0) + 1;
+ }
+ bool twin(ModelManagerController owner, LocalModel model) =>
+ (named['${identityHashCode(owner)}:${model.name.toLowerCase()}'] ?? 0) >
+ 1;
final all = [
for (final (:owner, :model) in local)
ModelSearchEntry(
@@ -294,7 +316,9 @@ class ModelSearchCatalog extends ChangeNotifier {
? 'model:local:${model.id}'
: 'model:machine:${_managedKey(owner, model)}'),
),
- name: model.displayName,
+ name: model.name.isEmpty || twin(owner, model)
+ ? model.displayName
+ : model.name,
source: 'Local',
node: owner.machine?.machine.displayName,
status: localStatus(model, controller: owner),
@@ -302,7 +326,10 @@ class ModelSearchCatalog extends ChangeNotifier {
own: true,
controller: owner,
gridModel: served[_managedKey(owner, model)],
- searchAliases: [?owner.machine?.machine.hostname],
+ searchAliases: [
+ ?owner.machine?.machine.hostname,
+ ?model.quantization,
+ ],
),
...discovered.where((entry) => entry.own),
...discovered.where((entry) => !entry.own),
@@ -369,13 +396,16 @@ class ModelSearchCatalog extends ChangeNotifier {
? 'Running'
: model.downloaded
? 'Downloaded'
- : 'Suggested';
+ : 'Not downloaded';
}
/// The inline status word for a list row: a short word with no progress
/// percentage (the percentage lives in the pane/detail). Operation and pending
/// states map to their bare label so the row never repeats the "42%".
- String localStatusWord(LocalModel model, {ModelManagerController? controller}) {
+ String localStatusWord(
+ LocalModel model, {
+ ModelManagerController? controller,
+ }) {
final owner = controller ?? manager;
final operation = owner.operationFor(model);
if (operation?.active == true) return operation!.label;
@@ -391,7 +421,25 @@ class ModelSearchCatalog extends ChangeNotifier {
? 'Running'
: model.downloaded
? 'Downloaded'
- : 'Suggested';
+ : 'Not downloaded';
+ }
+
+ /// The downloads' heading: the machine they are for and its memory, `Get for this Mac · 64 GB`.
+ /// Downloads for more than one machine are headed plainly; each row's preview names its machine.
+ String get catalogHeading {
+ final owners = {
+ for (final entry in entries.values)
+ if (entry.section == ModelSearchSection.catalog)
+ entry.controller ?? manager,
+ };
+ if (owners.length != 1) return ModelSearchSection.catalog.label;
+ final owner = owners.single;
+ final machine = owner.machine;
+ final memory = owner.memoryBytes;
+ return [
+ 'Get for ${machine == null || machine.isLocalMachine ? thisComputerName() : machine.machine.displayName}',
+ if (memory != null) gigabytesLabel(memory),
+ ].join(' · ');
}
@override
@@ -406,3 +454,14 @@ class ModelSearchCatalog extends ChangeNotifier {
super.dispose();
}
}
+
+/// Bytes as a person reads a model's size: `2.7 GB` under ten, `27 GB` above.
+String gigabytesLabel(double bytes) {
+ final gb = bytes / (1024 * 1024 * 1024);
+ return gb < 9.95 ? '${gb.toStringAsFixed(1)} GB' : '${gb.round()} GB';
+}
+
+/// This computer as its owner calls it: `this Mac` on a Mac, `this computer` on Linux.
+String thisComputerName() => defaultTargetPlatform == TargetPlatform.macOS
+ ? 'this Mac'
+ : 'this computer';
diff --git a/desktop/lib/screens/swarm_screen.dart b/desktop/lib/screens/swarm_screen.dart
index f51ec6324..4074050e1 100644
--- a/desktop/lib/screens/swarm_screen.dart
+++ b/desktop/lib/screens/swarm_screen.dart
@@ -4298,6 +4298,7 @@ class _SwarmScreenState extends State<SwarmScreen> {
focused.engine,
app.gridPictures[focused.pane.machineId],
machineId: focused.pane.machineId,
+ agentId: focused.agentId,
);
void selectCurrent() {
if (search.query != ':' || search.managing) return;
@@ -4325,6 +4326,7 @@ class _SwarmScreenState extends State<SwarmScreen> {
focused.engine,
choices,
machineId: focused.pane.machineId,
+ agentId: focused.agentId,
);
if (search.selected?.id == initialSelection) selectCurrent();
}),
@@ -4763,13 +4765,17 @@ class _SwarmScreenState extends State<SwarmScreen> {
final placement = _search?.placement;
final answering = _search?.sessionFilter == SessionFilter.needsInput;
if (target == null) return;
+ // Get on a model the focused harness can run on downloads it, starts it and moves the harness
+ // onto it, below. With no such harness, Get only downloads.
if (choice.destination.isModel &&
- _search!.canGetModel(choice.destination)) {
+ _search!.canGetModel(choice.destination) &&
+ !_search!.canGetModelForUse(choice.destination)) {
await _search!.getModel(choice.destination);
return;
}
if (choice.destination.isModel &&
- _search!.canSelectModel(choice.destination)) {
+ (_search!.canSelectModel(choice.destination) ||
+ _search!.canGetModelForUse(choice.destination))) {
final search = _search!;
if (search.usingModelId != null) return;
final chosenFor = _modelSelectionTarget;
@@ -4806,7 +4812,14 @@ class _SwarmScreenState extends State<SwarmScreen> {
return;
}
var selected = search.selectableGridModel(choice.destination);
- if (selected == null && search.canStartModelForUse(choice.destination)) {
+ if (selected == null && search.canGetModelForUse(choice.destination)) {
+ selected = await search.getModelForUse(
+ choice.destination,
+ stillCurrent: current,
+ );
+ if (!mounted || !current() || selected == null) return;
+ } else if (selected == null &&
+ search.canStartModelForUse(choice.destination)) {
selected = await search.startModelForUse(
choice.destination,
stillCurrent: current,
@@ -5247,8 +5260,13 @@ class _SwarmScreenState extends State<SwarmScreen> {
)
.firstOrNull;
if (destination == null) return false;
- final readToken = app.agentUnread.readTokenFor(row.machineId, row.agentId);
- final questionId = app.questionFor(row.machineId, row.agentId)?.requestId;
+ final readToken = app.agentUnread.readTokenFor(
+ row.machineId,
+ row.agentId,
+ );
+ final questionId = app
+ .questionFor(row.machineId, row.agentId)
+ ?.requestId;
final opened = await activateSwarmDestination(
app,
destination,
@@ -5257,9 +5275,15 @@ class _SwarmScreenState extends State<SwarmScreen> {
// Opening acknowledges this notification. Its question stays pending
// until the daemon confirms an answer, independently of unread state.
if (opened &&
- app.agentUnread.readTokenFor(row.machineId, row.agentId) == readToken &&
- app.questionFor(row.machineId, row.agentId)?.requestId == questionId) {
- app.readAgentNotification(row.machineId, row.agentId, readToken: readToken);
+ app.agentUnread.readTokenFor(row.machineId, row.agentId) ==
+ readToken &&
+ app.questionFor(row.machineId, row.agentId)?.requestId ==
+ questionId) {
+ app.readAgentNotification(
+ row.machineId,
+ row.agentId,
+ readToken: readToken,
+ );
}
return opened;
},
diff --git a/desktop/lib/state/swarm_search.dart b/desktop/lib/state/swarm_search.dart
index fa811e28e..7e5cb0bdf 100644
--- a/desktop/lib/state/swarm_search.dart
+++ b/desktop/lib/state/swarm_search.dart
@@ -3,11 +3,14 @@ import 'dart:async';
import 'package:flutter/foundation.dart';
import 'package:collection/collection.dart' show compareNatural;
-import '../models/api_connections_controller.dart' show ApiConnection, ApiModel;
+import '../models/api_connections_controller.dart'
+ show ApiConnection, ApiModel, agentOnApiModel;
+import '../models/local_model.dart';
import '../models/model_search_catalog.dart';
import '../core/dsh_catalog.dart';
import '../core/machine_resources.dart';
-import '../core/models.dart' show ConnectionStatus, GridModels, GridModel;
+import '../core/models.dart'
+ show Agent, ConnectionStatus, GridModels, GridModel;
import 'app_state.dart';
import 'harness_placement.dart';
@@ -172,18 +175,19 @@ class SwarmSearchController extends ChangeNotifier {
return (api: api, model: model);
}
- late final _showDownloadsRow = SwarmDestination(
- id: 'model:downloads',
- modelId: 'model:downloads',
- title: '[ Get models ]',
- detail: '',
- swarmId: null,
- current: false,
- );
- late final _hideDownloadsRow = SwarmDestination(
+ /// How many catalog models the list shows before "More models" is pressed.
+ static const shownDownloads = 5;
+
+ /// Catalog models this list could show: the ones past [shownDownloads] are behind the row below.
+ int _downloadCount = 0;
+
+ /// The row under the downloads that shows the rest of the catalog, or folds it away again.
+ SwarmDestination get _downloadsRow => SwarmDestination(
id: 'model:downloads',
modelId: 'model:downloads',
- title: '[ Hide catalog ]',
+ title: modelDownloadsVisible
+ ? '[ Show fewer ]'
+ : '[ More models (${_downloadCount - shownDownloads}) ]',
detail: '',
swarmId: null,
current: false,
@@ -191,8 +195,16 @@ class SwarmSearchController extends ChangeNotifier {
ModelSearchSection modelSection(SwarmDestination row) => row.isCreate
? ModelSearchSection.apis
+ : isModelDownloadsRow(row)
+ ? ModelSearchSection.catalog
: models?.entries[row.modelId]?.section ?? ModelSearchSection.local;
+ /// A section's heading in the list. The downloads name the machine they are for.
+ String modelSectionLabel(ModelSearchSection section) =>
+ section == ModelSearchSection.catalog && models != null
+ ? models!.catalogHeading
+ : section.label;
+
String? modelRowAction(SwarmDestination row) {
final entry = models?.entries[row.modelId];
if (entry == null) return null;
@@ -203,35 +215,94 @@ class SwarmSearchController extends ChangeNotifier {
: null;
}
- /// The live status word for a model row (no glyph), shown inline in the list
- /// so you can see Running/Downloaded/usage at a glance. Derives the word from
- /// the same catalogue [ModelSearchCatalog.localStatus] the preview uses, so
- /// the list and the pane can never disagree.
+ /// The word at the end of a model row. A row of yours says what Enter does on it — Use, Get —
+ /// unless something is happening to it (Downloading, Starting) or the harness is already on it
+ /// (In use); only a row with no action says its state. Operation words come from the catalogue's
+ /// [ModelSearchCatalog.localStatusWord], which the preview's status also reads.
String? modelRowStatus(SwarmDestination row) {
final catalog = models;
final entry = catalog?.entries[row.modelId];
if (entry == null || catalog == null) return null;
+ if (modelRowInUse(row)) return inUseWord;
// An API's model says what Enter does on it — Use, when this pane can run on it, else nothing.
// Its entry's status is only the API's name, which the row it sits under already shows.
if (entry.apiModel != null) return modelRowAction(row);
final local = entry.local;
+ if (local == null) {
+ return entry.own ? modelRowAction(row) ?? entry.status : entry.status;
+ }
final owner = entry.controller ?? catalog.manager;
- return local != null
- ? catalog.localStatusWord(local, controller: owner)
- : entry.status;
+ final operation = owner.operationFor(local);
+ if (operation?.active == true ||
+ owner.pendingId == local.id ||
+ operation?.failed == true) {
+ return catalog.localStatusWord(local, controller: owner);
+ }
+ return modelRowAction(row) ??
+ (local.running
+ ? 'Running'
+ : local.downloaded
+ ? 'Downloaded'
+ : null);
+ }
+
+ static const inUseWord = '● In use';
+
+ /// Whether the harness this picker chooses for is on [row]'s model now: the grid model the
+ /// daemon read off its process, or a saved API's model at that API's address.
+ bool modelRowInUse(SwarmDestination row) {
+ final entry = models?.entries[row.modelId];
+ final agent = _modelSelectionAgent;
+ if (entry == null || agent == null) return false;
+ if (entry.apiModel case final model?) {
+ return agentOnApiModel(agent, entry.api!, model.id);
+ }
+ final current = agent.gridModel?.toLowerCase();
+ return current != null &&
+ entry.gridModel?.id.toLowerCase() == current &&
+ (entry.local?.running ?? true);
}
- /// Whether the model row is live right now (running, or a download/start/stop
- /// in progress). Drives the green status colour in the list.
+ /// Whether the model row is live right now: running, in use, or a download, start or stop under
+ /// way. Only a live row's word is green.
bool modelRowLive(SwarmDestination row) {
final catalog = models;
final entry = catalog?.entries[row.modelId];
if (entry == null || catalog == null) return false;
+ if (modelRowInUse(row)) return true;
final local = entry.local;
- final op = local == null
- ? null
- : (entry.controller ?? catalog.manager).operationFor(local);
- return op?.active == true || (local?.running ?? false);
+ if (local == null) return false;
+ final owner = entry.controller ?? catalog.manager;
+ return owner.operationFor(local)?.active == true ||
+ owner.pendingId == local.id ||
+ local.running;
+ }
+
+ /// A model of yours that could not be started or downloaded: its row's word is a warning.
+ bool modelRowFailed(SwarmDestination row) {
+ final catalog = models;
+ final local = catalog?.entries[row.modelId]?.local;
+ if (catalog == null || local == null) return false;
+ final owner = catalog.entries[row.modelId]!.controller ?? catalog.manager;
+ return owner.operationFor(local)?.failed == true;
+ }
+
+ /// What sets one model of yours apart from the next, in two aligned columns ahead of the row's
+ /// word: its size, and its speed — measured while it runs, else the catalog's estimate for this
+ /// machine (`~`). Null for any other row. Widths are fixed so every row's columns line up.
+ String? modelRowFacts(SwarmDestination row) {
+ final local = models?.entries[row.modelId]?.local;
+ if (local == null) return null;
+ final size = local.sizeBytes == null
+ ? ''
+ : gigabytesLabel(local.sizeBytes!);
+ final measured = local.running ? local.tokensPerSecond : null;
+ final speed = measured != null
+ ? '${measured.round()} tok/s'
+ : local.estTokS != null
+ ? '~${local.estTokS!.round()} tok/s'
+ : '';
+ return '${size.padLeft(6)} ${speed.padLeft(9)}';
}
bool canGetModel(SwarmDestination? row) {
@@ -335,7 +406,20 @@ class SwarmSearchController extends ChangeNotifier {
bool managing = false;
String? modelSelectionEngine;
String? _modelSelectionMachineId;
+ String? _modelSelectionAgentId;
GridModels? _modelChoices;
+
+ /// The harness this picker chooses a model for, as the app knows it now.
+ Agent? get _modelSelectionAgent {
+ final id = _modelSelectionAgentId;
+ if (id == null) return null;
+ return app
+ .stateOf(_modelSelectionMachineId ?? '')
+ ?.agents
+ .where((agent) => agent.id == id)
+ .firstOrNull;
+ }
+
String? usingModelId;
String? modelUseErrorId, modelUseError;
Timer? _modelUseTimer;
@@ -345,9 +429,11 @@ class SwarmSearchController extends ChangeNotifier {
String? engine,
GridModels? choices, {
String? machineId,
+ String? agentId,
}) {
modelSelectionEngine = engine;
_modelSelectionMachineId = machineId;
+ _modelSelectionAgentId = engine == null ? null : agentId;
_modelChoices = choices;
notifyListeners();
}
@@ -451,11 +537,91 @@ class SwarmSearchController extends ChangeNotifier {
Duration timeout = const Duration(minutes: 3),
}) async {
if (usingModelId != null || !canStartModelForUse(row)) return null;
+ return _useModel(
+ row,
+ stillCurrent: stillCurrent,
+ timeout: timeout,
+ download: false,
+ );
+ }
+
+ /// Whether Get on [row] can go on to put the picker's harness on the model: a download of yours,
+ /// chosen for a harness that can run on a local model. Otherwise Get only downloads.
+ ///
+ /// Not while another model runs on that machine: its daemon runs one local model at a time and
+ /// refuses the start, so Get would download and then fail. It only downloads, and says why.
+ bool canGetModelForUse(SwarmDestination? row) =>
+ canGetModel(row) &&
+ modelSelectionEngine != null &&
+ _modelChoices?.reachable == true &&
+ _modelChoices?.canRunLocally(modelSelectionEngine) == true &&
+ models!.entries[row!.modelId]!.own &&
+ otherRunningModel(row) == null;
+
+ /// Another model of yours running on [row]'s machine — the one to stop before [row]'s can run.
+ LocalModel? otherRunningModel(SwarmDestination? row) {
+ final entry = models?.entries[row?.modelId];
+ final local = entry?.local, owner = entry?.controller;
+ if (local == null || owner == null) return null;
+ return owner.localModels
+ .where((model) => model.canStop && model.id != local.id)
+ .firstOrNull;
+ }
+
+ /// Get, then Use, in one step: downloads [row]'s model, starts it, and answers the grid model the
+ /// harness can be switched to. The daemon owns the download, so closing the picker stops only
+ /// the waiting and the switch — the download goes on, and the row says so.
+ Future<GridModel?> getModelForUse(
+ SwarmDestination row, {
+ required bool Function() stillCurrent,
+ Duration timeout = const Duration(minutes: 3),
+ }) async {
+ if (usingModelId != null || !canGetModelForUse(row)) return null;
+ return _useModel(
+ row,
+ stillCurrent: stillCurrent,
+ timeout: timeout,
+ download: true,
+ );
+ }
+
+ /// What the picker is doing for Use or Get, for its hint: `Downloading 42%…`, `Starting…`.
+ String? get usingLabel {
+ final entry = models?.entries[usingModelId];
+ final local = entry?.local;
+ if (usingModelId == null) return null;
+ if (entry == null || local == null) return 'Starting…';
+ final owner = entry.controller ?? models!.manager;
+ final operation = owner.operationFor(local);
+ if (operation?.active == true && operation!.stage == 'downloading') {
+ final progress = operation.progress;
+ return 'Downloading${progress == null ? '' : ' ${(progress * 100).floor()}%'}…';
+ }
+ return local.downloaded || owner.pendingStart
+ ? 'Starting…'
+ : 'Downloading…';
+ }
+
+ Future<void> _modelUsePause() async {
+ _modelUseWait = Completer<void>();
+ _modelUseTimer = Timer(const Duration(seconds: 2), () {
+ if (_modelUseWait?.isCompleted == false) _modelUseWait!.complete();
+ });
+ await _modelUseWait!.future;
+ _modelUseWait = null;
+ _modelUseTimer = null;
+ }
+
+ Future<GridModel?> _useModel(
+ SwarmDestination row, {
+ required bool Function() stillCurrent,
+ required Duration timeout,
+ required bool download,
+ }) async {
final entry = models!.entries[row.modelId]!;
final owner = entry.controller!;
final modelId = entry.local!.id;
final host = owner.machine;
- final deadline = DateTime.now().add(timeout);
usingModelId = row.modelId;
modelUseErrorId = modelUseError = null;
notifyListeners();
@@ -466,19 +632,59 @@ class SwarmSearchController extends ChangeNotifier {
modelUseError = message;
}
+ bool hostGone() =>
+ host?.connectionStatus != ConnectionStatus.connected ||
+ host?.needsLink == true ||
+ host?.isOffline == true;
+ LocalModel? model() =>
+ owner.localModels.where((model) => model.id == modelId).firstOrNull;
+
try {
- await owner.control(entry.local!, 'start');
+ if (download) {
+ await owner.control(
+ entry.local!,
+ owner.supportsDownload ? 'download' : 'start',
+ );
+ // A download takes as long as it takes, with its progress on the row: no deadline here.
+ while (true) {
+ if (!current()) return null;
+ if (hostGone()) {
+ fail('Reconnect to ${entry.node} to get this model.');
+ return null;
+ }
+ final got = model();
+ final operation = got == null ? null : owner.operationFor(got);
+ if (operation?.failed == true ||
+ (owner.error != null && !owner.busy)) {
+ fail(
+ operation?.error ??
+ owner.error ??
+ 'Could not download this model. Try again.',
+ );
+ return null;
+ }
+ if (got != null &&
+ got.downloaded &&
+ operation?.active != true &&
+ !owner.busy) {
+ if (!got.running) await owner.control(got, 'start');
+ break;
+ }
+ await _modelUsePause();
+ if (!current()) return null;
+ await owner.refresh();
+ }
+ } else {
+ await owner.control(entry.local!, 'start');
+ }
+ final deadline = DateTime.now().add(timeout);
while (current()) {
- if (host?.connectionStatus != ConnectionStatus.connected ||
- host?.needsLink == true ||
- host?.isOffline == true) {
+ if (hostGone()) {
fail('Reconnect to ${entry.node} to use this model.');
return null;
}
- final model = owner.localModels
- .where((model) => model.id == modelId)
- .firstOrNull;
- final operation = model == null ? null : owner.operationFor(model);
+ final started = model();
+ final operation = started == null ? null : owner.operationFor(started);
if (operation?.failed == true || (owner.error != null && !owner.busy)) {
fail(
operation?.error ??
@@ -487,7 +693,7 @@ class SwarmSearchController extends ChangeNotifier {
);
return null;
}
- if (model?.running == true && operation?.active != true) {
+ if (started?.running == true && operation?.active != true) {
await models!.manager.refresh(force: true);
if (!current()) return null;
final machineId = _modelSelectionMachineId;
@@ -505,13 +711,7 @@ class SwarmSearchController extends ChangeNotifier {
);
return null;
}
- _modelUseWait = Completer<void>();
- _modelUseTimer = Timer(const Duration(seconds: 2), () {
- if (_modelUseWait?.isCompleted == false) _modelUseWait!.complete();
- });
- await _modelUseWait!.future;
- _modelUseWait = null;
- _modelUseTimer = null;
+ await _modelUsePause();
if (!current()) return null;
await owner.refresh();
}
@@ -995,8 +1195,8 @@ class SwarmSearchController extends ChangeNotifier {
: row!.title
: isModelDownloadsRow(row)
? modelDownloadsVisible
- ? 'Hide catalog'
- : 'Get models'
+ ? 'Show fewer'
+ : 'More models'
: canExpandApi(row)
? expandedApis.contains(models!.entries[row!.modelId]!.api!.id)
? 'Hide models'
@@ -1280,13 +1480,18 @@ class SwarmSearchController extends ChangeNotifier {
(query.isNotEmpty && row.agentId != null)),
)
.toList();
+ if (isModelMode) {
+ _downloadCount = candidates
+ .where((row) => models?.entries[row.modelId]?.needsDownload == true)
+ .length;
+ }
if (isModelMode && matchQuery.trim().isEmpty && !modelDownloadsVisible) {
- // Always surface the top few catalog models (in grid-ranking order) so the
+ // Always surface the top few catalog models (in the daemon's order) so the
// picker opens with them already in view; the rest stay hidden until
- // "Get models" is pressed.
+ // "More models" is pressed.
final topCatalog = candidates
.where((row) => models?.entries[row.modelId]?.needsDownload == true)
- .take(5)
+ .take(shownDownloads)
.map((row) => row.id)
.toSet();
candidates = candidates
@@ -1482,12 +1687,8 @@ class SwarmSearchController extends ChangeNotifier {
: [...found, ?create];
}
if (isModelMode) {
- if (matchQuery.trim().isEmpty &&
- models?.entries.values.any((entry) => entry.needsDownload) == true) {
- rows = [
- ...rows,
- modelDownloadsVisible ? _hideDownloadsRow : _showDownloadsRow,
- ];
+ if (matchQuery.trim().isEmpty && _downloadCount > shownDownloads) {
+ rows = [...rows, _downloadsRow];
}
// An API's models are listed under its row, as a group: a search that matches a model and not
// its API still shows the API above it, and the models of two APIs never interleave.
@@ -1509,7 +1710,8 @@ class SwarmSearchController extends ChangeNotifier {
rows.sort((a, b) {
final section = modelSection(a).index.compareTo(modelSection(b).index);
if (section != 0) return section;
- if (modelSection(a) != ModelSearchSection.local) {
+ if (modelSection(a) != ModelSearchSection.local &&
+ modelSection(a) != ModelSearchSection.catalog) {
final create = (a.isCreate ? 1 : 0).compareTo(b.isCreate ? 1 : 0);
if (create != 0) return create;
if (modelSection(a) == ModelSearchSection.apis && !a.isCreate) {
diff --git a/desktop/lib/widgets/swarm_resource_preview.dart b/desktop/lib/widgets/swarm_resource_preview.dart
index fde7bb28e..8f65da461 100644
--- a/desktop/lib/widgets/swarm_resource_preview.dart
+++ b/desktop/lib/widgets/swarm_resource_preview.dart
@@ -9,6 +9,7 @@ import '../shortcuts/app_keymap.dart';
import '../shortcuts/keymap.dart';
import '../models/api_connections_controller.dart'
show ApiModels, contextWindowLabel;
+import '../models/local_model.dart';
import '../models/model_search_catalog.dart';
import '../shared/theme/app_theme.dart' as grid;
import '../state/app_state.dart';
@@ -330,7 +331,9 @@ class _SwarmResourcePreviewState extends State<SwarmResourcePreview> {
action?.onPressed?.call();
return true;
}
+ // Get on a model the harness can run is Get and Use in one step: the choose path, as Use is.
if (widget.search.canSelectModel(row) ||
+ widget.search.canGetModelForUse(row) ||
widget.search.isModelDownloadsRow(row) ||
widget.search.canExpandApi(row)) {
_open();
@@ -632,7 +635,7 @@ class _SwarmResourcePreviewState extends State<SwarmResourcePreview> {
key('picker.control_next') != null)
'${key('picker.control_previous')}/${key('picker.control_next')} move',
if (starting)
- 'Starting…'
+ widget.search.usingLabel ?? 'Starting…'
else if (key('picker.accept') case final enter?
when managing ||
row?.isModel != true ||
@@ -764,7 +767,7 @@ class _SwarmResourcePreviewState extends State<SwarmResourcePreview> {
(get
? local.canStart
: search.canSelectModel(selected)))
- ? !stop && !get
+ ? !stop && (!get || search.canGetModelForUse(selected))
? _open
: () => unawaited(
_run(() async {
@@ -1032,10 +1035,18 @@ class _SwarmResourcePreviewState extends State<SwarmResourcePreview> {
Widget _modelPreview() {
final catalog = widget.search.models!;
if (widget.search.isModelDownloadsRow(row)) {
- return _details([
- 'Get models',
- 'Browse models available to download on your machines.',
- ], controls: true);
+ return _details(
+ widget.search.modelDownloadsVisible
+ ? [
+ 'Show fewer',
+ 'Keep only the catalog\'s top ${SwarmSearchController.shownDownloads} in the list.',
+ ]
+ : [
+ 'More models',
+ 'The rest of the models the grid catalog ranks for this machine, best first.',
+ ],
+ controls: true,
+ );
}
final entry = model;
if (entry == null) {
@@ -1056,11 +1067,6 @@ class _SwarmResourcePreviewState extends State<SwarmResourcePreview> {
// API entries have their own dedicated preview; keep main's dispatch.
if (entry.api != null) return _apiPreview(entry);
- String bytesLabel(double? bytes) {
- if (bytes == null) return '—';
- return '${(bytes / (1024 * 1024 * 1024)).toStringAsFixed(1)} GB';
- }
-
String windowLabel(double? seconds) {
if (seconds == null) return '—';
if (seconds > 0 && seconds % 86400 == 0) {
@@ -1072,6 +1078,27 @@ class _SwarmResourcePreviewState extends State<SwarmResourcePreview> {
return '${(seconds / 60).round()}m';
}
+ final inUse = widget.search.modelRowInUse(row!);
+ // The daemon refuses a download without its size and a gigabyte to spare; say so before Get.
+ final size = local?.sizeBytes, free = owner.freeDiskBytes;
+ final diskShort =
+ local != null &&
+ !local.downloaded &&
+ !pending &&
+ !opActive &&
+ size != null &&
+ free != null &&
+ size + _kGiB > free;
+ // "this Mac" in a sentence, "This Mac" as a value; another machine by its name.
+ final machineName =
+ identical(owner, catalog.manager) &&
+ (owner.machine?.isLocalMachine ?? true)
+ ? thisComputerName()
+ : entry.node ?? 'its machine';
+ final machineTitle = machineName == thisComputerName()
+ ? '${machineName[0].toUpperCase()}${machineName.substring(1)}'
+ : machineName;
+
// The status word is the catalog's own [localStatus] so the pane and the
// list row can never disagree (both come from the same [_refresh] snapshot);
// no re-derivation from a possibly-stale operation on the pane side.
@@ -1079,20 +1106,6 @@ class _SwarmResourcePreviewState extends State<SwarmResourcePreview> {
? catalog.localStatus(local, controller: owner)
: entry.status;
- // Suitability against this machine's usable memory, per plan §5. Only local
- // models carry a "fits this machine" meaning; shared/api/subscription nodes
- // have no per-node memory here, so fit is left out for them.
- final memory = owner.memoryBytes;
- String? fitsLabel() {
- final size = local?.sizeBytes;
- if (memory == null || local == null || size == null) return null;
- if (size <= memory) {
- final gb = (memory / (1024 * 1024 * 1024)).toStringAsFixed(0);
- return '✓ fits $gb GB';
- }
- return 'needs ${(size / (1024 * 1024 * 1024)).toStringAsFixed(0)} GB';
- }
-
Widget labelValue(String label, String value) {
return Padding(
padding: EdgeInsets.only(bottom: cell.height * .6),
@@ -1138,24 +1151,53 @@ class _SwarmResourcePreviewState extends State<SwarmResourcePreview> {
.copyWith(fontWeight: FontWeight.bold),
),
SizedBox(height: cell.height),
- Text(statusWord, style: terminalContentStyle(color: theme.foreground)),
+ Text(
+ inUse ? '$statusWord · this harness is on it' : statusWord,
+ style: terminalContentStyle(color: theme.foreground),
+ ),
if (widget.search.modelUseErrorId == entry.id &&
widget.search.modelUseError != null)
errorLine(widget.search.modelUseError!),
SizedBox(height: cell.height),
- labelValue(
- 'Machine',
- entry.node ?? (entry.source == 'Local' ? 'This Mac' : entry.source),
- ),
if (local != null) ...[
- if (fitsLabel() case final fits?) labelValue('Fits', fits),
- labelValue('Size', bytesLabel(local.sizeBytes)),
- labelValue('Quant', local.quant ?? '—'),
+ // What decides between models: what it costs to get, whether it fits, how fast it answers.
+ if (local.sizeBytes case final size?)
+ labelValue(
+ local.downloaded ? 'Size' : 'Download',
+ [
+ gigabytesLabel(size),
+ if (!local.downloaded && owner.freeDiskBytes != null)
+ '${gigabytesLabel(owner.freeDiskBytes!)} free',
+ ].join(' · '),
+ ),
+ if ((local.sizeBytes, owner.memoryBytes) case (
+ final size?,
+ final memory?,
+ ))
+ labelValue(
+ 'Memory',
+ '${size <= memory ? 'fits' : 'needs ${gigabytesLabel(size)}'} · '
+ '$machineName has ${gigabytesLabel(memory)}',
+ ),
if (local.running && local.tokensPerSecond != null)
labelValue(
'Speed',
'${local.tokensPerSecond!.toStringAsFixed(1)} tok/s',
+ )
+ else if (local.estTokS case final estimate?)
+ labelValue(
+ 'Speed',
+ '~${estimate.round()} tok/s on $machineName (estimate)',
+ ),
+ if (local.contextWindow case final window?)
+ labelValue('Context', contextWindowLabel(window.toInt())),
+ if (local.paramsB case final params?)
+ labelValue(
+ 'Params',
+ '${params == params.roundToDouble() ? params.toInt() : params}B',
),
+ labelValue('Quant', local.quantization ?? '—'),
+ labelValue('Machine', machineTitle),
if (local.running &&
local.requests != null &&
local.windowSeconds != null)
@@ -1165,7 +1207,9 @@ class _SwarmResourcePreviewState extends State<SwarmResourcePreview> {
),
if (local.resting)
labelValue('State', 'Resting until your next message'),
- if (!local.downloaded &&
+ if (diskShort)
+ errorLine('Free up disk space on $machineName to get it.')
+ else if (!local.downloaded &&
!owner.supportsDownload &&
local.canStart &&
!pending &&
@@ -1173,19 +1217,28 @@ class _SwarmResourcePreviewState extends State<SwarmResourcePreview> {
errorLine(
'Downloads and starts on ${entry.node ?? 'this machine'}.',
),
+ if (_enterSentence(local) case final sentence?) ...[
+ SizedBox(height: cell.height * .4),
+ Text(
+ sentence,
+ style: terminalContentStyle(color: theme.foreground),
+ ),
+ ],
+ ] else ...[
+ labelValue(
+ 'Machine',
+ entry.node ??
+ (entry.source == 'Local' ? machineTitle : entry.source),
+ ),
+ if (entry.subscription case final subscription?) ...[
+ ...((subscription['details'] as List?) ?? const [])
+ .map((d) => '$d')
+ .where((d) => d != entry.status)
+ .take(3)
+ .map((d) => labelValue('Detail', d)),
+ ],
+ labelValue('Source', entry.source),
],
- if (entry.api case final api?) ...[
- labelValue('Host', api.baseUrl),
- labelValue('Key', api.keyEnv),
- ],
- if (entry.subscription case final subscription?) ...[
- ...((subscription['details'] as List?) ?? const [])
- .map((d) => '$d')
- .where((d) => d != entry.status)
- .take(3)
- .map((d) => labelValue('Detail', d)),
- ],
- labelValue('Source', entry.source),
if (widget.search.modelUseReason(row) case final reason?
when reason != 'No active harness' &&
reason != entry.status &&
@@ -1215,6 +1268,33 @@ class _SwarmResourcePreviewState extends State<SwarmResourcePreview> {
);
}
+ static const _kGiB = 1024 * 1024 * 1024;
+
+ /// What Enter does on a model of yours, in words, under its facts. Nothing when it does nothing.
+ String? _enterSentence(LocalModel local) {
+ final search = widget.search;
+ final selected = row;
+ if (selected == null || search.modelRowInUse(selected)) return null;
+ // One local model runs at a time: a second one waits for the first to stop.
+ final other = search.otherRunningModel(selected)?.name;
+ if (search.canGetModelForUse(selected)) {
+ return 'Get downloads it, starts it, and moves this harness onto it.';
+ }
+ if (search.canGetModel(selected)) {
+ return other == null
+ ? 'Get downloads it.'
+ : 'Get downloads it. Stop $other to run it: one local model runs at a time.';
+ }
+ if (search.canSelectModel(selected)) {
+ return local.running
+ ? 'Use moves this harness onto it.'
+ : other == null
+ ? 'Use starts it and moves this harness onto it.'
+ : 'Stop $other first: one local model runs at a time.';
+ }
+ return null;
+ }
+
static const _kDetailLabelColumns = 9;
/// A saved API, or one of its models: a summary line, then labelled facts, then what it is for.
diff --git a/desktop/lib/widgets/swarm_switcher.dart b/desktop/lib/widgets/swarm_switcher.dart
index b6e5951f5..944c5ce22 100644
--- a/desktop/lib/widgets/swarm_switcher.dart
+++ b/desktop/lib/widgets/swarm_switcher.dart
@@ -500,18 +500,32 @@ class _SwarmSearchResultsState extends State<SwarmSearchResults> {
(Size, double)? _geometry;
SwarmSearchController get search => widget.search;
- List<({int? index, String? heading})> get _modelRows {
+ /// The model list as drawn: each section's heading, then its rows. [key] is the section's own
+ /// label, which stays put while a heading such as `Get for this Mac · 64 GB` follows its machine.
+ List<({int? index, String? heading, String? key})> get _modelRows {
if (!search.isModelMode) return const [];
- final items = <({int? index, String? heading})>[];
+ final items = <({int? index, String? heading, String? key})>[];
for (final section in ModelSearchSection.values) {
final indices = [
for (final (index, row) in search.rows.indexed)
if (search.modelSection(row) == section) index,
];
- if (indices.isEmpty && search.matchQuery.trim().isNotEmpty) continue;
- if (items.isNotEmpty) items.add((index: null, heading: null));
- items.add((index: null, heading: section.label));
- items.addAll(indices.map((index) => (index: index, heading: null)));
+ // An empty section still says it is there, so there is somewhere to add to — except the
+ // downloads, which a machine with the whole catalog, or none, has nothing under.
+ if (indices.isEmpty &&
+ (search.matchQuery.trim().isNotEmpty ||
+ section == ModelSearchSection.catalog)) {
+ continue;
+ }
+ if (items.isNotEmpty) items.add((index: null, heading: null, key: null));
+ items.add((
+ index: null,
+ heading: search.modelSectionLabel(section),
+ key: section.label,
+ ));
+ items.addAll(
+ indices.map((index) => (index: index, heading: null, key: null)),
+ );
}
return items;
}
@@ -1058,9 +1072,7 @@ class _SwarmSearchResultsState extends State<SwarmSearchResults> {
return Semantics(
header: true,
child: Padding(
- key: ValueKey(
- 'model-section:${item.heading}',
- ),
+ key: ValueKey('model-section:${item.key}'),
padding: EdgeInsets.symmetric(
horizontal: widget.bios
? cell.width * 3
@@ -1270,6 +1282,45 @@ class _SearchRowContent extends StatefulWidget {
}
class _SearchRowContentState extends State<_SearchRowContent> {
+ /// The widest word a model row of yours ends with (`Downloading`): the column is that wide, so
+ /// the size and speed columns ahead of it line up whatever each row says.
+ static const _modelWordColumns = 11;
+
+ /// A model row's last word. It is green only while something is live — running, in use, a
+ /// download under way; an action (Use, Get) is plain; a failure is a warning; a state is muted.
+ /// [row]'s size and speed columns, when a row [width] wide keeps room for the model's name.
+ String? _modelFacts(SwarmDestination row, double width, Size cell) =>
+ width >= cell.width * 58 ? widget.search.modelRowFacts(row) : null;
+
+ Widget _modelRowWord(
+ SwarmDestination row,
+ String status, {
+ required bool aligned,
+ required Color foreground,
+ required Color warning,
+ required Color muted,
+ required Size cell,
+ }) {
+ final search = widget.search;
+ final color = search.modelRowLive(row)
+ ? const Color(0xFF86E6A3)
+ : search.modelRowFailed(row)
+ ? warning
+ : status == search.modelRowAction(row)
+ ? foreground
+ : muted;
+ final text = Text(
+ status,
+ key: ValueKey('model-row-status:${row.id}'),
+ maxLines: 1,
+ textAlign: TextAlign.right,
+ style: terminalContentStyle(color: color),
+ );
+ return aligned
+ ? SizedBox(width: cell.width * _modelWordColumns, child: text)
+ : text;
+ }
+
late (String, bool, SessionContentHit?) _query;
/// What this row draws from the search: its words, and what a machine's
@@ -1440,22 +1491,36 @@ class _SearchRowContentState extends State<_SearchRowContent> {
maxLines: 1,
style: terminalContentStyle(color: muted),
),
- ] else if (widget.search.modelRowStatus(row)
- case final status?) ...[
- SizedBox(width: cell.width * 2),
- Text(
- status,
- key: ValueKey('model-row-status:${row.id}'),
- maxLines: 1,
- style: terminalContentStyle(
- color: underApi
- ? theme.foreground
- : widget.search.modelRowLive(row) ||
- status == 'Suggested'
- ? const Color(0xFF86E6A3)
- : muted,
+ ] else if (row.isModel) ...[
+ // A model of yours: its size and speed, in columns that line up down the list —
+ // when the list is wide enough to keep its name readable beside them.
+ if (_modelFacts(row, constraints.maxWidth, cell)
+ case final facts?) ...[
+ SizedBox(width: cell.width * 2),
+ Text(
+ facts,
+ key: ValueKey('model-row-facts:${row.id}'),
+ maxLines: 1,
+ style: terminalContentStyle(color: muted),
),
- ),
+ ],
+ if (widget.search.modelRowStatus(row)
+ case final status?) ...[
+ SizedBox(width: cell.width * 2),
+ _modelRowWord(
+ row,
+ status,
+ aligned:
+ _modelFacts(row, constraints.maxWidth, cell) !=
+ null,
+ foreground: theme.foreground,
+ warning: theme.yellow,
+ muted: muted,
+ cell: cell,
+ ),
+ ] else if (_modelFacts(row, constraints.maxWidth, cell) !=
+ null)
+ SizedBox(width: cell.width * (2 + _modelWordColumns)),
],
if (widget.unavailableReason case final reason?) ...[
SizedBox(width: cell.width * 2),
diff --git a/desktop/test/local_model_picker_test.dart b/desktop/test/local_model_picker_test.dart
new file mode 100644
index 000000000..55efa0a2b
--- /dev/null
+++ b/desktop/test/local_model_picker_test.dart
@@ -0,0 +1,467 @@
+// Your models and the downloads for this machine (Cmd-I / Cmd-P `:`): each row names its model alone,
+// lines up its size and speed, and ends with what Enter does — Use, Get — or what is happening to it.
+// The model the harness is on says In use. Get on a model the harness can run downloads it, starts
+// it and moves the harness onto it in one step; closing the picker stops only the switch.
+import 'package:flutter/material.dart';
+import 'package:flutter/services.dart';
+import 'package:flutter_test/flutter_test.dart';
+import 'package:harness/core/models.dart';
+import 'package:harness/models/model_search_catalog.dart';
+import 'package:harness/state/app_state.dart';
+import 'package:harness/state/swarm_navigation.dart';
+import 'package:harness/state/swarm_search.dart';
+import 'package:harness/widgets/swarm_resource_preview.dart';
+import 'package:harness/widgets/swarm_switcher.dart';
+import 'package:harness/ws/local_cli_discovery.dart';
+
+import 'keymap_host_test.dart' show MemoryKeymap, key;
+import 'keymap_runtime_test.dart' as configured;
+import 'resource_picker_test.dart' show fixture;
+import 'support/model_manager.dart';
+import 'support/real_fonts.dart';
+
+final field = find.byKey(const ValueKey('swarm-search-input'));
+SwarmSearchController search(WidgetTester tester) =>
+ tester.widget<SwarmSearchResults>(find.byType(SwarmSearchResults)).search;
+
+const _gib = 1024 * 1024 * 1024;
+const _live = Color(0xFF86E6A3);
+
+/// This Mac as the daemon would describe it: a model running, one downloaded, two versions of one
+/// more, and two of the catalog's picks for it.
+Map<String, dynamic> _inventory({bool running = true}) => {
+ 'memoryBytes': 64 * _gib,
+ 'freeDiskBytes': 114 * _gib,
+ 'supportsDownload': true,
+ 'busy': false,
+ 'models': [
+ {
+ 'id': 'local:Qwen3.6-35B-A3B-UD-Q5_K_XL.gguf',
+ 'name': 'Qwen3.6-35B-A3B',
+ 'state': running ? 'running' : 'downloaded',
+ 'sizeBytes': 27159116064,
+ 'canStart': !running,
+ 'canStop': running,
+ if (running) 'tokensPerSecond': 21.3,
+ },
+ {
+ 'id': 'gemma',
+ 'name': 'gemma-4-12B',
+ 'state': 'downloaded',
+ 'sizeBytes': 7.3 * _gib,
+ 'canStart': true,
+ },
+ {
+ 'id': 'local:Small-Q4_0.gguf',
+ 'name': 'Small',
+ 'state': 'downloaded',
+ 'sizeBytes': 2 * _gib,
+ 'canStart': true,
+ },
+ {
+ 'id': 'local:Small-Q8_0.gguf',
+ 'name': 'Small',
+ 'state': 'downloaded',
+ 'sizeBytes': 4 * _gib,
+ 'canStart': true,
+ },
+ {
+ 'id': 'unsloth/Qwen3.5-9B-GGUF',
+ 'name': 'Qwen3.5-9B',
+ 'state': 'available',
+ 'quant': 'Q4_K_XL',
+ 'sizeBytes': 5.6 * _gib,
+ 'canStart': true,
+ 'recommended': true,
+ 'contextWindow': 262144,
+ 'estTokS': 10.2,
+ 'paramsB': 9,
+ },
+ {
+ 'id': 'unsloth/Qwen3.5-4B-GGUF',
+ 'name': 'Qwen3.5-4B',
+ 'state': 'available',
+ 'quant': 'Q4_K_XL',
+ 'sizeBytes': 2.7 * _gib,
+ 'canStart': true,
+ 'contextWindow': 262144,
+ 'estTokS': 14.5,
+ },
+ ],
+};
+
+class _LocalApp extends ModelManagerTestApp {
+ _LocalApp() : super(ModelManagerConnection());
+
+ /// Downloads and starts finish at once, as a fast machine's would; left false, they stay under way.
+ bool completeDownloads = false, completeStarts = false;
+ final selections = <({String agent, String model})>[];
+
+ Map<String, dynamic> _with(
+ String modelId,
+ Map<String, dynamic> Function(Map<String, dynamic>) change,
+ ) {
+ final original = inventoryFor('m');
+ return {
+ ...original,
+ 'busy': false,
+ 'models': [
+ for (final raw in original['models'] as List)
+ if (raw['id'] == modelId)
+ change(raw as Map<String, dynamic>)
+ else
+ raw,
+ ],
+ };
+ }
+
+ @override
+ Future<Map<String, dynamic>> downloadLocalModel(
+ String machineId,
+ String modelId,
+ ) async {
+ final answer = await super.downloadLocalModel(machineId, modelId);
+ if (!completeDownloads) return answer;
+ setInventoryFor(
+ machineId,
+ _with(
+ modelId,
+ (model) => {...model, 'state': 'downloaded', 'operation': null},
+ ),
+ );
+ return {
+ 'operation': {...answer['operation'] as Map, 'phase': 'done'},
+ };
+ }
+
+ @override
+ Future<Map<String, dynamic>> controlLocalModel(
+ String machineId,
+ String modelId, {
+ required bool start,
+ }) async {
+ final answer = await super.controlLocalModel(
+ machineId,
+ modelId,
+ start: start,
+ );
+ if (!start || !completeStarts) return answer;
+ late String name;
+ setInventoryFor(
+ machineId,
+ _with(modelId, (model) {
+ name = model['name'] as String;
+ return {
+ ...model,
+ 'state': 'running',
+ 'canStart': false,
+ 'canStop': true,
+ 'operation': null,
+ };
+ }),
+ );
+ inventory = GridModels(
+ gridName: 'home',
+ models: [
+ ...inventory.models,
+ GridModel(id: name, node: 'This Mac'),
+ ],
+ );
+ return {
+ 'operation': {
+ ...answer['operation'] as Map<String, dynamic>,
+ 'stage': 'verifying',
+ 'phase': 'done',
+ },
+ };
+ }
+
+ @override
+ Future<void> retargetAgentToGridModel(
+ String machineId,
+ String agentId,
+ String modelId, {
+ String? gridName,
+ }) async {
+ selections.add((agent: agentId, model: modelId));
+ }
+}
+
+Future<_LocalApp> _localFixture({String? onModel, bool running = true}) async {
+ final app = _LocalApp()
+ ..inventory = const GridModels(
+ gridName: 'home',
+ models: [GridModel(id: 'Qwen3.6-35B-A3B', node: 'This Mac')],
+ );
+ await fixture(provided: app);
+ app.localInventory = _inventory(running: running);
+ final machine = app.machineStates['m']!
+ ..localEndpoint = LocalCliEndpoint(
+ computerId: 'fixture',
+ wsUri: Uri.parse('ws://fixture.invalid'),
+ protocolVersion: 1,
+ terminalProtocolVersion: 3,
+ )
+ ..connectionStatus = ConnectionStatus.connected
+ ..agentLoadStatus = AgentLoadStatus.loaded;
+ machine.agents.add(
+ Agent(
+ id: 'a69',
+ name: 'Current harness',
+ engine: 'claude',
+ terminalAvailable: true,
+ gridModel: onModel,
+ ),
+ );
+ await app.modelManager.refresh(force: true);
+ return app;
+}
+
+SwarmDestination _row(SwarmSearchController picker, String title) =>
+ picker.rows.singleWhere((row) => row.title == title);
+
+Finder _inPreview(String text) => find.descendant(
+ of: find.byType(SwarmResourcePreview),
+ matching: find.text(text),
+);
+
+String _status(WidgetTester tester, SwarmDestination row) => tester
+ .widget<Text>(find.byKey(ValueKey('model-row-status:${row.id}')))
+ .data!;
+
+Color? _statusColor(WidgetTester tester, SwarmDestination row) => tester
+ .widget<Text>(find.byKey(ValueKey('model-row-status:${row.id}')))
+ .style
+ ?.color;
+
+String _facts(WidgetTester tester, SwarmDestination row) => tester
+ .widget<Text>(find.byKey(ValueKey('model-row-facts:${row.id}')))
+ .data!;
+
+Future<SwarmSearchController> _open(WidgetTester tester, _LocalApp app) async {
+ await tester.binding.setSurfaceSize(const Size(1600, 1000));
+ addTearDown(() => tester.binding.setSurfaceSize(null));
+ await configured.mount(tester, app, MemoryKeymap());
+ await key(tester, LogicalKeyboardKey.keyI, cmd: true);
+ await tester.pumpAndSettle();
+ return search(tester);
+}
+
+void main() {
+ setUpAll(loadRealFonts);
+
+ testWidgets(
+ 'each model of yours ends with what Enter does, after its size and speed',
+ (tester) async {
+ final app = await _localFixture();
+ try {
+ final picker = await _open(tester, app);
+ // Named alone: the quantization is in the preview, unless two versions share a name.
+ final running = _row(picker, 'Qwen3.6-35B-A3B');
+ final downloaded = _row(picker, 'gemma-4-12B');
+ final download = _row(picker, 'Qwen3.5-9B');
+ expect(_row(picker, 'Small · Q4_0'), isNotNull);
+ expect(_row(picker, 'Small · Q8_0'), isNotNull);
+
+ expect(picker.modelSection(running), ModelSearchSection.local);
+ expect(picker.modelSection(downloaded), ModelSearchSection.local);
+ expect(picker.modelSection(download), ModelSearchSection.catalog);
+ expect(
+ find.text('Get for ${thisComputerName()} · 64 GB'),
+ findsOneWidget,
+ );
+ expect(find.text('Your models'), findsOneWidget);
+ // Two downloads fit in the list whole: nothing is folded behind "More models".
+ expect(picker.rows.where(picker.isModelDownloadsRow), isEmpty);
+
+ // Running: Use, green because it is live. Downloaded: Use, plain. A download: Get, plain.
+ expect(_status(tester, running), 'Use');
+ expect(_statusColor(tester, running), _live);
+ expect(_status(tester, downloaded), 'Use');
+ expect(_statusColor(tester, downloaded), isNot(_live));
+ expect(_status(tester, download), 'Get');
+ expect(_statusColor(tester, download), isNot(_live));
+ expect(
+ _statusColor(tester, download),
+ _statusColor(tester, downloaded),
+ );
+
+ // Size, then speed — measured while it runs, else the catalog's estimate for this machine.
+ expect(_facts(tester, running), ' 25 GB 21 tok/s');
+ expect(_facts(tester, download), '5.6 GB ~10 tok/s');
+ expect(_facts(tester, downloaded), '7.3 GB ');
+ // Every row's columns line up: the size, the speed and the word start where the next row's do.
+ final rightEdges = {
+ for (final row in [running, downloaded, download])
+ tester
+ .getTopRight(find.byKey(ValueKey('model-row-status:${row.id}')))
+ .dx,
+ };
+ expect(rightEdges, hasLength(1));
+ final factEdges = {
+ for (final row in [running, downloaded, download])
+ tester
+ .getTopLeft(find.byKey(ValueKey('model-row-facts:${row.id}')))
+ .dx,
+ };
+ expect(factEdges, hasLength(1));
+ expect(find.text('Suggested'), findsNothing);
+ } finally {
+ await tester.pumpWidget(const SizedBox());
+ app.dispose();
+ }
+ },
+ );
+
+ testWidgets(
+ 'the model the harness is on says In use, here and in its preview',
+ (tester) async {
+ final app = await _localFixture(onModel: 'Qwen3.6-35B-A3B');
+ try {
+ final picker = await _open(tester, app);
+ final running = _row(picker, 'Qwen3.6-35B-A3B');
+ expect(_status(tester, running), SwarmSearchController.inUseWord);
+ expect(_statusColor(tester, running), _live);
+ // Cmd-I opens on the model the harness is on.
+ expect(picker.selected!.id, running.id);
+ expect(_inPreview('Running · this harness is on it'), findsOneWidget);
+ // Nothing to do on it, so no sentence about what Enter does.
+ expect(find.textContaining('moves this harness onto it'), findsNothing);
+ // Another model is not in use.
+ expect(_status(tester, _row(picker, 'gemma-4-12B')), 'Use');
+ } finally {
+ await tester.pumpWidget(const SizedBox());
+ app.dispose();
+ }
+ },
+ );
+
+ testWidgets(
+ "a download's preview says what it costs, whether it fits, and what Get does",
+ (tester) async {
+ final app = await _localFixture();
+ try {
+ final picker = await _open(tester, app);
+ final download = _row(picker, 'Qwen3.5-9B');
+ picker.move(picker.rows.indexOf(download) - picker.cursor);
+ await tester.pump();
+ final here = thisComputerName();
+ expect(_inPreview('Not downloaded'), findsOneWidget);
+ expect(_inPreview('Download'), findsOneWidget);
+ expect(_inPreview('5.6 GB · 114 GB free'), findsOneWidget);
+ expect(_inPreview('fits · $here has 64 GB'), findsOneWidget);
+ expect(_inPreview('~10 tok/s on $here (estimate)'), findsOneWidget);
+ expect(_inPreview('256K'), findsOneWidget);
+ expect(_inPreview('9B'), findsOneWidget);
+ expect(_inPreview('Q4_K_XL'), findsOneWidget);
+ // One local model runs at a time: with Qwen3.6 running, Get only downloads, and says why.
+ expect(picker.canGetModelForUse(download), isFalse);
+ expect(
+ _inPreview(
+ 'Get downloads it. Stop Qwen3.6-35B-A3B to run it: one local model runs at a time.',
+ ),
+ findsOneWidget,
+ );
+ // The old line that read like the model's own size, and the redundant source.
+ expect(find.textContaining('✓ fits'), findsNothing);
+ expect(_inPreview('Source'), findsNothing);
+
+ // Downloaded weights: a size, not a download, and Use starts them first.
+ picker.move(
+ picker.rows.indexOf(_row(picker, 'gemma-4-12B')) - picker.cursor,
+ );
+ await tester.pump();
+ expect(_inPreview('Size'), findsOneWidget);
+ expect(_inPreview('Download'), findsNothing);
+ expect(
+ _inPreview(
+ 'Stop Qwen3.6-35B-A3B first: one local model runs at a time.',
+ ),
+ findsOneWidget,
+ );
+ } finally {
+ await tester.pumpWidget(const SizedBox());
+ app.dispose();
+ }
+ },
+ );
+
+ testWidgets(
+ 'Get downloads the model, starts it and moves the harness onto it in one step',
+ (tester) async {
+ final app = await _localFixture(running: false)
+ ..completeDownloads = true
+ ..completeStarts = true;
+ try {
+ final picker = await _open(tester, app);
+ final download = _row(picker, 'Qwen3.5-9B');
+ picker.move(picker.rows.indexOf(download) - picker.cursor);
+ await tester.pump();
+ expect(picker.canGetModelForUse(picker.selected), isTrue);
+ expect(
+ _inPreview(
+ 'Get downloads it, starts it, and moves this harness onto it.',
+ ),
+ findsOneWidget,
+ );
+ await key(tester, LogicalKeyboardKey.enter);
+ await tester.pumpAndSettle();
+ expect(app.downloads, [
+ (machine: 'm', model: 'unsloth/Qwen3.5-9B-GGUF'),
+ ]);
+ expect(app.actions, [
+ (machine: 'm', model: 'unsloth/Qwen3.5-9B-GGUF', start: true),
+ ]);
+ expect(app.selections, [(agent: 'a69', model: 'Qwen3.5-9B')]);
+ expect(field, findsNothing);
+ } finally {
+ await tester.pumpWidget(const SizedBox());
+ app.dispose();
+ }
+ },
+ );
+
+ testWidgets(
+ 'closing the picker during the download stops the switch, not the download',
+ (tester) async {
+ final app = await _localFixture(running: false);
+ try {
+ final picker = await _open(tester, app);
+ picker.move(
+ picker.rows.indexOf(_row(picker, 'Qwen3.5-9B')) - picker.cursor,
+ );
+ await tester.pump();
+ await key(tester, LogicalKeyboardKey.enter);
+ await tester.pump();
+ expect(app.downloads, hasLength(1));
+ // The hint follows the download; the row says so too.
+ expect(picker.usingLabel, 'Downloading 42%…');
+ expect(find.textContaining('Downloading 42%…'), findsOneWidget);
+ expect(_status(tester, _row(picker, 'Qwen3.5-9B')), 'Downloading');
+ expect(_statusColor(tester, _row(picker, 'Qwen3.5-9B')), _live);
+ // A longer word does not push its row's columns out of line with a row that says Use.
+ double factsLeft(String title) => tester
+ .getTopLeft(
+ find.byKey(ValueKey('model-row-facts:${_row(picker, title).id}')),
+ )
+ .dx;
+ expect(factsLeft('Qwen3.5-9B'), factsLeft('gemma-4-12B'));
+ await key(tester, LogicalKeyboardKey.escape);
+ await tester.pump(const Duration(seconds: 5));
+ expect(field, findsNothing);
+ expect(app.actions, isEmpty);
+ expect(app.selections, isEmpty);
+ } finally {
+ await tester.pumpWidget(const SizedBox());
+ app.dispose();
+ }
+ },
+ );
+
+ test('sizes read as people say them', () {
+ expect(gigabytesLabel(2.7 * _gib), '2.7 GB');
+ expect(gigabytesLabel(9.94 * _gib), '9.9 GB');
+ expect(gigabytesLabel(9.96 * _gib), '10 GB');
+ expect(gigabytesLabel(27159116064), '25 GB');
+ });
+}
diff --git a/desktop/test/model_search_catalog_test.dart b/desktop/test/model_search_catalog_test.dart
index 0f9a4b43f..d2da24ff7 100644
--- a/desktop/test/model_search_catalog_test.dart
+++ b/desktop/test/model_search_catalog_test.dart
@@ -73,103 +73,121 @@ void main() {
app.dispose();
});
- test(
- 'four sections separate installed and shared models from downloads',
- () async {
- final usage = _WithSubscriptions();
- final grouped = ModelSearchCatalog(
- app.modelManager,
- usage,
- pollHosts: false,
+ test('sections separate your models from downloads, and fold the catalog past five', () async {
+ final usage = _WithSubscriptions();
+ final grouped = ModelSearchCatalog(
+ app.modelManager,
+ usage,
+ pollHosts: false,
+ );
+ final search = SwarmSearchController(
+ app,
+ const [],
+ models: grouped,
+ offersCreate: true,
+ adding: true,
+ )..setQuery(':');
+ try {
+ app.localInventory = {
+ 'memoryBytes': 64 * 1024 * 1024 * 1024,
+ 'models': [
+ for (final letter in ['A', 'B', 'C', 'D', 'E', 'F', 'G'])
+ {'id': 'catalog-$letter', 'name': '${letter * 3} catalog'},
+ {
+ 'id': 'installed',
+ 'name': 'ZZZ installed',
+ 'state': 'downloaded',
+ 'canStart': true,
+ },
+ ],
+ };
+ app.inventory = const GridModels(
+ gridName: 'home',
+ models: [],
+ grids: [
+ GridSection(
+ name: 'Team',
+ own: false,
+ models: [GridModel(id: 'Shared Qwen', node: 'team.lan')],
+ ),
+ ],
);
- final search = SwarmSearchController(
- app,
- const [],
- models: grouped,
- offersCreate: true,
- adding: true,
- )..setQuery(':');
- try {
- app.localInventory = {
- 'models': [
- {'id': 'available', 'name': 'AAA catalog'},
- {
- 'id': 'installed',
- 'name': 'ZZZ installed',
- 'state': 'downloaded',
- 'canStart': true,
- },
- ],
- };
- app.inventory = const GridModels(
- gridName: 'home',
- models: [],
- grids: [
- GridSection(
- name: 'Team',
- own: false,
- models: [GridModel(id: 'Shared Qwen', node: 'team.lan')],
- ),
- ],
- );
- app.modelManager.apis.connections = [
- const ApiConnection({'id': 'custom', 'name': 'Custom API'}),
- ];
- await app.modelManager.refresh();
- expect(search.rows.map((row) => row.title), [
- 'OpenAI',
- 'Custom API',
- '[ Add ]',
- 'ZZZ installed',
- 'AAA catalog',
- '[ Get models ]',
- 'Shared Qwen · team.lan',
- ]);
- expect(search.rows.map(search.modelSection), [
- ModelSearchSection.subscriptions,
- ModelSearchSection.apis,
- ModelSearchSection.apis,
- ModelSearchSection.local,
- ModelSearchSection.local,
- ModelSearchSection.local,
- ModelSearchSection.shared,
- ]);
- search.move(
- search.rows.indexWhere(search.isModelDownloadsRow) - search.cursor,
- );
- expect(search.submit(), isNull);
- expect(search.modelDownloadsVisible, isTrue);
- expect(search.rows.map((row) => row.title), [
- 'OpenAI',
- 'Custom API',
- '[ Add ]',
+ app.modelManager.apis.connections = [
+ const ApiConnection({'id': 'custom', 'name': 'Custom API'}),
+ ];
+ await app.modelManager.refresh();
+ expect(search.rows.map((row) => row.title), [
+ 'OpenAI',
+ 'Custom API',
+ '[ Add ]',
+ 'ZZZ installed',
+ 'AAA catalog',
+ 'BBB catalog',
+ 'CCC catalog',
+ 'DDD catalog',
+ 'EEE catalog',
+ '[ More models (2) ]',
+ 'Shared Qwen · team.lan',
+ ]);
+ expect(search.rows.map(search.modelSection), [
+ ModelSearchSection.subscriptions,
+ ModelSearchSection.apis,
+ ModelSearchSection.apis,
+ ModelSearchSection.local,
+ for (var i = 0; i < 6; i++) ModelSearchSection.catalog,
+ ModelSearchSection.shared,
+ ]);
+ // The downloads are headed with the machine they are for, and its memory.
+ expect(grouped.catalogHeading, 'Get for ${thisComputerName()} · 64 GB');
+ expect(
+ search.modelSectionLabel(ModelSearchSection.catalog),
+ grouped.catalogHeading,
+ );
+ expect(search.modelSectionLabel(ModelSearchSection.local), 'Your models');
+ search.move(
+ search.rows.indexWhere(search.isModelDownloadsRow) - search.cursor,
+ );
+ expect(search.actionLabel(search.selected), 'More models');
+ expect(search.submit(), isNull);
+ expect(search.modelDownloadsVisible, isTrue);
+ expect(search.rows.map((row) => row.title), [
+ 'OpenAI',
+ 'Custom API',
+ '[ Add ]',
+ 'ZZZ installed',
+ for (final letter in ['A', 'B', 'C', 'D', 'E', 'F', 'G'])
+ '${letter * 3} catalog',
+ '[ Show fewer ]',
+ 'Shared Qwen · team.lan',
+ ]);
+ expect(search.selected!.title, 'AAA catalog');
+ expect(search.modelRowAction(search.selected!), isNull);
+ search.move(
+ search.rows.indexWhere(search.isModelDownloadsRow) - search.cursor,
+ );
+ expect(search.actionLabel(search.selected), 'Show fewer');
+ search.submit();
+ expect(search.modelDownloadsVisible, isFalse);
+ // The top five stay listed with the rest folded away again.
+ expect(search.rows.any((row) => row.title == 'EEE catalog'), isTrue);
+ expect(search.rows.any((row) => row.title == 'FFF catalog'), isFalse);
+ // A search reaches every catalog model, folded or not.
+ search.setQuery(':local');
+ expect(
+ search.rows.where((row) => !row.isCreate).map((row) => row.title),
+ [
'ZZZ installed',
- 'AAA catalog',
- '[ Hide catalog ]',
- 'Shared Qwen · team.lan',
- ]);
- expect(search.selected!.title, 'AAA catalog');
- expect(search.modelRowAction(search.selected!), isNull);
- search.move(
- search.rows.indexWhere(search.isModelDownloadsRow) - search.cursor,
- );
- search.submit();
- expect(search.modelDownloadsVisible, isFalse);
- // The top-5 catalog model stays visible even after hiding the catalog.
- expect(search.rows.any((row) => row.title == 'AAA catalog'), isTrue);
- search.setQuery(':Local AI');
- expect(
- search.rows.where((row) => !row.isCreate).map((row) => row.title),
- ['ZZZ installed', 'AAA catalog'],
- );
- expect(app.actions, isEmpty);
- } finally {
- search.dispose();
- grouped.dispose();
- usage.dispose();
- }
- },
- );
+ for (final letter in ['A', 'B', 'C', 'D', 'E', 'F', 'G'])
+ '${letter * 3} catalog',
+ ],
+ );
+ expect(app.actions, isEmpty);
+ } finally {
+ search.dispose();
+ grouped.dispose();
+ usage.dispose();
+ }
+ });
test(
'own models precede shared models even without local inventory',
diff --git a/desktop/test/resource_picker_test.dart b/desktop/test/resource_picker_test.dart
index 456a535a6..650dbd45f 100644
--- a/desktop/test/resource_picker_test.dart
+++ b/desktop/test/resource_picker_test.dart
@@ -13,6 +13,8 @@ import 'package:harness/core/dsh_catalog.dart';
import 'package:harness/auth/cli_link.dart';
import 'package:harness/core/models.dart';
import 'package:harness/models/api_connections_controller.dart';
+import 'package:harness/models/model_search_catalog.dart'
+ show ModelSearchSection;
import 'package:harness/widgets/api_picker_form.dart';
import 'package:harness/shared/theme/app_theme.dart' as grid;
import 'package:harness/shared/theme/color_palette.dart';
@@ -756,7 +758,8 @@ void main() {
for (final heading in [
'Subscriptions',
'APIs',
- 'Your local AI models',
+ 'Your models',
+ 'Get models',
'Shared with you',
]) {
expect(
@@ -764,27 +767,31 @@ void main() {
findsOneWidget,
);
}
- final browse = search(tester).rows
- .indexWhere(search(tester).isModelDownloadsRow);
- search(tester).move(browse - search(tester).cursor);
- await tester.pump();
- await key(tester, LogicalKeyboardKey.enter);
- expect(search(tester).modelDownloadsVisible, isTrue);
+ // Four catalog models all fit in the list, so nothing is folded behind "More models".
expect(
- search(tester)
- .models!
- .entries[search(tester).selected!.modelId]!
- .needsDownload,
- isTrue,
+ search(tester).rows.where(search(tester).isModelDownloadsRow),
+ isEmpty,
);
+ final download = search(tester).rows.firstWhere(
+ (row) =>
+ search(tester).models!.entries[row.modelId]?.needsDownload ==
+ true,
+ );
+ expect(
+ search(tester).modelSection(download),
+ ModelSearchSection.catalog,
+ );
+ search(
+ tester,
+ ).move(search(tester).rows.indexOf(download) - search(tester).cursor);
+ await tester.pump();
expect(search(tester).modelRowAction(search(tester).selected!), 'Get');
expect(app.actions, isEmpty);
expect(app.downloads, isEmpty);
await key(tester, LogicalKeyboardKey.escape);
await key(tester, LogicalKeyboardKey.keyI, cmd: true);
- expect(search(tester).modelDownloadsVisible, isFalse);
final usable = search(tester).rows
- .firstWhere((row) => row.title == 'qwen3.8-27b · Q4_0');
+ .firstWhere((row) => row.title == 'qwen3.8-27b');
search(tester)
.move(search(tester).rows.indexOf(usable) - search(tester).cursor);
await tester.pump();
@@ -805,7 +812,7 @@ void main() {
);
expect(find.text('Enter Use · Tab pane'), findsOneWidget);
expect(find.text('M2'), findsOneWidget);
- expect(find.text('15.0 GB'), findsOneWidget);
+ expect(find.text('15 GB'), findsOneWidget);
await capture(tester, 'remote-model-select');
final origin = search(tester);
await key(tester, LogicalKeyboardKey.tab);
@@ -844,7 +851,8 @@ void main() {
for (final heading in [
'Subscriptions',
'APIs',
- 'Your local AI models',
+ 'Your models',
+ 'Get models',
'Shared with you',
]) {
expect(
@@ -881,7 +889,7 @@ void main() {
);
app.notifyListeners();
await key(tester, LogicalKeyboardKey.keyI, cmd: true);
- expect(search(tester).selected!.title, 'qwen3.8-27b · Q4_0');
+ expect(search(tester).selected!.title, 'qwen3.8-27b');
await tester.enterText(field, ':Anthropic');
await tester.pumpAndSettle();
expect(search(tester).canSelectModel(search(tester).selected), isFalse);
diff --git a/desktop/test/resource_preview_actions_test.dart b/desktop/test/resource_preview_actions_test.dart
index 2eea1e7db..fcdfb5ff5 100644
--- a/desktop/test/resource_preview_actions_test.dart
+++ b/desktop/test/resource_preview_actions_test.dart
@@ -322,11 +322,11 @@ void main() {
await tester.pumpAndSettle();
expect(search.selected!.id, id);
expect(
- search.rows.where((row) => row.title == 'qwen3.8-27b · Q4_0'),
+ search.rows.where((row) => row.title == 'qwen3.8-27b'),
hasLength(1),
);
expect(find.text('M2'), findsOneWidget);
- expect(find.text('16.0 GB'), findsOneWidget);
+ expect(find.text('16 GB'), findsOneWidget);
expect(find.text('17.6 tok/s'), findsOneWidget);
expect(find.text('42 req / 1d'), findsOneWidget);
TerminalTextAction button(String action) => tester.widget(