Skip to content

Commit cd914c0

Browse files
authored
Merge pull request #207 from syncable-dev/develop
feat(agent): add @ file picker for context file selection
2 parents a449c0b + fa51e07 commit cd914c0

9 files changed

Lines changed: 830 additions & 66 deletions

File tree

Cargo.lock

Lines changed: 86 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ chrono = { version = "0.4", features = ["serde"] }
4141
colored = "3"
4242
crossterm = "0.28" # Terminal raw mode for interactive input
4343
inquire = "0.7" # Interactive terminal prompts with autocomplete
44+
rustyline = "15" # Readline-style input with completions
4445
prettytable = "0.10"
4546
term_size = "0.3"
4647

src/agent/session.rs

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,9 @@
1010
1111
use crate::agent::commands::{TokenUsage, SLASH_COMMANDS};
1212
use crate::agent::{AgentError, AgentResult, ProviderType};
13-
use crate::agent::ui::{SlashCommandAutocomplete, ansi};
13+
use crate::agent::ui::ansi;
1414
use crate::config::{load_agent_config, save_agent_config};
1515
use colored::Colorize;
16-
use inquire::Text;
1716
use std::io::{self, Write};
1817
use std::path::Path;
1918

@@ -407,17 +406,13 @@ impl ChatSession {
407406
input.trim().starts_with('/')
408407
}
409408

410-
/// Read user input with prompt - with interactive slash command support
411-
/// Uses `inquire` library for proper terminal handling and autocomplete
409+
/// Read user input with prompt - with interactive file picker support
410+
/// Uses custom terminal handling for @ file references and / commands
412411
pub fn read_input(&self) -> io::Result<String> {
413-
// Use inquire::Text with custom autocomplete for slash commands
414-
let input = Text::new("You:")
415-
.with_autocomplete(SlashCommandAutocomplete::new())
416-
.with_help_message("Type / for commands, or ask a question")
417-
.prompt();
412+
use crate::agent::ui::input::{read_input_with_file_picker, InputResult};
418413

419-
match input {
420-
Ok(text) => {
414+
match read_input_with_file_picker("You:", &self.project_path) {
415+
InputResult::Submit(text) => {
421416
let trimmed = text.trim();
422417
// Handle case where full suggestion was submitted (e.g., "/model Description")
423418
// Extract just the command if it looks like a suggestion format
@@ -429,9 +424,8 @@ impl ChatSession {
429424
}
430425
Ok(trimmed.to_string())
431426
}
432-
Err(inquire::InquireError::OperationCanceled) => Ok("exit".to_string()),
433-
Err(inquire::InquireError::OperationInterrupted) => Ok("exit".to_string()),
434-
Err(e) => Err(io::Error::new(io::ErrorKind::Other, e.to_string())),
427+
InputResult::Cancel => Ok("".to_string()),
428+
InputResult::Exit => Ok("exit".to_string()),
435429
}
436430
}
437431
}

0 commit comments

Comments
 (0)