1use crate::state::{AppState, DialogOption, SelectKind};
2
3pub struct PaletteCommand {
4 pub name: &'static str,
5 pub title: &'static str,
6 pub desc: &'static str,
7 pub category: &'static str,
8 pub shortcut: Option<&'static str>,
9}
10
11pub const COMMANDS: &[PaletteCommand] = &[
12 PaletteCommand {
13 name: "session.new",
14 title: "New session",
15 desc: "Start a new conversation",
16 category: "Session",
17 shortcut: Some("^X n"),
18 },
19 PaletteCommand {
20 name: "session.list",
21 title: "Switch session",
22 desc: "Open the session list",
23 category: "Session",
24 shortcut: Some("^S"),
25 },
26 PaletteCommand {
27 name: "session.compact",
28 title: "Compact session",
29 desc: "Summarize older turns to free up context",
30 category: "Session",
31 shortcut: Some("^X c"),
32 },
33 PaletteCommand {
34 name: "session.export",
35 title: "Export session",
36 desc: "Write the transcript to disk",
37 category: "Session",
38 shortcut: None,
39 },
40 PaletteCommand {
41 name: "session.rename",
42 title: "Rename session",
43 desc: "Set a new title for this session",
44 category: "Session",
45 shortcut: None,
46 },
47 PaletteCommand {
48 name: "status.show",
49 title: "Show status",
50 desc: "Display current env, model, mode, cost",
51 category: "Session",
52 shortcut: None,
53 },
54 PaletteCommand {
55 name: "skills.show",
56 title: "Skills",
57 desc: "Browse available skills",
58 category: "Session",
59 shortcut: None,
60 },
61 PaletteCommand {
62 name: "model.list",
63 title: "Switch model",
64 desc: "Pick a different model for this session",
65 category: "Model",
66 shortcut: Some("^M"),
67 },
68 PaletteCommand {
69 name: "model.cycle_recent",
70 title: "Cycle recent model",
71 desc: "Quick-switch to the previous model",
72 category: "Model",
73 shortcut: Some("F2"),
74 },
75 PaletteCommand {
76 name: "mode.cycle",
77 title: "Cycle permission mode",
78 desc: "Normal → Auto-accept → Plan → Bypass",
79 category: "Mode",
80 shortcut: Some("S-Tab"),
81 },
82 PaletteCommand {
83 name: "sidebar.toggle",
84 title: "Toggle sidebar",
85 desc: "Show or hide the left panel",
86 category: "View",
87 shortcut: Some("^B"),
88 },
89 PaletteCommand {
90 name: "theme.switch",
91 title: "Switch theme",
92 desc: "Pick a different theme",
93 category: "View",
94 shortcut: None,
95 },
96 PaletteCommand {
97 name: "help.show",
98 title: "Help",
99 desc: "Show keyboard shortcuts and slash commands",
100 category: "Help",
101 shortcut: Some("?"),
102 },
103 PaletteCommand {
104 name: "app.quit",
105 title: "Quit",
106 desc: "Exit stynx-code",
107 category: "App",
108 shortcut: Some("^C"),
109 },
110];
111
112pub fn open_command_palette(state: &mut AppState) {
113 let options: Vec<DialogOption> = COMMANDS
114 .iter()
115 .map(|c| {
116 let mut opt = DialogOption::new(c.name, c.title)
117 .with_description(c.desc)
118 .with_category(c.category);
119 if let Some(s) = c.shortcut {
120 opt = opt.with_footer(s);
121 }
122 opt
123 })
124 .collect();
125 state
126 .modal
127 .open_select(SelectKind::CommandPalette, "Commands", options, None, None);
128}