Skip to content

search: frontend scaffolding for 'Feeling Lucky' search mode

Warren Gifford requested to merge rvt/lucky-frontend-3 into main

Created by: rvantonder

This is the frontend part (and minimal backend part) for the "Feeling Lucky" search mode I'd like to merge. Context.

This PR adds a feature-flagged toggle:

https://user-images.githubusercontent.com/888624/171751372-d7af4253-3849-4cc2-8bd6-f34e76ba2973.mp4

I don't want to go into the search behavior of this mode in this PR, I will do that in the backend changes (just know that, it's worth having, and it's worth having as an experimental feature--see the PR for the backend changes here: https://github.com/sourcegraph/sourcegraph/pull/36519). This PR just gets into the details of how the feature affects the frontend (toggle buttons and how it's enabled).

The way it's enabled is by setting the default search pattern setting to lucky (open to other ideas, lucky works well enough for me). We don't have a good mechanism to create and separate "alternative default search pattern that is experimental", because of our GQL definitions and setting, so I found it much much easier to just modify this setting slightly, and recognize this as a new patterntype. I have tried other things (feature flagging with experimental settings) but it requires extremely invasive changes to the frontend and adds the need for another field to be set in all the prop drilling, etc.

When the flag is on, the default pattern becomes a lucky one, and a toggle with lightning bolt appears. The lightning bolt expands to the usual toggles when clicked, and collapses it on disable. I've called the hover on this button "Expert user", and how bounced around with "Power user" or "Advanced usage" or "Strict mode" something like that, I'm open to ideas and comments here but the exact wording is also low stakes at this point IMO, so would not bike shed on it.

Note: there's no special wording around "Feeling Lucky" signaled to the user, this is just an internal name for the addition. From the user's perspective, it's "just the default way Sourcegraph works", and the other (current) modes are the expert/advanced/precise/power user search modes.

Test plan

Scaffolding, manually tested, it's an experimental extension and not enabled.

Merge request reports

Loading