Changesets · Branches · Tags · Compare
| Changeset | c2565dc2794520169e16d11e84ee9926a2acc1eaa8fd9dc0cd9bfac24f9b0ef9 |
|---|---|
| Author | Nate Sesti <33237525+sestinj@users.noreply.github.com> · 2025-07-03 19:04 -07:00 |
| Committer | GitHub <noreply@github.com> · 2025-07-03 19:04 -07:00 |
| Parents | 1c73a1f84d7c, d94819353983 |
1 file changed
modified gui/src/components/History/index.tsx +35 −4
| @@ -76,10 +76,41 @@ | ||
| 76 | 76 | const platform = useMemo(() => getPlatform(), []); |
| 77 | 77 | |
| 78 | 78 | const filteredAndSortedSessions: SessionMetadata[] = useMemo(() => { |
| 79 | - const sessionIds = minisearch | |
| 80 | - .search(searchTerm, { | |
| 81 | - fuzzy: 0.1, | |
| 82 | - }) | |
| 79 | + // 1. Exact phrase matching | |
| 80 | + const exactResults = minisearch.search(searchTerm, { | |
| 81 | + fuzzy: false, | |
| 82 | + }); | |
| 83 | + | |
| 84 | + // 2. Fuzzy matching with higher tolerance | |
| 85 | + const fuzzyResults = minisearch.search(searchTerm, { | |
| 86 | + fuzzy: 0.3, | |
| 87 | + }); | |
| 88 | + | |
| 89 | + // 3. Prefix matching for partial words | |
| 90 | + const prefixResults = minisearch.search(searchTerm, { | |
| 91 | + prefix: true, | |
| 92 | + fuzzy: 0.2, | |
| 93 | + }); | |
| 94 | + | |
| 95 | + // Combine results, with exact matches having higher priority | |
| 96 | + const allResults = [ | |
| 97 | + ...exactResults.map((r) => ({ ...r, priority: 3 })), | |
| 98 | + ...fuzzyResults.map((r) => ({ ...r, priority: 2 })), | |
| 99 | + ...prefixResults.map((r) => ({ ...r, priority: 1 })), | |
| 100 | + ]; | |
| 101 | + | |
| 102 | + // Remove duplicates while preserving highest priority | |
| 103 | + const uniqueResultsMap = new Map<string, any>(); | |
| 104 | + allResults.forEach((result) => { | |
| 105 | + const existing = uniqueResultsMap.get(result.id); | |
| 106 | + if (!existing || existing.priority < result.priority) { | |
| 107 | + uniqueResultsMap.set(result.id, result); | |
| 108 | + } | |
| 109 | + }); | |
| 110 | + const uniqueResults = Array.from(uniqueResultsMap.values()); | |
| 111 | + | |
| 112 | + const sessionIds = uniqueResults | |
| 113 | + .sort((a, b) => b.priority - a.priority || b.score - a.score) | |
| 83 | 114 | .map((result) => result.id); |
| 84 | 115 | |
| 85 | 116 | return allSessionMetadata |