Skip to content

Placeholder (maybe split later): migrate the rest of the areas to the new model according to RFC 155.

Created by: twop

See this WIP PR https://github.com/sourcegraph/sourcegraph/pull/10651 to overview API complexity RFC: https://docs.google.com/document/d/1ikrUNVe3YVbR-JpegxhjrFdmRkTGzTLcOMkKHnOyjuE/edit#

This is a placeholder task to migrate the rest of the surfaces after
#10748 (closed) and #10749 (closed) It should be probably be broken into several pieces later on

Note that depending on the progress of the tasks above we might want to revisit some of the decisions related to the approach. Questions that we hope to get answers before doing working on this task

  • Should we proxy observables?
  • Are flat interfaces + single state object is a good approach?
  • is there anything that blocks us from deprecating services?
  • how do we write tests for this new model

this is what should be left after two tasks mentioned above


  // --------------------------------------
 // State held by Extension host
 export interface State {
     // ExtDocuments
     documents: Map<string, ExtDocument>

      // ExtViews
     // implicit panelViews: Map<string, ExtPanelView>

      // ExtWindows
     activeWindow: {
         viewComponents: Map<string, ExtCodeEditor | DirectoryViewer>
     }
 }

  // --------------------------------------
 // tracking changes (derived data)
 export interface Updates {
     // ExtDocuments
     openedTextDocuments: Subject<TextDocument>

      // ExtWindows
     activeWindowChanges: Observable<WindowS>
     activeViewComponentChanges: BehaviorSubject<ViewComponent | undefined>
 }

  // --------------------------------------
 // Worker -> Main
 export interface ToMainThread {
     // ExtContext
     updateContext: (proxy: Remote<ClientContextAPI>, updates: ContextValues) => void

      // ExtViews
     registerPanelViewProvider: (
         id: string
     ) => {
         // returns an object that remembers the id here
         // NOTE implicit state here
         updatePanel: (data: PanelViewData) => void // EXTRA proxy
     }
     registerDirectoryViewProvider: (id: string, provider: object) => Unsubscribable // EXTRA proxy
     registerGlobalPageViewProvider: (id: string, provider: object) => Unsubscribable // EXTRA proxy

      // ExtContent
     registerLinkPreviewProvider: (urlMatchPattern: string, provider: LinkPreviewProvider) => Unsubscribable // EXTRA proxy

      // ExtWindows
     windows: {
         showNotification: (message: string, type: NotificationType) => void
         showMessage: (message: string) => Promise<void>
         showInputBox: (options?: InputBoxOptions) => Promise<string | undefined>
         showProgress: (options: ProgressOptions) => Promise<ProgressReporter> // EXTRA proxy
     }

      // ExtLanguageFeatures
     registerHoverProvider: (selector: DocumentSelector, provider: HoverProvider) => Unsubscribable // EXTRA proxy
     registerDefinitionProvider: (selector: DocumentSelector, provider: DefinitionProvider) => Unsubscribable // EXTRA proxy
     registerReferenceProvider: (selector: DocumentSelector, provider: ReferenceProvider) => Unsubscribable // EXTRA proxy
     registerLocationProvider: (id: string, selector: DocumentSelector, provider: LocationProvider) => Unsubscribable // EXTRA proxy
     registerCompletionItemProvider: (selector: DocumentSelector, provider: CompletionItemProvider) => Unsubscribable // EXTRA proxy
 }

  // --------------------------------------
 // Main -> Worker
 export interface FromMainThread {
     // ExtDocuments
     updateDocumentData: (modelUpdates: readonly TextModelUpdate[]) => void

      // ExtWindows
     acceptWindowData: (viewerUpdates: ViewerUpdate[]) => void
 }