Skip to content

fix(code-suggestions): detect and cleanup detached streams

Tristan Read requested to merge tr-handle-streaming-handler-detatched into main

Description

New Behavior:

  1. Detects when a stream is 'detached'.
    • Detached stream is one that has added new data sent to it from the Language Server, and that data isn't been consumed by the client within 200 milliseconds.
    • This can happen in numerous situations, the most common is hitting escape at the wrong time while a stream is loading.
  2. When this occurs, we now toggle off the loading icon for a stream
  3. We also trigger the subscription cleanup for the stream.

New Tests added for:

  • create_stream_iterator.ts
  • completion_stream.ts

Related Issues

Issue: #1190 (closed)

How has this been tested?

Manually

To reproduce:

  1. Enable debug logging (add "gitlab.debug": true to your VSCode preferences)
  2. Trigger code generation (e.g. add a comment at the top of a file and then hit enter)
  3. While the code gen code is streaming, hit escape
  4. You have a 20% chance to trigger the 'detached' stream state. Continue resetting and triggering the stream until it occurs.
    • On this branch, you will see this in the Output tab if it detached:
      2024-02-15T17:34:50:055 [debug]: Possible detached stream, initiating check
      2024-02-15T17:34:50:260 [debug]: Detached stream detected, performing cleanup
    • On the main branch, you will see the loading icon get 'stuck' in place until you click somewhere else on the page.
  5. Observe that the loading icon is cleared correctly with the new changes.

Screenshots (if appropriate)

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation
  • Chore (Related to CI or Packaging to platforms)
  • Test gap
Edited by Tristan Read

Merge request reports

Loading