private async setupDataEditor()

in src/dataEditor/dataEditorClient.ts [221:283]


  private async setupDataEditor() {
    assert(
      checkpointPath && checkpointPath.length > 0,
      'checkpointPath is not set'
    )

    // create a session and capture the session id, content type, and file size
    try {
      const createSessionResponse = await createSession(
        this.fileToEdit,
        undefined,
        checkpointPath
      )
      this.omegaSessionId = createSessionResponse.getSessionId()
      assert(this.omegaSessionId.length > 0, 'omegaSessionId is not set')
      addActiveSession(this.omegaSessionId)

      this.contentType = createSessionResponse.hasContentType()
        ? (createSessionResponse.getContentType() as string)
        : 'unknown'
      assert(this.contentType.length > 0, 'contentType is not set')

      this.fileSize = createSessionResponse.hasFileSize()
        ? (createSessionResponse.getFileSize() as number)
        : 0
    } catch {
      vscode.window.showErrorMessage(
        `Failed to create session for ${this.fileToEdit}`
      )
    }

    // create the viewport
    try {
      const viewportDataResponse = await createViewport(
        undefined,
        this.omegaSessionId,
        0,
        VIEWPORT_CAPACITY_MAX,
        false
      )
      this.currentViewportId = viewportDataResponse.getViewportId()
      assert(this.currentViewportId.length > 0, 'currentViewportId is not set')
      await viewportSubscribe(this.panel, this.currentViewportId)
      await sendViewportRefresh(this.panel, viewportDataResponse)
    } catch {
      vscode.window.showErrorMessage(
        `Failed to create viewport for ${this.fileToEdit}`
      )
    }

    // send the initial file info to the webview
    await this.panel.webview.postMessage({
      command: MessageCommand.fileInfo,
      data: {
        changeCount: 0,
        computedFileSize: this.fileSize,
        diskFileSize: this.fileSize,
        fileName: this.fileToEdit,
        type: this.contentType,
        undoCount: 0,
      },
    })
  }