- Complete architectural overhaul of useUnifiedCompletion hook - Unified state management: 8 separate states → single CompletionState interface - Simplified core logic: getWordAtCursor 194 lines → 42 lines (78% reduction) - Fixed infinite React update loops with ref-based input tracking - Smart triggering mechanism replacing aggressive auto-completion - Integrated @agent and @file mention system with system reminders - Added comprehensive agent loading and mention processing - Enhanced Tab/Arrow/Enter key handling with clean event management - Maintained 100% functional compatibility across all completion types Key improvements: • File path completion (relative, absolute, ~expansion, @references) • Slash command completion (/help, /model, etc.) • Agent completion (@agent-xxx with intelligent descriptions) • System command completion (PATH scanning with fallback) • Terminal-style Tab cycling, Enter confirmation, Escape cancellation • Preview mode with boundary calculation • History navigation compatibility • Empty directory handling with user feedback Architecture: Event-driven @mention detection → system reminder injection → LLM tool usage Performance: Eliminated 7-layer nested conditionals, reduced state synchronization issues Reliability: Fixed maximum update depth exceeded warnings, stable state management
2.2 KiB
2.2 KiB
Autocomplete System Test Guide
Testing Tab Completion Priority
The system now has three autocomplete systems that work together without conflicts:
1. Slash Command Autocomplete
- Trigger: Type
/followed by command name - Complete: Tab or Enter
- Example:
/help,/model,/agents
2. Agent Mention Autocomplete
- Trigger: Type
@followed by agent name - Complete: Tab only (Enter submits message)
- Example:
@agent-code-writer,@dao-qi-harmony-designer
3. Path Autocomplete
- Trigger: Type a path-like string (contains
/, starts with.or~, or has file extension) - Complete: Tab
- Example:
./src/,~/Desktop/,package.json
4. Model Switching (Fallback)
- Trigger: Tab key when no autocomplete is active
- Action: Switches to next available model
Tab Key Priority Order
- Slash command suggestions (if
/commandis being typed) - Agent mention suggestions (if
@agentis being typed) - Path autocomplete (if path-like string is detected)
- Model switching (if no autocomplete is active)
Test Cases
Test 1: Slash Command
- Type
/he - Press Tab → Should complete to
/help - Press Enter → Should execute help command
Test 2: Agent Mention
- Type
@code - Press Tab → Should complete to
@agent-code-writer - Type additional message
- Press Enter → Should submit with agent mention
Test 3: Path Completion
- Type
./src/ - Press Tab → Should show files in src directory
- Select with arrow keys
- Press Tab → Should complete the path
Test 4: Model Switching
- Clear input
- Press Tab → Should switch model
- Verify model changed in status display
Test 5: Mixed Usage
- Type
Check @agent-code-writer for ./package.json - Tab should complete mentions and paths appropriately
- When no autocomplete context, Tab switches model
Expected Behavior
- No conflicts: Each autocomplete system activates only in its specific context
- Tab handling: Properly prioritized based on active context
- Enter handling: Only submits for slash commands with no args; otherwise just completes
- Model switching: Only works when no autocomplete is active