fix: @ file search stops working after selecting a slash command#2694
Conversation
📋 Review SummaryThis PR fixes issue #2518 where 🔍 General Feedback
🎯 Specific Feedback🔵 Low
✅ Highlights
|
Code Coverage Summary
CLI Package - Full Text ReportCore Package - Full Text ReportFor detailed HTML reports, please see the 'coverage-reports-22.x-ubuntu-latest' artifact from the main CI run. |
…lash-command-2518 fix: @ file search stops working after selecting a slash command
TLDR
Fix
@file search not working after selecting a custom slash command (e.g.,/qc:create-issue).The completion mode detection in
useCommandCompletionchecked for SLASH mode before AT mode. When the line started with/, it immediately entered SLASH mode and never reached the@detection logic. This PR reorders the checks so@detection runs first, allowing file search to work correctly even after a slash command.Screenshots / Video Demo
N/A — CLI input behavior fix. The
@file search suggestions now correctly appear when typing@after a slash command on the same line.Dive Deeper
Root Cause: In
useCommandCompletion.tsx, theuseMemothat determinescompletionModehad this order:/→ returnCompletionMode.SLASH@→ returnCompletionMode.ATWhen typing
/qc:create-issue @file, the entire line starts with/, soisSlashCommand()returnedtrueand the function returned SLASH mode immediately, never reaching the@scan.Fix: Swap the detection order — scan for
@first (from cursor position backward), then fall back to SLASH check. This ensures:/help→ SLASH mode (no@found, works as before)/qc:create-issue @file→ AT mode (@found near cursor, triggers file search)Reviewer Test Plan
npm startto enter the interactive CLI/and select a custom slash command (e.g.,/qc:create-issue)@followed by a partial filename/commands still show slash command suggestionsnpx vitest run packages/cli/src/ui/hooks/useCommandCompletion.test.ts— all 17 tests passTesting Matrix
Linked issues / bugs
Fixes #2518