Skip to content

Commit

Permalink
web: fix client workspaces cicular dependency issue (#44192)
Browse files Browse the repository at this point in the history
  • Loading branch information
valerybugakov committed Nov 12, 2022
1 parent 6733f46 commit 16b44cc
Show file tree
Hide file tree
Showing 33 changed files with 58 additions and 53 deletions.
2 changes: 1 addition & 1 deletion client/branded/src/components/panel/TabbedPanelContent.tsx
Expand Up @@ -11,13 +11,13 @@ import { ContributableMenu, Contributions, Evaluated } from '@sourcegraph/client
import { MaybeLoadingResult } from '@sourcegraph/codeintellify'
import { isDefined, combineLatestOrDefault, isErrorLike } from '@sourcegraph/common'
import { Location } from '@sourcegraph/extension-api-types'
import { FetchFileParameters } from '@sourcegraph/search-ui'
import { ActionsNavItems } from '@sourcegraph/shared/src/actions/ActionsNavItems'
import { wrapRemoteObservable } from '@sourcegraph/shared/src/api/client/api/common'
import { match } from '@sourcegraph/shared/src/api/client/types/textDocument'
import { ExtensionCodeEditor } from '@sourcegraph/shared/src/api/extension/api/codeEditor'
import { PanelViewData } from '@sourcegraph/shared/src/api/extension/extensionHostApi'
import { haveInitialExtensionsLoaded } from '@sourcegraph/shared/src/api/features'
import { FetchFileParameters } from '@sourcegraph/shared/src/backend/file'
import { ExtensionsControllerProps } from '@sourcegraph/shared/src/extensions/controller'
import { PlatformContextProps } from '@sourcegraph/shared/src/platform/context'
import { SettingsCascadeProps } from '@sourcegraph/shared/src/settings/settings'
Expand Down
3 changes: 2 additions & 1 deletion client/branded/src/components/panel/views/FileLocations.tsx
Expand Up @@ -10,7 +10,8 @@ import { Badged } from 'sourcegraph'

import { asError, ErrorLike, isErrorLike, isDefined, property, logger } from '@sourcegraph/common'
import { Location } from '@sourcegraph/extension-api-types'
import { FileSearchResult, FetchFileParameters } from '@sourcegraph/search-ui'
import { FileSearchResult } from '@sourcegraph/search-ui'
import { FetchFileParameters } from '@sourcegraph/shared/src/backend/file'
import { VirtualList } from '@sourcegraph/shared/src/components/VirtualList'
import { ContentMatch } from '@sourcegraph/shared/src/search/stream'
import { SettingsCascadeProps } from '@sourcegraph/shared/src/settings/settings'
Expand Down
Expand Up @@ -9,7 +9,7 @@ import { catchError, distinctUntilChanged, endWith, map, startWith, switchMap, t
import { MaybeLoadingResult } from '@sourcegraph/codeintellify'
import { asError, ErrorLike, isErrorLike } from '@sourcegraph/common'
import { Location } from '@sourcegraph/extension-api-types'
import { FetchFileParameters } from '@sourcegraph/search-ui'
import { FetchFileParameters } from '@sourcegraph/shared/src/backend/file'
import { ExtensionsControllerProps } from '@sourcegraph/shared/src/extensions/controller'
import { SettingsCascadeProps } from '@sourcegraph/shared/src/settings/settings'
import { TelemetryProps } from '@sourcegraph/shared/src/telemetry/telemetryService'
Expand Down
2 changes: 1 addition & 1 deletion client/branded/src/components/panel/views/PanelView.tsx
Expand Up @@ -4,7 +4,7 @@ import * as H from 'history'
import { Observable } from 'rxjs'

import { renderMarkdown } from '@sourcegraph/common'
import { FetchFileParameters } from '@sourcegraph/search-ui'
import { FetchFileParameters } from '@sourcegraph/shared/src/backend/file'
import { Markdown } from '@sourcegraph/shared/src/components/Markdown'
import { ExtensionsControllerProps } from '@sourcegraph/shared/src/extensions/controller'
import { SettingsCascadeProps } from '@sourcegraph/shared/src/settings/settings'
Expand Down
2 changes: 1 addition & 1 deletion client/branded/tsconfig.json
Expand Up @@ -6,7 +6,7 @@
"sourceRoot": "src",
"baseUrl": ".",
"paths": {
"*": ["src/types/*", "*"],
"*": ["../observability-client/src/types/*", "src/types/*", "*"],
},
"rootDir": ".",
"outDir": "./out",
Expand Down
7 changes: 6 additions & 1 deletion client/observability-client/src/instrumentations/history.ts
Expand Up @@ -44,7 +44,12 @@ export class HistoryInstrumentation extends InstrumentationBaseWeb {
const instrumentation = this

return function historyMethod(this: History, ...args: unknown[]) {
const result = original.apply(this, args as any)
/**
* TODO: figure out why `original as any` is required.
* Without it the monorepo wide Typescript build fails even though
* the `observability-client` Typescript builds are successful.
*/
const result = (original as any).apply(this, args as any)
instrumentation.createPageViewSpan()

return result
Expand Down
2 changes: 1 addition & 1 deletion client/observability-client/tsconfig.json
Expand Up @@ -7,7 +7,7 @@
"rootDir": ".",
"outDir": "out",
"paths": {
"*": ["../shared/src/types/*", "*"],
"*": ["./src/types/*", "*"],
},
},
"include": ["**/*", ".*"],
Expand Down
11 changes: 0 additions & 11 deletions client/search-ui/src/components/CodeExcerpt.tsx
Expand Up @@ -10,10 +10,8 @@ import { catchError, filter } from 'rxjs/operators'
import { HoverMerged } from '@sourcegraph/client-api'
import { DOMFunctions, findPositionsFromEvents, Hoverifier } from '@sourcegraph/codeintellify'
import { asError, ErrorLike, isDefined, isErrorLike, highlightNodeMultiline } from '@sourcegraph/common'
import { HighlightLineRange } from '@sourcegraph/search'
import { ActionItemAction } from '@sourcegraph/shared/src/actions/ActionItem'
import { ViewerId } from '@sourcegraph/shared/src/api/viewerTypes'
import { HighlightResponseFormat } from '@sourcegraph/shared/src/graphql-operations'
import { HoverContext } from '@sourcegraph/shared/src/hover/HoverOverlay.types'
import { Repo } from '@sourcegraph/shared/src/util/url'
import { Icon, Code } from '@sourcegraph/wildcard'
Expand All @@ -27,15 +25,6 @@ export interface Shape {
right?: number
}

export interface FetchFileParameters {
repoName: string
commitID: string
filePath: string
disableTimeout?: boolean
ranges: HighlightLineRange[]
format?: HighlightResponseFormat
}

interface Props extends Repo {
commitID: string
filePath: string
Expand Down
3 changes: 2 additions & 1 deletion client/search-ui/src/components/FileMatchChildren.tsx
Expand Up @@ -16,6 +16,7 @@ import {
} from '@sourcegraph/common'
import { HighlightLineRange, HighlightResponseFormat } from '@sourcegraph/search'
import { ActionItemAction } from '@sourcegraph/shared/src/actions/ActionItem'
import { FetchFileParameters } from '@sourcegraph/shared/src/backend/file'
import { MatchGroup } from '@sourcegraph/shared/src/components/ranking/PerFileResultRanking'
import { Controller as ExtensionsController } from '@sourcegraph/shared/src/extensions/controller'
import { HoverContext } from '@sourcegraph/shared/src/hover/HoverOverlay.types'
Expand All @@ -27,7 +28,7 @@ import { codeCopiedEvent } from '@sourcegraph/shared/src/tracking/event-log-crea
import { useCodeIntelViewerUpdates } from '@sourcegraph/shared/src/util/useCodeIntelViewerUpdates'
import { useFocusOnLoadedMore } from '@sourcegraph/wildcard'

import { CodeExcerpt, FetchFileParameters, onClickCodeExcerptHref } from './CodeExcerpt'
import { CodeExcerpt, onClickCodeExcerptHref } from './CodeExcerpt'
import { LastSyncedIcon } from './LastSyncedIcon'

import styles from './FileMatchChildren.module.scss'
Expand Down
4 changes: 2 additions & 2 deletions client/search-ui/src/components/FileSearchResult.tsx
Expand Up @@ -9,6 +9,7 @@ import { HoverMerged } from '@sourcegraph/client-api'
import { Hoverifier } from '@sourcegraph/codeintellify'
import { isErrorLike, pluralize } from '@sourcegraph/common'
import { ActionItemAction } from '@sourcegraph/shared/src/actions/ActionItem'
import { FetchFileParameters } from '@sourcegraph/shared/src/backend/file'
import { LineRanking } from '@sourcegraph/shared/src/components/ranking/LineRanking'
import { MatchGroup, MatchItem } from '@sourcegraph/shared/src/components/ranking/PerFileResultRanking'
import { ZoektRanking } from '@sourcegraph/shared/src/components/ranking/ZoektRanking'
Expand All @@ -26,7 +27,6 @@ import { isSettingsValid, SettingsCascadeProps } from '@sourcegraph/shared/src/s
import { TelemetryProps } from '@sourcegraph/shared/src/telemetry/telemetryService'
import { Badge } from '@sourcegraph/wildcard'

import { FetchFileParameters } from './CodeExcerpt'
import { FileMatchChildren } from './FileMatchChildren'
import { RepoFileLink } from './RepoFileLink'
import { ResultContainerProps, ResultContainer } from './ResultContainer'
Expand Down Expand Up @@ -125,7 +125,7 @@ export const FileSearchResult: React.FunctionComponent<React.PropsWithChildren<P
const contextLinesSetting =
isSettingsValid(props.settingsCascade) &&
props.settingsCascade.final &&
(props.settingsCascade.final['search.contextLines'] as number | undefined)
props.settingsCascade.final['search.contextLines']

if (typeof contextLinesSetting === 'number' && contextLinesSetting >= 0) {
return contextLinesSetting
Expand Down
3 changes: 2 additions & 1 deletion client/search-ui/src/results/StreamingSearchResultsList.tsx
Expand Up @@ -10,8 +10,9 @@ import { Observable } from 'rxjs'
import { HoverMerged } from '@sourcegraph/client-api'
import { Hoverifier } from '@sourcegraph/codeintellify'
import { SearchContextProps } from '@sourcegraph/search'
import { CommitSearchResult, RepoSearchResult, FileSearchResult, FetchFileParameters } from '@sourcegraph/search-ui'
import { CommitSearchResult, RepoSearchResult, FileSearchResult } from '@sourcegraph/search-ui'
import { ActionItemAction } from '@sourcegraph/shared/src/actions/ActionItem'
import { FetchFileParameters } from '@sourcegraph/shared/src/backend/file'
import { FilePrefetcher, PrefetchableFile } from '@sourcegraph/shared/src/components/PrefetchableFile'
import { displayRepoName } from '@sourcegraph/shared/src/components/RepoLink'
import { VirtualList } from '@sourcegraph/shared/src/components/VirtualList'
Expand Down
1 change: 1 addition & 0 deletions client/search-ui/tsconfig.json
Expand Up @@ -16,5 +16,6 @@
{ "path": "../branded" },
{ "path": "../http-client" },
{ "path": "../common" },
{ "path": "../observability-client" },
],
}
4 changes: 2 additions & 2 deletions client/search/src/integration/streaming-search-mocks.ts
@@ -1,9 +1,9 @@
/* eslint-disable no-template-curly-in-string */
import { SearchGraphQlOperations } from '@sourcegraph/search'
import { FetchFileParameters } from '@sourcegraph/search-ui'
import { FetchFileParameters } from '@sourcegraph/shared/src/backend/file'
import { SharedGraphQlOperations } from '@sourcegraph/shared/src/graphql-operations'
import { SearchEvent } from '@sourcegraph/shared/src/search/stream'

import { SearchGraphQlOperations } from '..'
import { SymbolKind } from '../graphql-operations'

export const diffSearchStreamEvents: SearchEvent[] = [
Expand Down
17 changes: 15 additions & 2 deletions client/shared/src/backend/file.ts
Expand Up @@ -3,9 +3,13 @@ import { map } from 'rxjs/operators'

import { createAggregateError, memoizeObservable } from '@sourcegraph/common'
import { gql } from '@sourcegraph/http-client'
import { FetchFileParameters } from '@sourcegraph/search-ui'

import { HighlightedFileResult, HighlightedFileVariables, HighlightResponseFormat } from '../graphql-operations'
import {
HighlightedFileResult,
HighlightedFileVariables,
HighlightLineRange,
HighlightResponseFormat,
} from '../graphql-operations'
import { PlatformContext } from '../platform/context'
import { makeRepoURI } from '../util/url'

Expand Down Expand Up @@ -65,6 +69,15 @@ const VSCE_HIGHLIGHTED_FILE_QUERY = gql`
}
`

export interface FetchFileParameters {
repoName: string
commitID: string
filePath: string
disableTimeout?: boolean
ranges: HighlightLineRange[]
format?: HighlightResponseFormat
}

/**
* Fetches the specified highlighted file line ranges (`FetchFileParameters.ranges`) and returns
* them as a list of ranges, each describing a list of lines in the form of HTML table '<tr>...</tr>'.
Expand Down
3 changes: 1 addition & 2 deletions client/shared/src/testing/searchTestHelpers.ts
Expand Up @@ -2,10 +2,9 @@ import { noop } from 'lodash'
import { EMPTY, NEVER, of, Subscription } from 'rxjs'
import sinon from 'sinon'

import { FetchFileParameters } from '@sourcegraph/search-ui'

import { FlatExtensionHostAPI } from '../api/contract'
import { pretendProxySubscribable, pretendRemote } from '../api/util'
import { FetchFileParameters } from '../backend/file'
import { Controller } from '../extensions/controller'
import { PlatformContext } from '../platform/context'
import { AggregateStreamingSearchResults, ContentMatch, RepositoryMatch } from '../search/stream'
Expand Down
10 changes: 2 additions & 8 deletions client/vscode/src/webview/search-panel/SearchResultsView.tsx
Expand Up @@ -10,15 +10,9 @@ import {
getUserSearchContextNamespaces,
QueryState,
} from '@sourcegraph/search'
import {
IEditor,
SearchBox,
StreamingProgress,
StreamingSearchResultsList,
FetchFileParameters,
} from '@sourcegraph/search-ui'
import { IEditor, SearchBox, StreamingProgress, StreamingSearchResultsList } from '@sourcegraph/search-ui'
import { wrapRemoteObservable } from '@sourcegraph/shared/src/api/client/api/common'
import { fetchHighlightedFileLineRanges } from '@sourcegraph/shared/src/backend/file'
import { FetchFileParameters, fetchHighlightedFileLineRanges } from '@sourcegraph/shared/src/backend/file'
import { collectMetrics } from '@sourcegraph/shared/src/search/query/metrics'
import {
appendContextFilter,
Expand Down
Expand Up @@ -12,13 +12,9 @@ import {
appendSubtreeQueryParameter,
toPositionOrRangeQueryParameter,
} from '@sourcegraph/common'
import {
LastSyncedIcon,
FileMatchChildrenStyles as styles,
CodeExcerpt,
FetchFileParameters,
} from '@sourcegraph/search-ui'
import { LastSyncedIcon, FileMatchChildrenStyles as styles, CodeExcerpt } from '@sourcegraph/search-ui'
import { ActionItemAction } from '@sourcegraph/shared/src/actions/ActionItem'
import { FetchFileParameters } from '@sourcegraph/shared/src/backend/file'
import { MatchGroup } from '@sourcegraph/shared/src/components/ranking/PerFileResultRanking'
import { Controller as ExtensionsController } from '@sourcegraph/shared/src/extensions/controller'
import { HoverContext } from '@sourcegraph/shared/src/hover/HoverOverlay.types'
Expand Down
2 changes: 1 addition & 1 deletion client/web/src/Layout.tsx
Expand Up @@ -7,7 +7,7 @@ import { Observable } from 'rxjs'
import { TabbedPanelContent } from '@sourcegraph/branded/src/components/panel/TabbedPanelContent'
import { isMacPlatform } from '@sourcegraph/common'
import { SearchContextProps } from '@sourcegraph/search'
import { FetchFileParameters } from '@sourcegraph/search-ui'
import { FetchFileParameters } from '@sourcegraph/shared/src/backend/file'
import { ExtensionsControllerProps } from '@sourcegraph/shared/src/extensions/controller'
import { useKeyboardShortcut } from '@sourcegraph/shared/src/keyboardShortcuts/useKeyboardShortcut'
import { PlatformContextProps } from '@sourcegraph/shared/src/platform/context'
Expand Down
3 changes: 1 addition & 2 deletions client/web/src/SourcegraphWebApp.tsx
Expand Up @@ -28,9 +28,8 @@ import {
getAvailableSearchContextSpecOrDefault,
SearchQueryStateStoreProvider,
} from '@sourcegraph/search'
import { FetchFileParameters } from '@sourcegraph/search-ui'
import { NotificationType } from '@sourcegraph/shared/src/api/extension/extensionHostApi'
import { fetchHighlightedFileLineRanges } from '@sourcegraph/shared/src/backend/file'
import { FetchFileParameters, fetchHighlightedFileLineRanges } from '@sourcegraph/shared/src/backend/file'
import { setCodeIntelSearchContext } from '@sourcegraph/shared/src/codeintel/searchContext'
import { Controller as ExtensionsController } from '@sourcegraph/shared/src/extensions/controller'
import { createController as createExtensionsController } from '@sourcegraph/shared/src/extensions/createLazyLoadedController'
Expand Down
3 changes: 2 additions & 1 deletion client/web/src/codeintel/ReferencesPanel.tsx
Expand Up @@ -20,7 +20,8 @@ import {
} from '@sourcegraph/common'
import { Position } from '@sourcegraph/extension-api-classes'
import { useQuery } from '@sourcegraph/http-client'
import { CodeExcerpt, FetchFileParameters, onClickCodeExcerptHref } from '@sourcegraph/search-ui'
import { CodeExcerpt, onClickCodeExcerptHref } from '@sourcegraph/search-ui'
import { FetchFileParameters } from '@sourcegraph/shared/src/backend/file'
import { LanguageSpec } from '@sourcegraph/shared/src/codeintel/legacy-extensions/language-specs/language-spec'
import { findLanguageSpec } from '@sourcegraph/shared/src/codeintel/legacy-extensions/language-specs/languages'
import { displayRepoName } from '@sourcegraph/shared/src/components/RepoLink'
Expand Down
Expand Up @@ -10,12 +10,12 @@ import { Hoverifier } from '@sourcegraph/codeintellify'
import { SearchContextProps } from '@sourcegraph/search'
import {
StreamingSearchResultsList,
FetchFileParameters,
CodeMirrorQueryInput,
changeListener,
createDefaultSuggestions,
} from '@sourcegraph/search-ui'
import { ActionItemAction } from '@sourcegraph/shared/src/actions/ActionItem'
import { FetchFileParameters } from '@sourcegraph/shared/src/backend/file'
import { editorHeight } from '@sourcegraph/shared/src/components/CodeMirrorEditor'
import { ExtensionsControllerProps } from '@sourcegraph/shared/src/extensions/controller'
import { HoverContext } from '@sourcegraph/shared/src/hover/HoverOverlay.types'
Expand Down
3 changes: 2 additions & 1 deletion client/web/src/notebooks/index.ts
@@ -1,8 +1,9 @@
import { Remote } from 'comlink'
import { Observable } from 'rxjs'

import { FetchFileParameters, HighlightRange } from '@sourcegraph/search-ui'
import { HighlightRange } from '@sourcegraph/search-ui'
import { FlatExtensionHostAPI } from '@sourcegraph/shared/src/api/contract'
import { FetchFileParameters } from '@sourcegraph/shared/src/backend/file'
import { AggregateStreamingSearchResults } from '@sourcegraph/shared/src/search/stream'
import { UIRangeSpec } from '@sourcegraph/shared/src/util/url'

Expand Down
Expand Up @@ -5,8 +5,10 @@ import { NEVER } from 'rxjs'
import { catchError, startWith } from 'rxjs/operators'

import { asError, isErrorLike } from '@sourcegraph/common'
import { FetchFileParameters } from '@sourcegraph/search-ui'
import { fetchHighlightedFileLineRanges as fetchHighlightedFileLineRangesShared } from '@sourcegraph/shared/src/backend/file'
import {
FetchFileParameters,
fetchHighlightedFileLineRanges as fetchHighlightedFileLineRangesShared,
} from '@sourcegraph/shared/src/backend/file'
import { ExtensionsControllerProps } from '@sourcegraph/shared/src/extensions/controller'
import { PlatformContextProps } from '@sourcegraph/shared/src/platform/context'
import { aggregateStreamingSearch } from '@sourcegraph/shared/src/search/stream'
Expand Down
3 changes: 2 additions & 1 deletion client/web/src/repo/blob/BlobPage.tsx
Expand Up @@ -19,7 +19,8 @@ import {
reactManualTracer,
} from '@sourcegraph/observability-client'
import { SearchContextProps } from '@sourcegraph/search'
import { FetchFileParameters, StreamingSearchResultsListProps } from '@sourcegraph/search-ui'
import { StreamingSearchResultsListProps } from '@sourcegraph/search-ui'
import { FetchFileParameters } from '@sourcegraph/shared/src/backend/file'
import { ExtensionsControllerProps } from '@sourcegraph/shared/src/extensions/controller'
import { HighlightResponseFormat } from '@sourcegraph/shared/src/graphql-operations'
import { PlatformContextProps } from '@sourcegraph/shared/src/platform/context'
Expand Down
2 changes: 1 addition & 1 deletion client/web/src/repo/blob/panel/BlobPanel.tsx
Expand Up @@ -14,8 +14,8 @@ import { ReferenceParameters, TextDocumentPositionParameters } from '@sourcegrap
import { MaybeLoadingResult } from '@sourcegraph/codeintellify'
import { isErrorLike } from '@sourcegraph/common'
import * as clientType from '@sourcegraph/extension-api-types'
import { FetchFileParameters } from '@sourcegraph/search-ui'
import { wrapRemoteObservable } from '@sourcegraph/shared/src/api/client/api/common'
import { FetchFileParameters } from '@sourcegraph/shared/src/backend/file'
import { ExtensionsControllerProps } from '@sourcegraph/shared/src/extensions/controller'
import { Scalars } from '@sourcegraph/shared/src/graphql-operations'
import { PlatformContextProps } from '@sourcegraph/shared/src/platform/context'
Expand Down
3 changes: 2 additions & 1 deletion client/web/src/search/results/StreamingSearchResults.tsx
Expand Up @@ -7,7 +7,8 @@ import { Observable } from 'rxjs'

import { asError } from '@sourcegraph/common'
import { QueryUpdate, SearchContextProps, SearchMode } from '@sourcegraph/search'
import { FetchFileParameters, StreamingProgress, StreamingSearchResultsList } from '@sourcegraph/search-ui'
import { StreamingProgress, StreamingSearchResultsList } from '@sourcegraph/search-ui'
import { FetchFileParameters } from '@sourcegraph/shared/src/backend/file'
import { FilePrefetcher } from '@sourcegraph/shared/src/components/PrefetchableFile'
import { ExtensionsControllerProps } from '@sourcegraph/shared/src/extensions/controller'
import { SearchPatternType } from '@sourcegraph/shared/src/graphql-operations'
Expand Down

0 comments on commit 16b44cc

Please sign in to comment.