opencode icon indicating copy to clipboard operation
opencode copied to clipboard

Fix: use full file path for fuzzy matching in autocomplete

Open bagatka opened this issue 1 week ago • 0 comments

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:

  1. Files - long file paths were truncated
  2. 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?: string to AutocompleteOption type
  • Set value to full filename when creating file options
  • Set value to 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

Demo

Screen Recording 2026-01-02 at 23 13 36

bagatka avatar Jan 02 '26 22:01 bagatka