From 726e1ff35cce6e7ac9c4b3aac86da595f1cc6bb7 Mon Sep 17 00:00:00 2001 From: Ahmed Ibrahim Date: Sun, 3 May 2026 03:25:31 +0300 Subject: [PATCH] codex: compact service tier command names --- .../tui/src/bottom_pane/slash_commands.rs | 43 ++++++++++++++++--- 1 file changed, 36 insertions(+), 7 deletions(-) diff --git a/codex-rs/tui/src/bottom_pane/slash_commands.rs b/codex-rs/tui/src/bottom_pane/slash_commands.rs index 8a62a8e31d..a7ca87631d 100644 --- a/codex-rs/tui/src/bottom_pane/slash_commands.rs +++ b/codex-rs/tui/src/bottom_pane/slash_commands.rs @@ -222,17 +222,10 @@ fn command_token_conflicts(candidate: &str, reserved_names: &HashSet) -> fn normalize_service_tier_command_token(name: &str) -> Option { let mut normalized = String::new(); - let mut pending_dash = false; for ch in name.chars() { if ch.is_ascii_alphanumeric() { - if pending_dash && !normalized.is_empty() { - normalized.push('-'); - } normalized.push(ch.to_ascii_lowercase()); - pending_dash = false; - } else if !normalized.is_empty() { - pending_dash = true; } } @@ -426,4 +419,40 @@ mod tests { ] ); } + + #[test] + fn service_tier_command_compacts_name_separators() { + let model = ModelPreset { + id: "test".to_string(), + model: "test".to_string(), + display_name: "Test".to_string(), + description: String::new(), + default_reasoning_effort: codex_protocol::openai_models::ReasoningEffort::Medium, + supported_reasoning_efforts: Vec::new(), + supports_personality: false, + service_tiers: vec![ModelServiceTier { + id: ServiceTier::from("priorityboost"), + name: "Priority Boost".to_string(), + description: "Priority tier".to_string(), + }], + is_default: false, + upgrade: None, + show_in_picker: true, + availability_nux: None, + supported_in_api: true, + input_modalities: Vec::new(), + }; + + let commands = service_tier_commands_for_model(&model); + + assert_eq!( + commands, + vec![ServiceTierCommand { + service_tier: ServiceTier::from("priorityboost"), + command: "priorityboost".to_string(), + name: "Priority Boost".to_string(), + description: "Priority tier".to_string(), + }] + ); + } }