Create search and search-ui packages
Created by: tjkandala
Closes #29705 (closed).
Motivation
One goal of v1 of the new Sourcegraph VS Code extension is to provide a familiar experience for existing Sourcegraph users in their IDEs, which also makes the potential transition to using Sourcegraph.com easier for new users (acquired through the new VS Code extension). The easiest way to make that happen is to use the same components as the web application.
To that end, this PR introduces two new packages in order to share essential search code between client applications.
New Packages
-
search: General search types (e.g.
QueryState. Can be used in any client context (e.g. web app, browser extension, CLIs). - search-ui: Search UI components that adhere to our branding. Can be used only in branded clients (e.g. web app, VS Code extension)
For reviewers
This PR is best reviewed by commit. I've done my best to make sure each commit is simple and that the code is in a working state. The overall diff is very misleading in terms of complexity; the vast majority of changes are updates to imports and stuff like making components accept PlatformContext in order to abstract GQL requests. The build is passing and search features check out in manual testing. However, we can split this into multiple PRs if that would increase confidence!
Changes
-
<SearchBox>(really all ofweb/src/search/input) tosearch-ui- Moves to to enable this:
-
CurrentAuthStatequery, exportAuthenticatedUsertype alias (does this belong in a separate auth package?) -
web/src/keyboardShortcutstoshared/src/keyboardShortcuts-
also needs isMacPlatform,lazyComponent, andobserveResizefromweb/src/utilto be moved toshared/src/util
-
-
web/src/search/useQueryIntelligencetosearch/src/useQueryIntelligence. This only depends on stuff already inshared(moving tosearch) -
<MonacoEditor>fromweb/src/componentstoshared/src/components. This only depends on stuff already inshared(moving tosearch) -
web/src/search/helpers.tsxto move tosearch, notsearch-ui -
Settings schema type generation to move to shared(needed for quick links and<FilterLink>) -
TemporarySettings to move to shared -
Most of web/src/search/backend.tsxtosearch -
SyntaxHighlightedSearchQuerytosearch-ui
-
- Moves to to enable this:
-
<StreamingSearchResultsList>tosearch-ui. We could just move<StreamingSearchResults>, but that component is too intertwined with web stuff (e.g. code insights, search stack) so I think it makes more sense to pull out the list component and other shared components (likeSearchAlert) and assemble an independent VSCE search results page. Additionally,<StreamingSearchResults>renders the search sidebar, whereas we want to render that in a VS Code sidebar webview.- Moves to enable this:
-
<ModalVideo>tosearch-ui -
<ErrorAlert>tobranded(maybewildcard?) -
<SearchResult>and<CommitSearchResultMatch>tosearch-ui-
highlightCodefromweb/src/search/backend.tsxtosearch
-
-
Make web/src/user/settings/codeHosts/OrgUserNeedsCodeHost.tsxa render prop (depends on Apollo Client which will not be implemented for VSCE v1) -
<NoResultsPage>tosearch-ui-
Will have to pass in experimental features as prop instead of using useExperimentalFeatures(zustand store). Eventually we should think about how to more elegantly manage our zustand stores across clients -
<AnnotatedSearchInput>tosearch-ui
-
-
- Moves to enable this:
-
<SearchSidebar>tosearch-uias mentioned in the previous point.- Moves to to enable this:
-
This depends on the global useNavbarQueryState, so we should make a generalSearchQueryStateinterface insearchand pass the store instance as a prop. -
<Revisions>sidebar section will stay inwebuntil we get Apollo client working for VS Code webviews. Refactor<SearchSidebar>to acceptgetRevisionsprop -
<OnboardingTour>is web-only (for now?), so add aprefixContentprop for web consumers to render it into -
Move client/web/src/search/helpers/queryExample.tstosearch
-
- Moves to to enable this:
Candidates for moves in future PRs
-
shared/src/search/query,shared/src/search/suggestions, andshared/src/search/stream.tstosearch- move
<FileMatch>tosearch-ui
- move
