From 1de15cba7e20d46f35ec5fef6163dc96d6d9132a Mon Sep 17 00:00:00 2001 From: Stan Grams Date: Thu, 26 Feb 2026 23:59:49 +0100 Subject: [PATCH] [feat](trx-server): auto-generate rig IDs from model name if not specified Allow rigs to have empty IDs in config; auto-generate from backend model name with numeric suffix (e.g., 'ft817_0', 'ft817_1', 'soapysdr_0'). This makes config more concise when using multiple instances of the same model without explicit ID assignment. Co-Authored-By: Claude Opus 4.6 --- src/trx-server/src/config.rs | 36 ++++++++++++++++++++++++++++++------ 1 file changed, 30 insertions(+), 6 deletions(-) diff --git a/src/trx-server/src/config.rs b/src/trx-server/src/config.rs index 3913152..a91746a 100644 --- a/src/trx-server/src/config.rs +++ b/src/trx-server/src/config.rs @@ -503,11 +503,11 @@ impl ServerConfig { let mut seen_ids: std::collections::HashSet = std::collections::HashSet::new(); let mut seen_ports: std::collections::HashSet = std::collections::HashSet::new(); for rig in &self.rigs { - if rig.id.trim().is_empty() { - return Err("[[rigs]] entry has an empty id".to_string()); - } - if !seen_ids.insert(rig.id.clone()) { - return Err(format!("[[rigs]] duplicate rig id: \"{}\"", rig.id)); + // Check for explicit duplicate IDs (empty IDs are auto-generated later). + if !rig.id.trim().is_empty() { + if !seen_ids.insert(rig.id.clone()) { + return Err(format!("[[rigs]] duplicate rig id: \"{}\"", rig.id)); + } } if rig.audio.enabled { if !seen_ports.insert(rig.audio.port) { @@ -626,7 +626,31 @@ impl ServerConfig { /// into a single `RigInstanceConfig` with `id = "default"`. pub fn resolved_rigs(&self) -> Vec { if !self.rigs.is_empty() { - return self.rigs.clone(); + // Auto-generate IDs for rigs that don't have explicit ones. + return self + .rigs + .iter() + .enumerate() + .map(|(idx, rig)| { + let id = if rig.id.trim().is_empty() { + // Generate ID from model name with counter. + let model = rig + .rig + .model + .as_deref() + .unwrap_or("unknown") + .to_lowercase(); + format!("{}_{}", model, idx) + } else { + rig.id.clone() + }; + + RigInstanceConfig { + id, + ..rig.clone() + } + }) + .collect(); } vec![RigInstanceConfig { id: "default".to_string(),