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 only uses available embeddings if cody.codebase is set #446

Closed
chwarwick opened this issue Jul 28, 2023 · 0 comments · Fixed by #525
Closed

Autocomplete only uses available embeddings if cody.codebase is set #446

chwarwick opened this issue Jul 28, 2023 · 0 comments · Fixed by #525
Assignees
Labels
autocomplete bug Something isn't working

Comments

@chwarwick
Copy link
Contributor

Autocomplete uses the base configuration which only considers the cody.codebase setting, it does not check the git remote to auto detect the repo if there is no codebase specified.

The chat context correctly identifies embeddings are available because it replaces the codebase context based on the git remote if there isn’t a cody.codebase setting.

Steps to reproduce:
Open a repository that has embeddings such as sourcegraph/cody but does not have a .vscode/settings.json with a cody.codebase specified.
Enable debugging - see that no embeddings events occur

sourcegraph/sourcegraph and sourcegraph/about both have .vscode/settings.json with the codebase set, removing it will also stop embeddings from happening on autocomplete.

@philipp-spiess philipp-spiess added the bug Something isn't working label Jul 31, 2023
@philipp-spiess philipp-spiess self-assigned this Aug 1, 2023
philipp-spiess added a commit that referenced this issue Aug 4, 2023
Closes #446

In the current state, embedding results would only ever be added if a
`cody.codebase` was configured in the VS Code settings. That was because
we didn't account for two things:

- The version of codebase context we passed into the config is the
_initial_ version that is only inferred from the config. We have the
class `ContextProvider` which is actively tracking changes to the
current active document and updates the config accordingly (this is
necessary because you can have multiple git repos in a workspace and
want to infer the remote from the proper repo)
- Additionally, ContextProvider was only initialized when the chat web
view was loaded the first time meaning that context wasn't added if you
don't have the sidebar visible (I’m not sure if this affects inline chat
too cc @abeatrix @umpox @dominiccooney)

This PR changes the API to accept a `getCodebaseContext` callback that's
only queried when the context is actually needed (so it can always
resolve to the latest value) and makes sure that `ContextProvider` is
initialized as part of the startup.

## Test plan

- Open a repo that is indexed but does not have a codebase config set up
(I used `sourcegraph/sourcegraph` but removed the option from the config
- Observe that we now fetch embeddings and that the regular chat still
seems to work.

<img width="515" alt="Screenshot 2023-08-01 at 12 43 25"
src="https://github.com/sourcegraph/cody/assets/458591/d8cbcae0-0015-40fc-b811-78bdd287d4b5">
<img width="1121" alt="Screenshot 2023-08-01 at 12 42 24"
src="https://github.com/sourcegraph/cody/assets/458591/1a70c396-e9ef-4bef-b0a4-4f81339b6dc8">

<!-- Required. See
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
autocomplete bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants