Fix Intent registry package search - #1079
Conversation
📝 WalkthroughWalkthroughAdds normalized NPM package search matching, excludes the ChangesNPM search filtering
Estimated code review effort: 2 (Simple) | ~10 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 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 |
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
tanstack-com | 422265c | Commit Preview URL Branch Preview URL |
Jul 30 2026, 03:47 PM |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/utils/intent.functions.ts`:
- Around line 207-213: In getIntentDirectory, derive normalizedSearch from
search.trim() once and use it consistently for the NPM request, database lookup,
npmPackageMatchesSearch filtering, and inclusion condition. Replace raw search
checks with normalizedSearch so whitespace-only input follows the empty-search
path and returns all packages.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: d1503f48-584e-40e1-8367-8de893a88aed
📒 Files selected for processing (3)
src/utils/intent.functions.tssrc/utils/intent.server.tstests/intent-package-search.test.ts
| const matchingNpmObjects = search | ||
| ? npmData.objects.filter((obj) => | ||
| npmPackageMatchesSearch(obj.package, search), | ||
| ) | ||
| : npmData.objects | ||
| const npmByName = new Map( | ||
| npmData.objects.map((obj) => [obj.package.name, obj]), | ||
| matchingNpmObjects.map((obj) => [obj.package.name, obj]), |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Normalize the search before branching on it.
npmPackageMatchesSearch treats whitespace-only input as empty, but getIntentDirectory still treats raw search as an active query. A value such as " " can therefore take the filtered/DB-search path and return no packages instead of behaving like an empty search. Derive const normalizedSearch = search?.trim() once and use it consistently for the NPM request, DB lookup, filtering, and inclusion condition.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/utils/intent.functions.ts` around lines 207 - 213, In getIntentDirectory,
derive normalizedSearch from search.trim() once and use it consistently for the
NPM request, database lookup, npmPackageMatchesSearch filtering, and inclusion
condition. Replace raw search checks with normalizedSearch so whitespace-only
input follows the empty-search path and returns all packages.
What changed
tanstack-intentregistry marker when matching user queriesEvidence and impact
The npm search API treats
keywords:tanstack-intentas sufficient even when the user term does not match. The reported nonsense query returned all 243 Intent-tagged packages, so the UI could not produce an empty or meaningfully narrowed package result. Local filtering preserves npm metadata search while removing unrelated results.Closes #1070
Validation
registry.npmjs.orgpnpm test— TypeScript, oxlint, and 116 tests: 115 passed, 1 skippedRisk
Low. The change only affects non-empty package searches. Matching is intentionally stricter than npm's fuzzy ranking: all entered terms must occur in the package name, description, or non-registry keywords.
Summary by CodeRabbit
Improvements
Bug Fixes