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.

fix(models): match a running model to the name grid serves it under

bitcoinbuilder73eed3438bef
diff --git a/cli/src/lib/localModels.spec.ts b/cli/src/lib/localModels.spec.ts
index 6546de008..d42960db5 100644
--- a/cli/src/lib/localModels.spec.ts
+++ b/cli/src/lib/localModels.spec.ts
@@ -150,11 +150,14 @@ describe('local model discovery and lifecycle', () => {
})
it('downloads, loads and verifies without another user step', async () => {
+ // Not running: nothing serves it, so no name a harness could be on.
+ expect((await service.list('home')).models[0]).not.toHaveProperty('servedAs')
const ack = await service.act('home', 'org/Small-GGUF', 'start')
expect(ack.operation?.phase).toBe('running')
await service.settled()
const snapshot = await service.list('home')
- expect(snapshot.models[0]).toMatchObject({ state: 'running', canStop: true,
+ // Shown as the catalog's `Small`, served under its file's name — the one the grid lists, and a harness on it says.
+ expect(snapshot.models[0]).toMatchObject({ name: 'Small', state: 'running', canStop: true, servedAs: ['Small-Q4'],
tokensPerSecond: 17.6, requests: 4, windowSeconds: 3600, operation: { phase: 'done', stage: 'verifying' } })
expect(snapshot.models[0]).not.toHaveProperty('memoryBytes')
expect(calls.find(args => args.includes('join'))).toEqual(['--remote', 'join', 'home', '--serve', 'Small-Q4.gguf', '--max-concurrency', '1', '--parallel', '1', '--ctx-size', '131072', '--endpoint-port', expect.stringMatching(/^\d+$/), '--reasoning-budget', '0'])
@@ -323,7 +326,7 @@ describe('local model discovery and lifecycle', () => {
engines: [{ endpoint_url: null, models: ['Small-Q4.gguf'] }], advertise_as: ['Small-Q4.gguf'] }))
await writeFile(join(records, 'remote.heartbeat'), '')
const first = await service.list('home')
- expect(first.models[0]).toMatchObject({ id: 'local:Small-Q4.gguf', state: 'running', canStop: true })
+ expect(first.models[0]).toMatchObject({ id: 'local:Small-Q4.gguf', state: 'running', canStop: true, servedAs: ['Small-Q4'] })
await service.act('home', first.models[0].id, 'stop'); await service.settled()
const fresh = modelFixture({ stateDir, processEnv: { GRID_HOME: home }, run, request: request as typeof fetch , inventory })
expect((await fresh.list('home')).models[0]).toMatchObject({ state: 'downloaded', canStart: true })
@@ -1904,7 +1907,7 @@ describe('models other apps downloaded, started in their own app', () => {
engine: 'ollama', served: ollama.ref, alias: ollama.name, port: 41000, binary: ollama.binary, pid: 4242 }]))
service = appService({ appEngines: undefined })
expect((await service.list('home')).models.find(model => model.id === ollama.id))
- .toMatchObject({ state: 'downloaded', canStart: false, canStop: true })
+ .toMatchObject({ state: 'downloaded', canStart: false, canStop: true, servedAs: [ollama.name] })
const result = await service.act('home', ollama.id, 'stop'); await service.settled()
expect(result.operation?.phase).toBe('done')
expect(calls).toContainEqual(['--remote', 'leave', 'home', '--engine', ollama.name])
diff --git a/cli/src/lib/localModels.ts b/cli/src/lib/localModels.ts
index 35dc48cde..3a96880fd 100644
--- a/cli/src/lib/localModels.ts
+++ b/cli/src/lib/localModels.ts
@@ -83,6 +83,11 @@ export interface LocalModel {
/** What it runs in: `Grid` for a model Grid's llama.cpp serves, or the app whose folder holds it
* (`Ollama`, `LM Studio`, `llama.cpp`, [AppModel]). Absent for a catalog model not downloaded yet. */
app?: string
+ /** The names the grid lists it under while its engine runs here — what a harness on it names as its
+ * model. A catalog model is served under its file (`Qwen3.8-27B-UD-Q4_K_M`), not its name
+ * (`Qwen3.8-27B`): matched by name alone, the apps listed it twice, the second time as the grid's,
+ * and could not move a harness onto it from its own row. */
+ servedAs?: string[]
}
export interface ModelOperation {
id: string; modelId: string; action: 'download' | 'start' | 'stop'; phase: 'running' | 'done' | 'failed'
@@ -764,6 +769,7 @@ 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,
+ ...(instance ? { servedAs: instance.aliases.map(displayModelName) } : {}),
...(candidate.context ? { contextWindow: candidate.context } : {}),
...(candidate.estTokS ? { estTokS: candidate.estTokS } : {}),
...(candidate.paramsB ? { paramsB: candidate.paramsB } : {}),
@@ -779,7 +785,7 @@ export class LocalModels {
})
for (const instance of owned.filter(o => !choices.some(c => c.file === o.file))) {
const serving = !!servingNode(instance)
- models.push({ id: `local:${instance.file}`, name: cleanName(instance.aliases[0]),
+ models.push({ id: `local:${instance.file}`, name: cleanName(instance.aliases[0]), servedAs: instance.aliases.map(displayModelName),
state: serving || parked(instance) ? 'running' : 'available', canStart: false, canStop: !inventoryError,
operation: operation?.modelId === `local:${instance.file}` ? operation : undefined,
...(!serving && parked(instance) ? { gridAsleep: true } : {}), app: GRID_LABEL })
@@ -792,7 +798,7 @@ export class LocalModels {
const alive = record && this.options.appEngines ? await this.options.appEngines.alive(record) : false
const listed = !!record && listedHere(record.alias)
const running = alive && (listed || asleep)
- return { id, name, app: APP_LABEL[app], state: running ? 'running' : 'downloaded', ...extra,
+ return { id, name, app: APP_LABEL[app], state: running ? 'running' : 'downloaded', ...extra, ...(record ? { servedAs: [record.alias] } : {}),
canStart: !inventoryError && !record, canStop: !inventoryError && !!record,
operation: operation?.modelId === id ? operation : undefined, ...(running && !listed ? { gridAsleep: true } : {}) }
}
diff --git a/desktop/lib/models/local_model.dart b/desktop/lib/models/local_model.dart
index 56ee2f92a..a4830fb51 100644
--- a/desktop/lib/models/local_model.dart
+++ b/desktop/lib/models/local_model.dart
@@ -19,9 +19,23 @@ class LocalModel {
this.estTokS,
this.paramsB,
this.app,
+ this.servedAs = const [],
});
final String id, name, state;
+ /// The names the grid lists this model under while it runs here (`servedAs`; empty from an older
+ /// daemon). A catalog model runs under its file's name (`Qwen3.8-27B-UD-Q4_K_M`), not the catalog's
+ /// (`Qwen3.8-27B`), so its grid listing is matched to it by these.
+ final List<String> servedAs;
+
+ /// Whether the grid's [modelId] is this model: its id, its name, or a name it is served under.
+ bool answersTo(String modelId) {
+ final id = modelId.toLowerCase();
+ return this.id.toLowerCase() == id ||
+ name.toLowerCase() == id ||
+ servedAs.any((served) => served.toLowerCase() == id);
+ }
+
/// The app this model was downloaded with and starts in (`Ollama`, `LM Studio`, `llama.cpp`): one found
/// in that app's folder. Null for Grid's own models, and from an older daemon.
final String? app;
@@ -85,6 +99,10 @@ class LocalModel {
final String app when app.trim().isNotEmpty => app.trim(),
_ => null,
},
+ servedAs: switch (data['servedAs']) {
+ final List<dynamic> names => names.whereType<String>().toList(),
+ _ => const [],
+ },
);
}
diff --git a/desktop/lib/models/model_search_catalog.dart b/desktop/lib/models/model_search_catalog.dart
index 1d8873f2f..e63d7b7b2 100644
--- a/desktop/lib/models/model_search_catalog.dart
+++ b/desktop/lib/models/model_search_catalog.dart
@@ -276,8 +276,7 @@ class ModelSearchCatalog extends ChangeNotifier {
.where(
(local) =>
(local.downloaded || local.canStop) &&
- (local.name.toLowerCase() == model.id.toLowerCase() ||
- local.id.toLowerCase() == model.id.toLowerCase()),
+ local.answersTo(model.id),
)
.toList() ??
const <LocalModel>[];
diff --git a/desktop/test/model_search_catalog_test.dart b/desktop/test/model_search_catalog_test.dart
index 294dd6098..1e38f4017 100644
--- a/desktop/test/model_search_catalog_test.dart
+++ b/desktop/test/model_search_catalog_test.dart
@@ -424,6 +424,42 @@ void main() {
},
);
+ test(
+ 'a catalog model running here is one row, matched to the name grid serves it under',
+ () async {
+ Map<String, Object?> running() => {
+ 'models': [
+ {
+ 'id': 'unsloth/Qwen3.8-27B-GGUF',
+ 'name': 'Qwen3.8-27B',
+ 'state': 'running',
+ 'canStop': true,
+ 'app': 'Grid',
+ 'servedAs': ['Qwen3.8-27B-UD-Q4_K_M'],
+ },
+ ],
+ };
+ app.localInventory = running();
+ app.inventory = const GridModels(
+ gridName: 'home',
+ models: [],
+ grids: [
+ GridSection(
+ name: 'home',
+ own: true,
+ models: [GridModel(id: 'Qwen3.8-27B-UD-Q4_K_M', node: 'This Mac')],
+ ),
+ ],
+ );
+ await app.modelManager.refresh();
+ final served = catalog.entries.values.where(
+ (entry) => entry.local?.id == 'unsloth/Qwen3.8-27B-GGUF',
+ );
+ expect(catalog.entries, hasLength(1));
+ expect(served.single.gridModel?.id, 'Qwen3.8-27B-UD-Q4_K_M');
+ },
+ );
+
test('legacy own-grid replies remain visible in models', () async {
app.localInventory = {'models': <Object>[]};
app.inventory = const GridModels(
diff --git a/tui/src/models.rs b/tui/src/models.rs
index 1f30303c7..55792940a 100644
--- a/tui/src/models.rs
+++ b/tui/src/models.rs
@@ -75,6 +75,8 @@ pub struct LocalModel {
/// The app it runs in: `Ollama`, `LM Studio` or `llama.cpp` for one that app downloaded, `Grid`
/// for Grid's own engine (absent from an older daemon).
pub app: Option<String>,
+ /// The names the grid lists it under while it runs here (`servedAs`; absent from an older daemon).
+ pub served_as: Vec<String>,
}
impl LocalModel {
@@ -85,10 +87,18 @@ impl LocalModel {
size: num(&v["sizeBytes"]), quant: text(&v["quant"]), recommended: v["recommended"] == true, can_start: v["canStart"] == true, can_stop: v["canStop"] == true,
tok_s: num(&v["tokensPerSecond"]), requests: num(&v["requests"]), window_secs: num(&v["windowSeconds"]),
context: num(&v["contextWindow"]), est_tok_s: num(&v["estTokS"]), params_b: num(&v["paramsB"]),
- operation: Operation::parse(&v["operation"]), asleep: v["gridAsleep"] == true, app: text(&v["app"]), id,
+ operation: Operation::parse(&v["operation"]), asleep: v["gridAsleep"] == true, app: text(&v["app"]),
+ served_as: v["servedAs"].as_array().map(|a| a.iter().filter_map(|s| s.as_str().map(str::to_string)).collect()).unwrap_or_default(), id,
})
}
pub fn running(&self) -> bool { self.state == "running" }
+ /// Whether [id] — a grid's model, a harness's — is this model: its id, its name, or a name the grid
+ /// serves it under. A catalog model runs under its file's name (`Qwen3.8-27B-UD-Q4_K_M`), not the
+ /// catalog's (`Qwen3.8-27B`): matched by name alone, it was listed twice in Your models and a
+ /// harness could not be moved onto it from its own row.
+ pub fn answers_to(&self, id: &str) -> bool {
+ self.id.eq_ignore_ascii_case(id) || self.name.eq_ignore_ascii_case(id) || self.served_as.iter().any(|s| s.eq_ignore_ascii_case(id))
+ }
/// Its name as shown: without the quantization a file name ends in, which the Quant line says.
/// [name] stays whole — it is what the grid serves it as, and what a harness is matched to it by.
pub fn shown(&self) -> String { without_quant(&self.name).to_string() }
@@ -576,7 +586,7 @@ fn up(app: &App, machine: &str) -> bool { app.fleet.machine(machine).is_some_and
/// The own grid's listing of [m] once it serves — (section, the grid's id for it).
fn served_in(grids: Option<&Grids>, m: &LocalModel) -> Option<(String, String)> {
grids?.sections.iter().filter(|s| s.own).find_map(|s| s.models.iter()
- .find(|x| x.offline.is_none() && (x.id.eq_ignore_ascii_case(&m.id) || x.id.eq_ignore_ascii_case(&m.name)))
+ .find(|x| x.offline.is_none() && m.answers_to(&x.id))
.map(|x| (s.name.clone(), x.id.clone())))
}
@@ -589,10 +599,9 @@ fn other_running(app: &App, m: &LocalModel) -> Option<LocalModel> {
/// until they move to another (the desktop's `_harnessesOn`).
fn harnesses_on(app: &App, m: &LocalModel, t: Option<&Target>) -> Vec<String> {
let served = served_in(app.models_view.grids.get(&app.fleet.local_id), m).map(|(_, id)| id);
- let names = [Some(&m.name), Some(&m.id), served.as_ref()];
let mut out: Vec<String> = app.fleet.agents.values()
.filter(|a| !t.is_some_and(|t| t.machine == a.machine_id && t.agent == a.id))
- .filter(|a| !a.grid_model.is_empty() && names.iter().flatten().any(|n| n.eq_ignore_ascii_case(&a.grid_model)))
+ .filter(|a| !a.grid_model.is_empty() && (m.answers_to(&a.grid_model) || served.as_ref().is_some_and(|s| s.eq_ignore_ascii_case(&a.grid_model))))
.map(|a| a.name.clone()).collect();
out.sort();
out
@@ -651,9 +660,9 @@ pub fn facts(app: &App, m: &LocalModel, t: Option<&Target>) -> Facts {
let runs = t.is_some_and(|t| can_run(app, &t.engine));
let served = served_in(v.grids.get(machine), m);
let in_use = t.is_some_and(|t| m.running() && !t.grid_model.is_empty()
- && (served.as_ref().is_some_and(|(_, id)| id.eq_ignore_ascii_case(&t.grid_model)) || m.id.eq_ignore_ascii_case(&t.grid_model) || m.name.eq_ignore_ascii_case(&t.grid_model)));
+ && (served.as_ref().is_some_and(|(_, id)| id.eq_ignore_ascii_case(&t.grid_model)) || m.answers_to(&t.grid_model)));
let get = !m.downloaded() && m.can_start && !busy && online;
- let names = |id: &str| m.id.eq_ignore_ascii_case(id) || m.name.eq_ignore_ascii_case(id) || served.as_ref().is_some_and(|(_, s)| s.eq_ignore_ascii_case(id));
+ let names = |id: &str| m.answers_to(id) || served.as_ref().is_some_and(|(_, s)| s.eq_ignore_ascii_case(id));
Facts {
switching: switching_for(app, t).is_some_and(|to| !to.is_empty() && names(to)),
failed: op.as_ref().is_some_and(Operation::failed),
@@ -929,7 +938,7 @@ pub fn rows(app: &App, query: &str) -> Vec<Row> {
// (This computer's running ones are listed by their local names, above.)
let here: Vec<&LocalModel> = s.models.iter().filter(|m| m.running()).collect();
let theirs: Vec<Row> = v.grids.get(&machine).map(own).unwrap_or_default().into_iter()
- .filter(|(_, x)| !here.iter().any(|m| x.id.eq_ignore_ascii_case(&m.id) || x.id.eq_ignore_ascii_case(&m.name)))
+ .filter(|(_, x)| !here.iter().any(|m| m.answers_to(&x.id)))
.map(|(s, x)| grid_row(app, &s, &x, t, YOUR_MODELS)).collect();
// (Only with something below to get: Enter goes to it.)
let to_get = s.models.iter().any(|m| !m.downloaded() && !m.can_stop);
@@ -3610,6 +3619,29 @@ mod tests {
}
}
+ /// The catalog's Qwen3.8-27B running here, which grid serves under its file's name: one row in Your
+ /// models (not a second, as the grid's), and Enter on it moves the harness onto what grid serves.
+ #[test]
+ fn a_catalog_model_running_here_is_one_row_and_switched_onto_by_the_name_grid_serves() {
+ let mut app = app();
+ let catalog = json!({ "id": "unsloth/Qwen3.8-27B-GGUF", "name": "Qwen3.8-27B", "state": "running", "quant": "UD-Q4_K_M", "sizeBytes": 15.3 * GIB,
+ "canStart": false, "canStop": true, "app": "Grid", "servedAs": ["Qwen3.8-27B-UD-Q4_K_M"] });
+ on_local(&mut app, "local", Ok(local_reply(catalog, false)));
+ on_grids(&mut app, "local", Ok(grids_reply(&["Qwen3.8-27B-UD-Q4_K_M"])));
+ let rows = rows_of(&app);
+ let mine: Vec<&str> = rows.iter().filter(|r| r.group.as_deref() == Some(YOUR_MODELS) && r.label == "Qwen3.8-27B").map(|r| r.id.as_str()).collect();
+ assert_eq!(mine, vec!["mv:local:unsloth/Qwen3.8-27B-GGUF"]);
+ match plan_enter(&app, "mv:local:unsloth/Qwen3.8-27B-GGUF") {
+ Plan::Retarget { payload, name, .. } => { assert_eq!(payload["gridModel"], "Qwen3.8-27B-UD-Q4_K_M"); assert_eq!(name, "Qwen3.8-27B") }
+ other => panic!("{other:?}"),
+ }
+ // An older daemon, which does not say: as before — the grid's row beside it.
+ let mut older = app.models_view.local.get("local").cloned().unwrap();
+ older.models.iter_mut().for_each(|m| m.served_as.clear());
+ app.models_view.local.insert("local".into(), older);
+ assert!(rows_of(&app).iter().any(|r| r.id == "mv:grid:own-grid\tstudio\tQwen3.8-27B-UD-Q4_K_M"));
+ }
+
/// A model a Grid setup left running, which the catalog does not list: grid serves it under its
/// file's name, quant and all. It is shown without the quant (the Quant line says it), and a
/// harness still moves onto it by the name grid serves.