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:
-
CurrentAuthState
query, exportAuthenticatedUser
type alias (does this belong in a separate auth package?) -
web/src/keyboardShortcuts
toshared/src/keyboardShortcuts
-
also needs isMacPlatform
,lazyComponent
, andobserveResize
fromweb/src/util
to be moved toshared/src/util
-
-
web/src/search/useQueryIntelligence
tosearch/src/useQueryIntelligence
. This only depends on stuff already inshared
(moving tosearch
) -
<MonacoEditor>
fromweb/src/components
toshared/src/components
. This only depends on stuff already inshared
(moving tosearch
) -
web/src/search/helpers.tsx
to 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.tsx
tosearch
-
SyntaxHighlightedSearchQuery
tosearch-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
-
highlightCode
fromweb/src/search/backend.tsx
tosearch
-
-
Make web/src/user/settings/codeHosts/OrgUserNeedsCodeHost.tsx
a 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-ui
as mentioned in the previous point.- Moves to to enable this:
-
This depends on the global useNavbarQueryState
, so we should make a generalSearchQueryState
interface insearch
and pass the store instance as a prop. -
<Revisions>
sidebar section will stay inweb
until we get Apollo client working for VS Code webviews. Refactor<SearchSidebar>
to acceptgetRevisions
prop -
<OnboardingTour>
is web-only (for now?), so add aprefixContent
prop for web consumers to render it into -
Move client/web/src/search/helpers/queryExample.ts
tosearch
-
- Moves to to enable this:
Candidates for moves in future PRs
-
shared/src/search/query
,shared/src/search/suggestions
, andshared/src/search/stream.ts
tosearch
- move
<FileMatch>
tosearch-ui
- move