Skip to content

Search suggestions #85

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 20 commits into from
Nov 23, 2024
Merged

Search suggestions #85

merged 20 commits into from
Nov 23, 2024

Conversation

brendan-kellam
Copy link
Contributor

@brendan-kellam brendan-kellam commented Nov 21, 2024

The following PR introduces search suggestions:

Screen.Recording.2024-11-21.at.4.22.05.PM.mov

The motivation for building search suggestions is two-fold: (1) to make the zoekt query language more approachable by presenting all available options to the user, and (2) make it easier for power-users to craft complex queries.

The meat-n-potatoes of this change are concentrated in searchBar.tsx and searchSuggestionBox.tsx. The suggestions box works by maintaining a state-machine of "modes". By default, the box is in the refine mode, where suggestions for different prefixes (e.g., repo:, lang:, etc.) are suggested to the user. When one of these prefixes is matched, the state-machine transitions to the corresponding mode (e.g., repository, language, etc.) and surfaces suggestions for that mode (if any).

The query is split up into parts by spaces " " (e.g., 'test repo:hello' -> ['test', 'repo:hello']). See splitQuery. The part that has the cursor over it is considered the active part. We evaluate which mode the state machine is in based on the active part. When a suggestion is clicked, we only modify the active part of the query.

Three modes are currently missing suggestion data: file (file names), revision (branch / tag names), and symbol (symbol names). In future PRs, we will need to introduce endpoints into the backend to allow the frontend to fetch this data and surface it as suggestions..

@brendan-kellam brendan-kellam marked this pull request as ready for review November 22, 2024 01:01
@brendan-kellam brendan-kellam changed the title [wip] Search suggestions Search suggestions Nov 22, 2024
@msukkari msukkari self-requested a review November 22, 2024 23:59
@brendan-kellam brendan-kellam merged commit 7f952ce into main Nov 23, 2024
3 checks passed
@brendan-kellam brendan-kellam deleted the bkellam/search_suggestions branch November 23, 2024 02:50
@brendan-kellam brendan-kellam mentioned this pull request Nov 24, 2024
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.

2 participants