Skip to content

Commit 9ad73d0

Browse files
authored
feat(commands): consolidate /model into /models and persist model selection (#24)
- 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 c398212 commit 9ad73d0

File tree

21 files changed

+62
-75
lines changed

21 files changed

+62
-75
lines changed

docs/user-guide.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ Within an interactive session, you can use slash commands:
111111
|---------|-------------|
112112
| `/help` | Show available commands |
113113
| `/clear` | Clear the conversation |
114-
| `/model <name>` | Switch AI model |
114+
| `/models <name>` | Switch AI model |
115115
| `/export` | Export the session |
116116
| `/quit` or `/exit` | Exit Cortex |
117117

@@ -182,7 +182,7 @@ cortex -m claude-3-opus
182182
cortex exec -m gpt-4-turbo "your prompt"
183183

184184
# During session (slash command)
185-
/model claude-3-sonnet
185+
/models claude-3-sonnet
186186
```
187187

188188
### Model Recommendations

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-engine/src/commands/types.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -326,8 +326,8 @@ mod tests {
326326
assert_eq!(inv.name, "help");
327327
assert!(inv.args.is_empty());
328328

329-
let inv = CommandInvocation::parse("/model gpt-4").unwrap();
330-
assert_eq!(inv.name, "model");
329+
let inv = CommandInvocation::parse("/models gpt-4").unwrap();
330+
assert_eq!(inv.name, "models");
331331
assert_eq!(inv.arg(0), Some("gpt-4"));
332332

333333
let inv = CommandInvocation::parse("/config --edit").unwrap();

src/cortex-plugins/src/hooks/completion_hooks.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -531,17 +531,17 @@ mod tests {
531531
#[test]
532532
fn test_completion_context() {
533533
let context = CompletionContext {
534-
input: "/model claude".to_string(),
535-
cursor_position: 13,
534+
input: "/models claude".to_string(),
535+
cursor_position: 14,
536536
word: Some("claude".to_string()),
537-
command: Some("model".to_string()),
537+
command: Some("models".to_string()),
538538
arg_index: Some(0),
539539
previous_args: vec![],
540540
manual_trigger: false,
541541
trigger_character: None,
542542
};
543543

544-
assert_eq!(context.command, Some("model".to_string()));
544+
assert_eq!(context.command, Some("models".to_string()));
545545
assert_eq!(context.arg_index, Some(0));
546546
}
547547
}

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
}

0 commit comments

Comments
 (0)