Skip to content

Conversation

@seanbudd
Copy link
Member

@seanbudd seanbudd commented Dec 1, 2025

Link to issue number:

None

Summary of the issue:

Add-on store list searching uses an exact search, i.e. it doesn't allow for typos or similar text to be found.
This also means that we cannot sort by search results relevance.
Instead a trigram search can be used to improve the search usability of the add-on store.

Description of user facing changes:

When searching add-ons, add-ons are filtered and ordered by search results relevance. The order can be updated after searching, and the previous order will restore if the search is cleared.

Description of developer facing changes:

None

Description of development approach:

  • Introduced a trigram-based fuzzy search algorithm for add-on filtering, providing more relevant search results even with partial or misspelled queries. Added a new searchRank field to AddonListField and made it the default sorting method when a search is active. [1] [2] [3]
  • Updated sorting logic throughout the GUI to use a new sortableFields property, which includes the new "Search relevance" option, and ensured that sorting and column selection are synchronized with the current search/filter state. [1] [2] [3] [4] [5]
  • When a search filter is applied or cleared, the code now updates both the ViewModel and UI selection to avoid inconsistencies and ensures the sort field reflects the current context (e.g., switches to "Search relevance" when searching).
  • Added logic to clear both ViewModel and UI selection when the search filter changes, preventing multiple rows from appearing selected and ensuring a single source of truth for selection.

Testing strategy:

Tested manually by filtering the add-on store

Known issues with pull request:

None

Code Review Checklist:

  • Documentation:
    • Change log entry
    • User Documentation
    • Developer / Technical Documentation
    • Context sensitive help for GUI changes
  • Testing:
    • Unit tests
    • System (end to end) tests
    • Manual testing
  • UX of all users considered:
    • Speech
    • Braille
    • Low Vision
    • Different web browsers
    • Localization in other languages / culture than English
  • API is compatible with existing add-ons.
  • Security precautions taken.

@seanbudd seanbudd requested a review from a team as a code owner December 1, 2025 07:47
@seanbudd seanbudd changed the title add trigram searching to add-on store add fuzzy trigram searching to add-on store Dec 1, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds trigram-based fuzzy search functionality to the NVDA add-on store, improving search usability by allowing typos and partial matches. The search results are now filtered and ordered by relevance, with the ability to restore the previous sort order when the search is cleared.

Key changes:

  • Implemented trigram-based similarity scoring for add-on search with a threshold of 0.3
  • Added "Search relevance" as a sortable field that becomes the default when searching
  • Automatically switches sort field to "Search relevance" when search is active and reverts to previous sort when cleared

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.

File Description
source/gui/addonStoreGui/viewModels/addonList.py Adds trigram search implementation, searchRank field, searchableText property, and logic to handle sort field transitions
source/gui/addonStoreGui/controls/storeDialog.py Updates UI to clear selection on search, switch to search relevance sorting, and synchronize column filter display
source/gui/addonStoreGui/controls/addonList.py Updates column click handling to use sortableFields instead of presentedFields

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@seanbudd seanbudd marked this pull request as draft December 1, 2025 07:57
@seanbudd seanbudd marked this pull request as ready for review December 2, 2025 06:30
@seanbudd seanbudd requested a review from Copilot December 2, 2025 06:30
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

seanbudd and others added 4 commits December 2, 2025 17:36
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
:return: A frozenset of trigrams.
:raises ValueError: If the text is too short to generate trigrams.
"""
normalized = strxfrm(text.strip())
Copy link
Contributor

Choose a reason for hiding this comment

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

Warning: strxfrm is not a normalization function.
It just provides a string that can be used as a key for locale-aware comparisons. Did you really intend to use this function?

Copy link
Member Author

Choose a reason for hiding this comment

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

yes, I believe it works as expected when performing trigram comparisons. e.g. ensuring an accented character matches the character itself.

Copy link
Contributor

Choose a reason for hiding this comment

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

>>> strxfrm("Sean")
'\x0e\x91\x0e!\x0e\x02\x0ep\x01\x01\x12\x01\x01'
>>> strxfrm("Séan")
'\x0e\x91\x0e!\x0e\x02\x0ep\x01\x02\x02\x0e\x01\x12\x01\x01'

Will trigram search work on these strings?

Also calling the result of strxfrm normalized is misleading.

Copy link
Member Author

Choose a reason for hiding this comment

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

yes, it will match by each char, in theory it should provide much better matching

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't think it's misleading. The conversion and stripping normalizes the text for the purpose of trigram searches

@CyrilleB79
Copy link
Contributor

Here are points of feedback after my first tests:

  • "福恩", the author of subtitle reader, cannot be found.
  • Assertion error when typing 3 spaces in the search field, or "AI " (e.g. when typing "AI image generator")
  • the add-on list is very slow to navigate with regular 1-second freeze
  • Maybe, if not already done, a more important weight should be given to the add-on's name, e.g. with respect to description, so that, for example, "Check Input Gestures" or "Enhanced Touch Gestures" appear on the top of the results.
  • Seems that you have implemented the algorithm manually. Why didn't you use a dedicated library for this?

@seanbudd seanbudd added the conceptApproved Similar 'triaged' for issues, PR accepted in theory, implementation needs review. label Dec 4, 2025
@seanbudd seanbudd marked this pull request as draft December 5, 2025 03:13
@seanbudd seanbudd added the merge-early Merge Early in a developer cycle label Dec 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

conceptApproved Similar 'triaged' for issues, PR accepted in theory, implementation needs review. merge-early Merge Early in a developer cycle

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants