Skip to content

[VS Code] DuoChat: Improve VS Code webview error messages

Problem

In certain cases, the VS Code Webview fails to initialize. This can cause a raw error to appear - the Duo Chat pane opens with the text "An error occurred while loading view: gl.chatView".

This is unfriendly and doesn't provide a resolution path for the user.

Proposal

Replace the above generic error with a more useful screen. If possible, including steps to attempt remedy the issue, or a reload button. It is possible the error might require the user to either close/open the pane, reload the extension, or reload the editor.

The error is thrown from VSCode itself. Possible solutions are:

  1. Add a top-level error catcher in our webview code, to avoid errors bubbling up to the container and hitting VS Code itself.
  2. Ensure the webview initialization is robust, e.g. ensuring any setup data passed to the web view is valid, even when errors outside exist.
  3. Ensure that the webview cannot be opened when the requires minimal setup has not occurred (e.g. the duo project access checker).

Other notes

Some work is required to determine exactly how this error case can appear. Current suspicion is that it's somehow possible to open the webview before it is fully initialized, perhaps if it was the last open view before the editor is restarted. For development purposes we may need to simulate the issue locally.

It may also be the case that certain graphql errors may be able to reproduce the error - could be a possibility based on this private doc.

There is also work to move the webview into gitlab-lsp, it might be the case that the error goes away. However, it would still be beneficial to have a top-level error page that we can show, for the case that the chat global error boundary gets tripped.

Edited by Tristan Read