Skip to content

Commit 97b8b22

Browse files
fix(mesh): dedupe models + retry throttled startup channel discovery (#2063)
Co-authored-by: Michael Neale <[email protected]>
1 parent 0011843 commit 97b8b22

2 files changed

Lines changed: 42 additions & 1 deletion

File tree

‎desktop/src-tauri/src/mesh_llm/mod.rs‎

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -636,11 +636,24 @@ fn push_model(out: &mut Vec<MeshModelOption>, id: &str, name: Option<String>) {
636636
});
637637
}
638638

639+
/// Canonical model id for equality/dedup. A serving node advertises the same
640+
/// model under two strings — `org/model@main:Q4` (serveTargets[].modelId) and
641+
/// `org/model:Q4` (available_models) — so keying on the raw string leaves BOTH
642+
/// in the picker. Strip the `@main` ref-qualifier (matching the selection-time
643+
/// rule in `pick_serve_target_for_model`) so the two collapse to one entry.
644+
pub(super) fn canonical_model_id(value: &str) -> String {
645+
value.trim().replace("@main", "")
646+
}
647+
639648
pub(super) fn dedupe_models(models: Vec<MeshModelOption>) -> Vec<MeshModelOption> {
649+
// Key by canonical id so `@main` / non-`@main` forms of the same model
650+
// dedup together. Display the canonical (stripped) id so the UI shows one
651+
// stable label; selection still matches because the picker canonicalizes
652+
// both sides too.
640653
let mut by_id = BTreeMap::<String, Option<String>>::new();
641654
for model in models {
642655
by_id
643-
.entry(model.id)
656+
.entry(canonical_model_id(&model.id))
644657
.and_modify(|name| {
645658
if name.is_none() {
646659
*name = model.name.clone();

‎desktop/src-tauri/src/mesh_llm/mod_tests.rs‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,34 @@ fn sdk_ready_models_are_parsed_from_real_status_shape() {
5353
);
5454
}
5555

56+
#[test]
57+
fn dedupe_models_collapses_at_main_and_plain_forms() {
58+
// Regression: a serving node advertises the SAME model under two strings —
59+
// `org/model@main:Q4` (serveTargets[].modelId) and `org/model:Q4`
60+
// (available_models). Keying on the raw id left BOTH in the picker (the
61+
// "two model listing" bug). They must dedup to a single canonical entry.
62+
let models = vec![
63+
super::MeshModelOption {
64+
id: "unsloth/gemma-4-E4B-it-GGUF@main:Q4_K_M".to_string(),
65+
name: None,
66+
},
67+
super::MeshModelOption {
68+
id: "unsloth/gemma-4-E4B-it-GGUF:Q4_K_M".to_string(),
69+
name: Some("Gemma 4".to_string()),
70+
},
71+
];
72+
73+
let deduped = super::dedupe_models(models);
74+
assert_eq!(
75+
deduped,
76+
vec![super::MeshModelOption {
77+
id: "unsloth/gemma-4-E4B-it-GGUF:Q4_K_M".to_string(),
78+
name: Some("Gemma 4".to_string()),
79+
}],
80+
"@main and plain forms of the same model must collapse to one entry"
81+
);
82+
}
83+
5684
#[test]
5785
fn requested_model_is_not_ready_while_sdk_is_in_standby() {
5886
let payload = json!({

0 commit comments

Comments
 (0)