@@ -406,6 +406,37 @@ impl ChatSession {
406406 input. trim ( ) . starts_with ( '/' )
407407 }
408408
409+ /// Strip @ prefix from file/folder references for AI consumption
410+ /// Keeps the path but removes the leading @ that was used for autocomplete
411+ /// e.g., "check @src/main.rs for issues" -> "check src/main.rs for issues"
412+ fn strip_file_references ( input : & str ) -> String {
413+ let mut result = String :: with_capacity ( input. len ( ) ) ;
414+ let chars: Vec < char > = input. chars ( ) . collect ( ) ;
415+ let mut i = 0 ;
416+
417+ while i < chars. len ( ) {
418+ if chars[ i] == '@' {
419+ // Check if this @ is at start or after whitespace (valid file reference trigger)
420+ let is_valid_trigger = i == 0 || chars[ i - 1 ] . is_whitespace ( ) ;
421+
422+ if is_valid_trigger {
423+ // Check if there's a path after @ (not just @ followed by space/end)
424+ let has_path = i + 1 < chars. len ( ) && !chars[ i + 1 ] . is_whitespace ( ) ;
425+
426+ if has_path {
427+ // Skip the @ but keep the path
428+ i += 1 ;
429+ continue ;
430+ }
431+ }
432+ }
433+ result. push ( chars[ i] ) ;
434+ i += 1 ;
435+ }
436+
437+ result
438+ }
439+
409440 /// Read user input with prompt - with interactive file picker support
410441 /// Uses custom terminal handling for @ file references and / commands
411442 pub fn read_input ( & self ) -> io:: Result < String > {
@@ -422,7 +453,9 @@ impl ChatSession {
422453 return Ok ( cmd. to_string ( ) ) ;
423454 }
424455 }
425- Ok ( trimmed. to_string ( ) )
456+ // Strip @ prefix from file references before sending to AI
457+ // The @ is for UI autocomplete, but the AI should see just the path
458+ Ok ( Self :: strip_file_references ( trimmed) )
426459 }
427460 InputResult :: Cancel => Ok ( "exit" . to_string ( ) ) , // Ctrl+C exits
428461 InputResult :: Exit => Ok ( "exit" . to_string ( ) ) ,
0 commit comments