Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Autocomplete: Log the number of lines of an accepted completion and fix a bug #53878

Merged
merged 7 commits into from
Jun 22, 2023

Conversation

philipp-spiess
Copy link
Contributor

This PR does two things:

  • First we add the number of lines of an accepted completion. Cool
  • But then I noticed an oversight on my side. When you hover over the autocomplete preview, the VS Code backends sends a new completion request concurrently which our previous logic was using the clear the number of open completion requests. That means that whenever we accepted a solution after that, we would not log it because we've already GCed it.
    • To fix this, I’m now using the LRU cache to keep more completions around (which will also help later as we need to do more shenanigans with the logger)

Test plan

  • Trigger a multi-line completion
  • Hover over the suggested completion
  • Select a different one with a lower number of lines
  • Accept the completion
  • Observe that the right number for lines is logged
Screen.Recording.2023-06-21.at.18.17.01.mov

@cla-bot cla-bot bot added the cla-signed label Jun 21, 2023
@github-actions github-actions bot added the team/code-exploration Issues owned by the Code Exploration team label Jun 21, 2023
@sourcegraph-bot
Copy link
Contributor

sourcegraph-bot commented Jun 21, 2023

📖 Storybook live preview

if (!suggestedAt) {
continue
// eslint-disable-next-line ban/ban
displayedCompletions.forEach(completionEvent => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would remove this ban from our config 🙂

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll do this as a follow up

@philipp-spiess philipp-spiess enabled auto-merge (squash) June 22, 2023 12:37
@philipp-spiess philipp-spiess merged commit 46cb2cd into main Jun 22, 2023
14 of 16 checks passed
@philipp-spiess philipp-spiess deleted the ps/cody-autocomplete-log-lines branch June 22, 2023 12:47
ErikaRS pushed a commit that referenced this pull request Jun 22, 2023
…ix a bug (#53878)

This PR does two things:

- First we add the number of lines of an accepted completion. Cool
- But then I noticed an oversight on my side. When you hover over the
autocomplete preview, the VS Code backends sends a new completion
request concurrently which our previous logic was using the _clear the
number of open completion requests_. That means that whenever we
accepted a solution _after that_, we would not log it because we've
already GCed it.
- To fix this, I’m now using the LRU cache to keep more completions
around (which will also help later as we need to do more shenanigans
with the logger)


## Test plan

- Trigger a multi-line completion
- Hover over the suggested completion
- Select a different one with a lower number of lines
- Accept the completion
- Observe that the right number for `lines` is logged



https://github.com/sourcegraph/sourcegraph/assets/458591/4618d890-2491-4ac8-880d-8eba5c3622ba


<!-- All pull requests REQUIRE a test plan:
https://docs.sourcegraph.com/dev/background-information/testing_principles
-->
sanderginn pushed a commit that referenced this pull request Jun 23, 2023
…ix a bug (#53878)

This PR does two things:

- First we add the number of lines of an accepted completion. Cool
- But then I noticed an oversight on my side. When you hover over the
autocomplete preview, the VS Code backends sends a new completion
request concurrently which our previous logic was using the _clear the
number of open completion requests_. That means that whenever we
accepted a solution _after that_, we would not log it because we've
already GCed it.
- To fix this, I’m now using the LRU cache to keep more completions
around (which will also help later as we need to do more shenanigans
with the logger)


## Test plan

- Trigger a multi-line completion
- Hover over the suggested completion
- Select a different one with a lower number of lines
- Accept the completion
- Observe that the right number for `lines` is logged



https://github.com/sourcegraph/sourcegraph/assets/458591/4618d890-2491-4ac8-880d-8eba5c3622ba


<!-- All pull requests REQUIRE a test plan:
https://docs.sourcegraph.com/dev/background-information/testing_principles
-->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla-signed team/code-exploration Issues owned by the Code Exploration team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants