fix: clear-search restores board and enable partial-match search

- useTasks debounced effect bailed when searchQuery transitioned back to
  undefined (App passes `searchQuery || undefined`), so clearing the
  input never refetched the unfiltered list. Track previous value via
  ref and only skip the initial mount.
- FTS5 search used bare tokens (exact term match), so "frob" did not
  match "frobnicator". Append `*` to each token (and to quoted tokens)
  for prefix matching. LIKE fallback already did substring matching.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
gsxdsm
2026-04-30 21:01:13 -07:00
parent 6670837b7e
commit 0f4031824e
2 changed files with 10 additions and 3 deletions

View File

@@ -161,8 +161,13 @@ export function useTasks(options?: UseTasksOptions) {
}, []);
// Debounced search effect - separate from refreshTasks to avoid dependency cycle
const prevSearchQueryRef = useRef<string | undefined>(searchQuery);
useEffect(() => {
if (searchQuery === undefined) return;
// Skip only the initial mount when query has never been set; the visibility
// effect handles the first fetch. Going from a defined value back to
// undefined/"" must still trigger a refetch so the filter is cleared.
if (searchQuery === undefined && prevSearchQueryRef.current === undefined) return;
prevSearchQueryRef.current = searchQuery;
const timer = setTimeout(() => {
void refreshTasks({ searchQueryOverride: searchQuery });
}, 300);