opencode
opencode copied to clipboard
Fix: use full file path for fuzzy matching in autocomplete
Summary
- Fix file search in
@autocomplete to match against full file paths instead of truncated display strings - Fix MCP resources search to match against full resource text instead of truncated display strings
Problem
When attaching files or MCP resources using @ in the TUI, long paths/URIs are truncated with "…" in the middle for display (e.g., src/components/f…ationService.ts). The fuzzy search was running against this truncated string, so typing text that was hidden by the ellipsis would fail to find matches.
This affected both:
- Files - long file paths were truncated
- MCP Resources - long resource names/URIs were truncated
Solution
Added a value field to AutocompleteOption that preserves the full text for fuzzy matching, while display continues to show the truncated version. The fuzzy filter now uses value when available, falling back to display for backward compatibility.
Changes
- Added
value?: stringtoAutocompleteOptiontype - Set
valueto full filename when creating file options - Set
valueto full resource text when creating MCP resource options - Updated fuzzy matching to use
value ?? display - Added tests for file autocomplete filtering logic
- Added tests for MCP resource autocomplete filtering logic