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): a model reads the same everywhere; ^S on another computer's model says where to stop it

bitcoinbuilderc9f648437eb1
diff --git a/desktop/lib/models/local_model.dart b/desktop/lib/models/local_model.dart
index a4830fb51..ec8c023e7 100644
--- a/desktop/lib/models/local_model.dart
+++ b/desktop/lib/models/local_model.dart
@@ -1,3 +1,18 @@
+/// [name] without the quantization its file name ends in, which a row's Quant
+/// says: `Qwen3.8-27B-UD-Q4_K_M` is `Qwen3.8-27B`, `qwen3:4b-instruct-2507-q4_k_m`
+/// is `qwen3:4b-instruct-2507` — hn's `without_quant`, so a model reads the same
+/// in both, and the same on the machine running it as on one it is shared with.
+/// A name that is all quant stays.
+String withoutQuant(String name) {
+ final quant = RegExp(
+ r'[-_.](?:ud[-_])?(?:(?:iq|q|mxfp)\d[a-z0-9_]*|bf16|fp16|f16)$',
+ caseSensitive: false,
+ ).firstMatch(name);
+ return quant == null || quant.start == 0
+ ? name
+ : name.substring(0, quant.start);
+}
+
/// The local daemon reports lifecycle and measured telemetry. Unknown values
/// stay absent; a weights file's size is never relabelled as memory use.
class LocalModel {
@@ -69,13 +84,19 @@ class LocalModel {
).firstMatch(id)?.group(1)?.toUpperCase();
}
+ /// Its name as shown: without the quant its file name ends in ([withoutQuant]).
+ String get shownName => withoutQuant(name);
+
+ /// [shownName] with its quant beside it: what tells two downloads of one
+ /// model apart.
String get displayName {
+ final shown = shownName;
final variant = quantization;
- if (variant == null || variant.isEmpty) return name;
+ if (variant == null || variant.isEmpty) return shown;
final present = RegExp(
'(^|[^a-z0-9])${RegExp.escape(variant.toLowerCase())}([^a-z0-9]|\$)',
- ).hasMatch(name.toLowerCase());
- return present ? name : '$name · $variant';
+ ).hasMatch(shown.toLowerCase());
+ return present ? shown : '$shown · $variant';
}
factory LocalModel.fromJson(Map<String, dynamic> data) => LocalModel(
diff --git a/desktop/lib/models/model_search_catalog.dart b/desktop/lib/models/model_search_catalog.dart
index e63d7b7b2..2da4ac354 100644
--- a/desktop/lib/models/model_search_catalog.dart
+++ b/desktop/lib/models/model_search_catalog.dart
@@ -300,12 +300,13 @@ class ModelSearchCatalog extends ChangeNotifier {
discovered.add(
ModelSearchEntry(
id: id,
- name: model.id,
+ // Shown without its quant, as hn shows it; found, and switched onto, by its id.
+ name: withoutQuant(model.id),
source: section.own
? 'On your machines'
: 'Shared · ${section.name}',
node: owner?.machine?.machine.displayName ?? model.node,
- searchAliases: [model.node, if (section.own) 'local'],
+ searchAliases: [model.id, model.node, if (section.own) 'local'],
own: section.own,
controller: owner,
gridModel: gridModel,
@@ -357,11 +358,11 @@ class ModelSearchCatalog extends ChangeNotifier {
// 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()}';
+ final key = '${identityHashCode(owner)}:${model.shownName.toLowerCase()}';
named[key] = (named[key] ?? 0) + 1;
}
bool twin(ModelManagerController owner, LocalModel model) =>
- (named['${identityHashCode(owner)}:${model.name.toLowerCase()}'] ?? 0) >
+ (named['${identityHashCode(owner)}:${model.shownName.toLowerCase()}'] ?? 0) >
1;
final all = [
for (final (:owner, :model) in local)
@@ -374,7 +375,7 @@ class ModelSearchCatalog extends ChangeNotifier {
),
name: model.name.isEmpty || twin(owner, model)
? model.displayName
- : model.name,
+ : model.shownName,
source: 'Local',
node: owner.machine?.machine.displayName,
status: localStatus(model, controller: owner),
diff --git a/desktop/test/model_manager_controller_test.dart b/desktop/test/model_manager_controller_test.dart
index af84eac57..a6a73b27b 100644
--- a/desktop/test/model_manager_controller_test.dart
+++ b/desktop/test/model_manager_controller_test.dart
@@ -81,7 +81,8 @@ void main() {
name: 'Example-Q4_K_M',
quant: 'Q4_K_M',
).displayName,
- 'Example-Q4_K_M',
+ // Its file's quant comes off the name and is said once, as every other's is.
+ 'Example · Q4_K_M',
);
expect(
const LocalModel(id: 'a', name: 'Example', quant: '').displayName,
diff --git a/desktop/test/model_search_catalog_test.dart b/desktop/test/model_search_catalog_test.dart
index 1e38f4017..9c27b23aa 100644
--- a/desktop/test/model_search_catalog_test.dart
+++ b/desktop/test/model_search_catalog_test.dart
@@ -1,5 +1,6 @@
import 'package:flutter_test/flutter_test.dart';
import 'package:harness/core/models.dart';
+import 'package:harness/models/local_model.dart';
import 'package:harness/models/model_search_catalog.dart';
import 'package:harness/models/api_connections_controller.dart';
import 'package:harness/state/swarm_navigation.dart';
@@ -460,6 +461,54 @@ void main() {
},
);
+ test('a name is shown without the quant its file ends in, as hn shows it', () {
+ const cases = {
+ 'Qwen3.8-27B-UD-Q4_K_M': 'Qwen3.8-27B',
+ 'Qwen3-4B-Instruct-2507-Q4_K_M': 'Qwen3-4B-Instruct-2507',
+ 'qwen3:4b-instruct-2507-q4_k_m': 'qwen3:4b-instruct-2507',
+ 'Kev-0.8B-Q8_0': 'Kev-0.8B',
+ 'gpt-oss-20b-MXFP4': 'gpt-oss-20b',
+ 'Mistral-7B-v0.1.IQ4_XS': 'Mistral-7B-v0.1',
+ 'gemma-4-E4B-it-BF16': 'gemma-4-E4B-it',
+ 'Qwen3.6-35B-A3B-UD_Q5_K_XL': 'Qwen3.6-35B-A3B',
+ 'Qwen3.6-35B-A3B': 'Qwen3.6-35B-A3B',
+ 'llama3.2:3b': 'llama3.2:3b',
+ 'Qwen-Q3-Coder': 'Qwen-Q3-Coder',
+ 'Q4_K_M': 'Q4_K_M',
+ '-Q4': '-Q4',
+ 'Qwen/Qwen3.8-27B': 'Qwen/Qwen3.8-27B',
+ };
+ for (final MapEntry(:key, :value) in cases.entries) {
+ expect(withoutQuant(key), value, reason: key);
+ }
+ });
+
+ test(
+ 'a model shared from another machine reads as it does there, without its quant',
+ () async {
+ app.localInventory = {'models': <Object>[]};
+ app.inventory = const GridModels(
+ gridName: 'home',
+ models: [],
+ grids: [
+ GridSection(
+ name: 'scholes-f8d388e6',
+ own: false,
+ models: [GridModel(id: 'Qwen3.8-27B-UD-Q4_K_M', node: 'harness')],
+ ),
+ ],
+ );
+ await app.modelManager.refresh();
+ expect(catalog.rows.single.title, 'Qwen3.8-27B · harness');
+ final entry = catalog.entries.values.single;
+ expect(entry.gridModel?.id, 'Qwen3.8-27B-UD-Q4_K_M');
+ final search = SwarmSearchController(app, const [], models: catalog)
+ ..setQuery(':Q4_K_M');
+ addTearDown(search.dispose);
+ expect(search.rows.map((row) => row.title), ['Qwen3.8-27B · harness']);
+ },
+ );
+
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 55792940a..b1d42191b 100644
--- a/tui/src/models.rs
+++ b/tui/src/models.rs
@@ -1145,6 +1145,13 @@ pub fn plan_enter(app: &App, id: &str) -> Plan {
/// What ^S does on row [id]: stop a local model (asked first).
pub fn plan_stop(app: &App, id: &str) -> Plan {
+ // A model another computer runs (shared with you, or on your other machines) stops there: said, not
+ // silently ignored — two ^S on one once read as a stop that never reached the grid.
+ if let Some(rest) = id.strip_prefix("mv:grid:") {
+ let mut parts = rest.splitn(3, '\t');
+ let (_, node, model) = (parts.next(), parts.next().unwrap_or(""), parts.next().unwrap_or(""));
+ return Plan::Say(format!("{} runs on {node} — stop it there", without_quant(model)));
+ }
let Some(m) = id.strip_prefix("mv:local:").and_then(|model| local_model(app, model)) else { return Plan::Nothing };
let f = facts(app, &m, None);
if f.busy { return Plan::Say("Wait for the current model operation to finish.".into()) }
@@ -3642,6 +3649,20 @@ mod tests {
assert!(rows_of(&app).iter().any(|r| r.id == "mv:grid:own-grid\tstudio\tQwen3.8-27B-UD-Q4_K_M"));
}
+ #[test]
+ fn stop_on_a_model_another_computer_runs_says_where_to_stop_it() {
+ let mut app = loaded();
+ let mut g = grids_reply(&[]);
+ g["grids"][1]["models"][0]["id"] = json!("Qwen3.8-27B-UD-Q4_K_M");
+ on_grids(&mut app, "local", Ok(g));
+ let mut picker = Picker::new("Models", "");
+ let id = "mv:grid:team\tgpu-box\tQwen3.8-27B-UD-Q4_K_M";
+ assert!(matches!(plan_stop(&app, id), Plan::Say(ref w) if w == "Qwen3.8-27B runs on gpu-box — stop it there"));
+ choose(&mut app, &mut picker, id, true);
+ choose(&mut app, &mut picker, id, true);
+ assert!(app.models_view.sent.iter().all(|s| s.1 != "grid_fleet_model_stop"));
+ }
+
/// 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.