Commit 8c3546d
committed
Search: Two-pass AI search with preflight
- LLM first generates a broad "preflight" query, runs it against the index, then refines using real results — fixes blind pattern guessing (e.g. `*resume*` matching `.fastresume`)
- `translate_search_query` accepts optional `PreflightContext` (hit count + up to 50 sample entries with names/sizes/dates) for the refinement pass
- `summarize_ai_query()` generates human-readable one-liners for the preflight row (e.g. `*resume* · size ≥ 10 MB · after 2025-01-01`)
- `format_preflight_table()` and `build_refinement_system_prompt()` format results for the LLM's second pass
- Preflight row always visible when AI is enabled — shows placeholder → summary → hit count → "Refining..." → "Refined"
- Skips refinement when ≤10 hits (already precise enough) or 0 hits
- Generation counter prevents stale LLM responses from overwriting newer queries
- Pass 2 failure gracefully falls back to pass 1 results with "Refinement failed" indicator
- UTF-8-safe name truncation in preflight table formatting
- `PreflightContext`, `PreflightEntry` types, `preflightSummary` field on `TranslateResult`
- 12 new Rust tests for summarization, table formatting, prompt construction, serde roundtrips1 parent 0f2c25c commit 8c3546d
7 files changed
Lines changed: 684 additions & 49 deletions
File tree
- apps/desktop
- src-tauri/src
- commands
- mcp
- src/lib
- search
- tauri-commands
0 commit comments