Skip to content

Comments

fix: support sorting algolia search results#1227

Merged
danielroe merged 5 commits intomainfrom
feat/sorting-search
Feb 8, 2026
Merged

fix: support sorting algolia search results#1227
danielroe merged 5 commits intomainfrom
feat/sorting-search

Conversation

@danielroe
Copy link
Member

No description provided.

@vercel
Copy link

vercel bot commented Feb 8, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
npmx.dev Ready Ready Preview, Comment Feb 8, 2026 5:07pm
2 Skipped Deployments
Project Deployment Actions Updated (UTC)
docs.npmx.dev Ignored Ignored Feb 8, 2026 5:07pm
npmx-lunaria Ignored Ignored Feb 8, 2026 5:07pm

Request Review

@github-actions
Copy link

github-actions bot commented Feb 8, 2026

Lunaria Status Overview

🌕 This pull request will trigger status changes.

Learn more

By default, every PR changing files present in the Lunaria configuration's files property will be considered and trigger status changes accordingly.

You can change this by adding one of the keywords present in the ignoreKeywords property in your Lunaria configuration file in the PR's title (ignoring all files) or by including a tracker directive in the merged commit's description.

Tracked Files

File Note
lunaria/files/en-GB.json Localization changed, will be marked as complete.
lunaria/files/en-US.json Source changed, localizations will be marked as outdated.
Warnings reference
Icon Description
🔄️ The source for this localization has been updated since the creation of this pull request, make sure all changes in the source have been applied.

@codecov
Copy link

codecov bot commented Feb 8, 2026

Codecov Report

❌ Patch coverage is 42.10526% with 11 lines in your changes missing coverage. Please review.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
app/composables/npm/useAlgoliaSearch.ts 0.00% 5 Missing and 2 partials ⚠️
app/composables/npm/useNpmSearch.ts 20.00% 3 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 8, 2026

📝 Walkthrough

Walkthrough

This pull request implements provider-aware sorting for package search. It adds a new getPackagesByName() method to fetch packages by exact name via Algolia, introduces a disabledSortKeys prop to ListToolbar for dynamic sort option availability, refactors useOrgPackages to use the new method with registry fallback, updates search.vue to implement client-side sorting for non-relevance queries, and adds PROVIDER_SORT_KEYS mapping to define supported sort keys per provider. Translation strings are added for sorted result messaging.

Possibly related PRs

  • PR 1191: Restructures org package fetching to use registry plus Algolia getPackagesByName fallback, implementing a similar streamlined authority-metadata-fallback pattern.
  • PR 641: Modifies org package fetching but retains bulk downloads approach, representing a contrasting implementation of composable restructuring.
🚥 Pre-merge checks | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Description check ⚠️ Warning The pull request has no description provided by the author, making it impossible to assess whether the intent aligns with the changeset. Add a clear description explaining the purpose of these changes, the problem being solved, and how the sorting functionality for Algolia search results is implemented.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/sorting-search

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (2)
app/components/Package/ListToolbar.vue (1)

186-208: Use UnoCSS preset-icons colon syntax for consistency with the codebase.

Lines 186 and 207–208 use dash syntax (i-carbon-chevron-down, i-carbon-sort-ascending, i-carbon-sort-descending), but colon syntax (i-carbon:chevron-down, etc.) is the standard throughout the codebase and provides better performance optimisation.

♻️ Suggested change
-              <span class="i-carbon-chevron-down w-4 h-4" />
+              <span class="i-carbon:chevron-down w-4 h-4" />
...
-                  ? 'i-carbon-sort-ascending'
-                  : 'i-carbon-sort-descending'
+                  ? 'i-carbon:sort-ascending'
+                  : 'i-carbon:sort-descending'
app/pages/search.vue (1)

114-126: Consider deriving this list from the shared type definition.

ALL_SORT_KEYS duplicates the non-relevance sort keys that are likely already defined in #shared/types/preferences. If the SortKey type is extended in the future, this list could drift out of sync.

Comment on lines +190 to 195
<!-- Sort direction toggle -->
<button
v-if="!searchContext"
v-if="!searchContext || currentSort.key !== 'relevance'"
type="button"
class="p-1.5 rounded border border-border bg-bg-subtle text-fg-muted hover:text-fg hover:border-border-hover transition-colors duration-200 focus-visible:ring-2 focus-visible:ring-fg focus-visible:ring-offset-2 focus-visible:ring-offset-bg"
:aria-label="$t('filters.sort.toggle_direction')"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Remove per-button focus-visible utilities; rely on the global focus styling.
Line 194 adds focus-visible utility classes to a button, which conflicts with the project’s global focus-visible rule for buttons and selects.

✅ Suggested change
-            class="p-1.5 rounded border border-border bg-bg-subtle text-fg-muted hover:text-fg hover:border-border-hover transition-colors duration-200 focus-visible:ring-2 focus-visible:ring-fg focus-visible:ring-offset-2 focus-visible:ring-offset-bg"
+            class="p-1.5 rounded border border-border bg-bg-subtle text-fg-muted hover:text-fg hover:border-border-hover transition-colors duration-200"

Based on learnings: In the npmx.dev project, ensure that focus-visible styling for button and select elements is implemented globally in app/assets/main.css with the rule: button:focus-visible, select:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }. Do not apply per-element inline focus-visible utility classes like focus-visible:outline-accent/70 on these elements.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
<!-- Sort direction toggle -->
<button
v-if="!searchContext"
v-if="!searchContext || currentSort.key !== 'relevance'"
type="button"
class="p-1.5 rounded border border-border bg-bg-subtle text-fg-muted hover:text-fg hover:border-border-hover transition-colors duration-200 focus-visible:ring-2 focus-visible:ring-fg focus-visible:ring-offset-2 focus-visible:ring-offset-bg"
:aria-label="$t('filters.sort.toggle_direction')"
<!-- Sort direction toggle -->
<button
v-if="!searchContext || currentSort.key !== 'relevance'"
type="button"
class="p-1.5 rounded border border-border bg-bg-subtle text-fg-muted hover:text-fg hover:border-border-hover transition-colors duration-200"
:aria-label="$t('filters.sort.toggle_direction')"

@danielroe danielroe merged commit 8039e14 into main Feb 8, 2026
20 checks passed
@danielroe danielroe deleted the feat/sorting-search branch February 8, 2026 17:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant