gemini-cli
gemini-cli copied to clipboard
fix(cli): Always process @file references in interactive mode
Summary
Fixes #14919
When users create prompts using the external editor (Ctrl+X), @file references were not being automatically loaded. Instead, the LLM had to initiate file reads itself, wasting tokens.
Root Cause
Interactive mode used isAtCommand() as a guard before calling handleAtCommand(). This heuristic (query.startsWith('@') || /\s@/.test(query)) failed in certain cases—especially for multi-line prompts from the external editor where @file might not be at the start or preceded by whitespace.
Non-interactive mode already calls handleAtCommand() unconditionally, so the fix is to match that behavior.
Changes
- useGeminiStream.ts: Remove the
isAtCommand()conditional guard—now always callshandleAtCommand()to match non-interactive behavior - atCommandProcessor.ts: Add a fast-path early exit (
if (!query.includes('@'))) to avoid unnecessary parsing when no@symbol exists - atCommandProcessor.test.ts: Add 3 new tests for edge cases:
- Prompts without
@symbol (verifies fast path) - Email addresses (verifies they don't trigger file loading)
- Multi-line prompts with
@fileon non-first line
- Prompts without
Testing
- All 47 tests in
atCommandProcessor.test.tspass - Full
npm run preflightpasses (build, typecheck, tests) - Manual verification recommended with external editor workflow