sourcegraph / sourcegraph-public-snapshot

Code AI platform with Code Search & Cody
https://sourcegraph.com
Other
10.11k stars 1.29k forks source link

Search contexts: allow setting a global default #58168

Open camdencheek opened 11 months ago

camdencheek commented 11 months ago

We've had a few requests for setting an instance-wide default search context so that an admin can set up the instance to be most useful for their devs by default.

nicholas-at-corteva commented 7 months ago

This would be handy for us as well. Our use case - We've added secondary code host connections, but most users will only want to search the primary first. The secondary results may just be extra noise to them.

qaisjp commented 2 months ago

Stripe would like this feature too.

If we were to submit a pull request for this, should it be namedsearch.defaultContext? Should it be a global/org/user setting or a site configuration setting?

qaisjp commented 2 months ago

This seems more complicated than expected because, today, the default search context is user configurable in the Search Contexts UI, and the default the user chooses is stored in the database using the setDefaultSearchContext mutation. Not in the user settings JSON.

That means that if we just naively stuck a default in the site configuration (or global settings), it would only affect new user accounts, as existing user accounts will already have a setting saved in the database.

I think what we need to do instead is to migrate the default search context from a bespoke setting to a setting saved in the user's configuration. (Like how codeIntel.mixPreciseAndSearchBasedReferences does.)

Then updating the global settings should work for existing accounts that haven't explicitly chosen some other context.