fix(code-suggestions): detect and cleanup detached streams
Description
New Behavior:
- 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.
- When this occurs, we now toggle off the loading icon for a stream
- 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:
- Enable debug logging (add
"gitlab.debug": true
to your VSCode preferences) - Trigger code generation (e.g. add a comment at the top of a file and then hit
enter
) - While the code gen code is streaming, hit
escape
- 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.
- On this branch, you will see this in the Output tab if it detached:
- 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