Skip to content

Commit 2282bdf

Browse files
committed
feat(tui): P1 wire slash commands + file completion into autocomplete
Register 18 built-in slash commands (/help, /clear, /compact, /exit, /model, /cost, /status, /memory, /config, /permissions, /resume, /diff, /review, /commit, /plan, /fast, /thinking, /effort) into the Tab completion engine at TUI startup. Also wire working directory for file path completion.
1 parent fdeffc1 commit 2282bdf

1 file changed

Lines changed: 79 additions & 0 deletions

File tree

crates/tui/src/runner.rs

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
//! - Skill `/command` input detection and resolution via `SkillRegistry`
99
1010
use std::io;
11+
12+
use crate::components::autocomplete::CommandInfo;
1113
use std::path::PathBuf;
1214
use std::pin::Pin;
1315
use std::sync::Arc;
@@ -161,8 +163,85 @@ pub async fn run(config: TuiConfig) -> anyhow::Result<()> {
161163
let mut app = App::new(&model_name);
162164
if let Ok(cwd) = std::env::current_dir() {
163165
app.set_working_dir(cwd.display().to_string());
166+
app.set_completion_cwd(cwd);
164167
}
165168

169+
// Register built-in slash commands for Tab completion
170+
app.set_slash_commands(vec![
171+
CommandInfo {
172+
name: "/help".into(),
173+
description: "Show available commands".into(),
174+
},
175+
CommandInfo {
176+
name: "/clear".into(),
177+
description: "Clear conversation history".into(),
178+
},
179+
CommandInfo {
180+
name: "/compact".into(),
181+
description: "Compact conversation (free context)".into(),
182+
},
183+
CommandInfo {
184+
name: "/exit".into(),
185+
description: "Exit crab-code".into(),
186+
},
187+
CommandInfo {
188+
name: "/model".into(),
189+
description: "Show or switch the current model".into(),
190+
},
191+
CommandInfo {
192+
name: "/cost".into(),
193+
description: "Show token usage and cost".into(),
194+
},
195+
CommandInfo {
196+
name: "/status".into(),
197+
description: "Show session status".into(),
198+
},
199+
CommandInfo {
200+
name: "/memory".into(),
201+
description: "Show or manage memory files".into(),
202+
},
203+
CommandInfo {
204+
name: "/config".into(),
205+
description: "Open settings configuration".into(),
206+
},
207+
CommandInfo {
208+
name: "/permissions".into(),
209+
description: "Show current permission mode".into(),
210+
},
211+
CommandInfo {
212+
name: "/resume".into(),
213+
description: "Resume a previous session".into(),
214+
},
215+
CommandInfo {
216+
name: "/diff".into(),
217+
description: "Show recent file changes".into(),
218+
},
219+
CommandInfo {
220+
name: "/review".into(),
221+
description: "Review recent code changes".into(),
222+
},
223+
CommandInfo {
224+
name: "/commit".into(),
225+
description: "Create a git commit".into(),
226+
},
227+
CommandInfo {
228+
name: "/plan".into(),
229+
description: "Enter plan mode".into(),
230+
},
231+
CommandInfo {
232+
name: "/fast".into(),
233+
description: "Toggle fast mode".into(),
234+
},
235+
CommandInfo {
236+
name: "/thinking".into(),
237+
description: "Toggle extended thinking".into(),
238+
},
239+
CommandInfo {
240+
name: "/effort".into(),
241+
description: "Set effort level".into(),
242+
},
243+
]);
244+
166245
// Main render + event loop
167246
let result = run_loop(
168247
&mut terminal,

0 commit comments

Comments
 (0)