async resolveWebviewView()

in src/common/chat/gitlab_chat_view.ts [161:195]


  async resolveWebviewView(webviewView: vscode.WebviewView) {
    this.#chatView = webviewView;

    this.#chatView.webview.options = {
      enableScripts: true,
    };

    const initialState: WebViewInitialStateInterface = {
      slashCommands: defaultSlashCommands,
    };

    this.#chatView.webview.html = await prepareWebviewSource(
      this.#chatView.webview,
      this.#context,
      'gitlab_duo_chat',
      initialState,
    );

    const timeoutSecondsSetting = vscode.workspace
      .getConfiguration(CONFIG_NAMESPACE)
      .get('webviewTimeoutSeconds');
    const timeoutMs = isNumber(timeoutSecondsSetting) ? timeoutSecondsSetting * 1000 : undefined;

    if (timeoutMs) log.info(`Setting Duo Chat webview timeout to ${timeoutMs}ms`);
    await waitForWebview(this.#chatView.webview, timeoutMs);

    this.#chatView.webview.onDidReceiveMessage(m => this.#messageEmitter.fire(m));
    this.#chatView.onDidChangeVisibility(() => {
      if (this.#chatView?.visible) this.#visibilityEmitter.fire();
    });

    this.#chatView.onDidDispose(() => {
      this.#chatView = undefined;
    }, this);
  }