fix(search): show default cards on empty search state#79
Conversation
Card search page showed nothing on initial load when no query,
colors, or types were set. Now calls getDefaultCards() to return
25 alphabetically-ordered cards from the DB, cached for a day.
- Add getDefaultCards() to lib/search/card-search.ts with 'use cache' + cacheLife("days")
- Call it in SearchResults when all filters are empty
- Pass isDefault flag to SearchForm; shows "showing popular cards — search to filter" hint
|
Warning Review limit reached
Next review available in: 53 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (6)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Intent
The developer wanted to fix a bug where the card search page at /search showed no cards when loaded with no query or filters. The fix required adding a getDefaultCards function in lib/search/card-search.ts that returns a cached sample of cards ordered by name, updating the SearchResults component in the search page to call that function when all filter fields are empty, and adding a UI label in SearchForm to communicate to users that they are seeing popular cards rather than filtered results. The developer also wanted to run the no-mistakes validation pipeline to verify and ship the change as a PR.
What Changed
getDefaultCardstolib/search/card-search.ts— returns a cached alphabetical sample of 25 cards when no query or filters are active, replacing the previous empty-results stateapp/(ui)/search/page.tsxto callgetDefaultCardswhen all filter fields are empty, and updatedapp/_components/search/search-form.tsxto show a "Browse cards — search to filter" label (guarded against AI mode) instead of the earlier "Popular cards" label that misrepresented the alphabetical orderinggetDefaultCardsbehavior and theisDefaultlabel guardRisk Assessment
✅ Low: Round-1 fixes applied correctly: label renamed to "Browse cards — search to filter" and AI mode guard added; no new issues introduced.
Testing
Added 7 unit/component tests covering
getDefaultCards(DB query, cache tag, null fallbacks, empty result) and theisDefaultlabel in SearchForm (shows in simple mode, hidden in AI mode, absent without flag). All 2124 tests pass. Browser screenshot confirms the/searchpage loads 25 default cards and displays "Browse cards — search to filter" instead of the previous empty state./var/folders/b2/rft4yv4177d6mpkbhbwj7svc0000gn/T/no-mistakes-evidence/01KWCBF8QXSCEVWDBTPRDZ8C5W/search-default-state.png)Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
🔧 **Review** - 2 issues found → auto-fixed ✅
app/_components/search/search-form.tsx:237- getDefaultCards uses ORDER BY c.name with no WHERE clause — it returns alphabetically-first cards, not popular ones. The function comment says 'representative sample', but user intent says 'popular cards'. The label should match the actual ordering (e.g. 'browse cards' / 'sorted by name') or the query needs a real popularity signal.app/_components/search/search-form.tsx:236- The isDefault check should also be gated on initialMode !== 'ai'. Low-traffic edge case (requires ?mode=ai bookmark with no query), but the label is contradicted by the empty AI prompt state visible right below it.🔧 Fix: rename label and guard default badge in AI mode
✅ Re-checked - no issues remain.
✅ **Test** - passed
✅ No issues found.
pnpm test -- lib/search/__tests__/card-search.test.ts app/_components/search/__tests__/search-form.test.tsx— 2124 tests pass (7 new tests forgetDefaultCardsandisDefaultlabel behavior)Manual browser screenshot ofhttp://localhost:3099/searchwith no query — confirmed 25 results and 'Browse cards — search to filter' label rendered✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.