Skip to main content

stynx_code_tui/dialogs/
model_picker.rs

1use crate::state::{AppState, DialogOption, SelectKind};
2
3struct ModelEntry {
4    id: &'static str,
5    name: &'static str,
6    provider: &'static str,
7    note: Option<&'static str>,
8}
9
10const MODELS: &[ModelEntry] = &[
11    ModelEntry {
12        id: "claude-opus-4-7",
13        name: "Claude Opus 4.7",
14        provider: "Anthropic",
15        note: Some("most capable"),
16    },
17    ModelEntry {
18        id: "claude-opus-4-6",
19        name: "Claude Opus 4.6",
20        provider: "Anthropic",
21        note: None,
22    },
23    ModelEntry {
24        id: "claude-sonnet-4-6",
25        name: "Claude Sonnet 4.6",
26        provider: "Anthropic",
27        note: Some("balanced"),
28    },
29    ModelEntry {
30        id: "claude-haiku-4-5-20251001",
31        name: "Claude Haiku 4.5",
32        provider: "Anthropic",
33        note: Some("fast"),
34    },
35    ModelEntry {
36        id: "claude-sonnet-4-20250514",
37        name: "Claude Sonnet 4",
38        provider: "Anthropic",
39        note: None,
40    },
41    ModelEntry {
42        id: "claude-3-7-sonnet-20250219",
43        name: "Claude Sonnet 3.7",
44        provider: "Anthropic",
45        note: None,
46    },
47];
48
49pub fn open_model_picker(state: &mut AppState) {
50    let current = state.model_name.clone();
51    let options: Vec<DialogOption> = MODELS
52        .iter()
53        .map(|m| {
54            let mut opt = DialogOption::new(m.id, m.name).with_category(m.provider);
55            if let Some(note) = m.note {
56                opt = opt.with_footer(note);
57            }
58            opt
59        })
60        .collect();
61    state.modal.open_select(
62        SelectKind::ModelPicker,
63        "Select model",
64        options,
65        Some(current),
66        Some("• current".to_string()),
67    );
68}