Skip to content

Commit 939bdb8

Browse files
committed
feat(commands): consolidate /model into /models and persist model selection
- Remove /model command, update /models to accept optional arg - /models [name] now either switches model or lists available models - Add 'm' alias to /models (was previously on /model) - Persist model selection to config when using /models <name> - Update all help text, tests, and mock content
1 parent d201070 commit 939bdb8

18 files changed

Lines changed: 50 additions & 67 deletions

File tree

src/cortex-engine/src/commands/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
//! - /compact - Compact conversation context
1414
//! - /undo - Undo last action
1515
//! - /config - Show/edit configuration
16-
//! - /model - Change model
16+
//! - /models - List or switch models
1717
//! - /cost - Show token usage and cost
1818
1919
mod configuration;

src/cortex-engine/src/commands/navigation.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ Navigation & Control:
3939
Information:
4040
/skills - List available skills
4141
/plugins - List installed plugins
42-
/model [name] - Show or change current model
42+
/models [name] - Show or change current model
4343
/cost - Show token usage and estimated cost
4444
/config - Show configuration
4545

src/cortex-tui-capture/src/screenshot_generator/mocks/input.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,7 @@ fn mock_input_command() -> String {
8787
│ > /mod_ │
8888
│ │
8989
│ ┌─ Commands ──────────────────────────────────────────────────────────┐ │
90-
│ │ > /model - Switch to a model │ │
91-
│ │ /models - List available models │ │
90+
│ │ > /models - List available models or switch to a model │ │
9291
│ └─────────────────────────────────────────────────────────────────────┘ │
9392
├─────────────────────────────────────────────────────────────────────────────┤
9493
│ Tab to complete · Enter to select │

src/cortex-tui-capture/src/screenshot_generator/mocks/widgets.rs

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,7 @@ fn mock_autocomplete_commands() -> String {
3838
╭─────────────────────────────────────────────────────────────────────────────╮
3939
│ ┌─ Commands ──────────────────────────────────────────────────────┐ │
4040
│ │ > /help - Show help information │ │
41-
│ │ /model - Switch to a model │ │
42-
│ │ /models - List available models │ │
41+
│ │ /models - List available models or switch to a model │ │
4342
│ │ /new - Start a new session │ │
4443
│ │ /clear - Clear current conversation │ │
4544
│ │ /session - Show current session info │ │
@@ -57,14 +56,13 @@ fn mock_autocomplete_filtered() -> String {
5756
r#"
5857
╭─────────────────────────────────────────────────────────────────────────────╮
5958
│ ┌─ Commands ──────────────────────────────────────────────────────┐ │
60-
│ │ > /model - Switch to a model │ │
61-
│ │ /models - List available models │ │
59+
│ │ > /models - List available models or switch to a model │ │
6260
│ └─────────────────────────────────────────────────────────────────┘ │
6361
├─────────────────────────────────────────────────────────────────────────────┤
6462
│ > /mod_ │
6563
╰─────────────────────────────────────────────────────────────────────────────╯
6664
67-
Filtering: "mod" matches 2 commands
65+
Filtering: "mod" matches 1 command
6866
"#
6967
.to_string()
7068
}
@@ -93,8 +91,7 @@ fn mock_autocomplete_scroll() -> String {
9391
╭─────────────────────────────────────────────────────────────────────────────╮
9492
│ ┌─ Commands ──────────────────────────────────────────────────────┐ │
9593
│ │ > /help - Show help information │█│ │
96-
│ │ /model - Switch to a model │ │ │
97-
│ │ /models - List available models │ │ │
94+
│ │ /models - List available models or switch to a model │ │ │
9895
│ │ /new - Start a new session │ │ │
9996
│ │ /clear - Clear current conversation │ │ │
10097
│ │ /session - Show current session info │ │ │
@@ -114,8 +111,7 @@ fn mock_autocomplete_selected() -> String {
114111
╭─────────────────────────────────────────────────────────────────────────────╮
115112
│ ┌─ Commands ──────────────────────────────────────────────────────┐ │
116113
│ │ /help - Show help information │ │
117-
│ │ /model - Switch to a model │ │
118-
│ │ █ /models - List available models [SELECTED] │ │
114+
│ │ █ /models - List available models or switch [SELECTED] │ │
119115
│ │ /new - Start a new session │ │
120116
│ │ /clear - Clear current conversation │ │
121117
│ └─────────────────────────────────────────────────────────────────┘ │
@@ -162,14 +158,14 @@ fn mock_command_palette() -> String {
162158
│ │ > _ │ │
163159
│ │ │ │
164160
│ │ Recent: │ │
165-
│ │ /model gpt-4 │ │
161+
│ │ /models gpt-4 │ │
166162
│ │ /clear │ │
167163
│ │ /help commands │ │
168164
│ │ │ │
169165
│ │ All Commands: │ │
170166
│ │ /help Show help │ │
171167
│ │ /new New session │ │
172-
│ │ /model Switch model │ │
168+
│ │ /models Switch model │ │
173169
│ │ /export Export session │ │
174170
│ │ ... │ │
175171
│ │ │ │

src/cortex-tui/src/cards/help.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ impl HelpCard {
120120
HelpSection::new(
121121
"Slash Commands",
122122
vec![
123-
HelpItem::new("/model", "Change AI model"),
123+
HelpItem::new("/models", "List or switch AI models"),
124124
HelpItem::new("/mcp", "Manage MCP servers"),
125125
HelpItem::new("/sessions", "View sessions"),
126126
HelpItem::new("/settings", "Open settings"),

src/cortex-tui/src/commands/executor/dispatch.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,7 @@ impl CommandExecutor {
8484
"context" | "ctx" => CommandResult::Async("context".to_string()),
8585

8686
// ============ MODEL ============
87-
"model" | "m" => self.cmd_model(cmd),
88-
"models" | "lm" | "list-models" => {
89-
CommandResult::Async("models:fetch-and-pick".to_string())
90-
}
87+
"models" | "m" | "lm" | "list-models" => self.cmd_models(cmd),
9188
"approval" | "approve" => self.cmd_approval(cmd),
9289
"sandbox" | "sb" => self.cmd_sandbox(cmd),
9390
"auto" | "autopilot" => self.cmd_auto(cmd),

src/cortex-tui/src/commands/executor/model.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ use super::CommandExecutor;
44
use crate::commands::types::{CommandResult, ModalType, ParsedCommand};
55

66
impl CommandExecutor {
7-
pub(super) fn cmd_model(&self, cmd: &ParsedCommand) -> CommandResult {
7+
pub(super) fn cmd_models(&self, cmd: &ParsedCommand) -> CommandResult {
88
match cmd.first_arg() {
99
Some(model) => CommandResult::SetValue("model".to_string(), model.to_string()),
10-
None => CommandResult::OpenModal(ModalType::ModelPicker),
10+
None => CommandResult::Async("models:fetch-and-pick".to_string()),
1111
}
1212
}
1313

@@ -61,7 +61,7 @@ impl CommandExecutor {
6161
CommandResult::Message(
6262
"Warning: The /provider command is deprecated.\n\n\
6363
Cortex is now a unified platform - all model access goes through the Cortex backend.\n\
64-
Use /model to switch between available models instead."
64+
Use /models to switch between available models instead."
6565
.to_string(),
6666
)
6767
}

src/cortex-tui/src/commands/executor/tests.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,24 +76,24 @@ fn test_execute_str_invalid() {
7676
}
7777

7878
#[test]
79-
fn test_model_with_arg() {
79+
fn test_models_with_arg() {
8080
let executor = CommandExecutor::new();
81-
let result = executor.execute_str("/model gpt-4");
81+
let result = executor.execute_str("/models gpt-4");
8282
if let CommandResult::SetValue(key, value) = result {
8383
assert_eq!(key, "model");
8484
assert_eq!(value, "gpt-4");
8585
} else {
86-
panic!("Expected SetValue");
86+
panic!("Expected SetValue, got {:?}", result);
8787
}
8888
}
8989

9090
#[test]
91-
fn test_model_without_arg() {
91+
fn test_models_without_arg() {
9292
let executor = CommandExecutor::new();
93-
let result = executor.execute_str("/model");
93+
let result = executor.execute_str("/models");
9494
assert!(matches!(
9595
result,
96-
CommandResult::OpenModal(ModalType::ModelPicker)
96+
CommandResult::Async(ref s) if s == "models:fetch-and-pick"
9797
));
9898
}
9999

src/cortex-tui/src/commands/forms.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -245,9 +245,9 @@ impl FormRegistry {
245245
],
246246
)),
247247

248-
"model" => Some(FormState::new(
248+
"models" => Some(FormState::new(
249249
"Set Model",
250-
"model",
250+
"models",
251251
vec![
252252
FormField::text("model", "Model Name")
253253
.required()
@@ -434,7 +434,7 @@ impl FormRegistry {
434434
"sandbox",
435435
"auto",
436436
"provider",
437-
"model",
437+
"models",
438438
"theme",
439439
// MCP commands
440440
"mcp",
@@ -497,7 +497,7 @@ mod tests {
497497
assert!(registry.has_form("sandbox"));
498498
assert!(registry.has_form("auto"));
499499
assert!(registry.has_form("provider"));
500-
assert!(registry.has_form("model"));
500+
assert!(registry.has_form("models"));
501501
assert!(registry.has_form("theme"));
502502
}
503503

src/cortex-tui/src/commands/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
//!
1111
//! Commands are entered with a leading `/` character:
1212
//! - `/help` - Show help
13-
//! - `/model claude-sonnet-4-20250514` - Switch model
13+
//! - `/models claude-sonnet-4-20250514` - Switch model
1414
//! - `/search "hello world"` - Search with quoted argument
1515
//!
1616
//! # Example

0 commit comments

Comments
 (0)