-
Notifications
You must be signed in to change notification settings - Fork 293
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
Add multi-repo search for enterprise, remove remote embeddings #2879
Conversation
@beyang I have some tidy up and testing work to do but I would love your directional feedback on this. Loom demo: https://www.loom.com/share/d7ca236087fd44988c35a5a0e9e1ae0f |
c24e537
to
df61c04
Compare
Would you be able to also add some tests to index.test.ts? |
@pkukielka I am looking into writing tests cases for this PR 💪🏻 @dominiccooney I just tried this out and was surprised by the behavior of CleanShot.2024-01-25.at.15.36.00.mp4 |
Yes, this needs automated tests! I would love some details about JetBrains' plans for the enhanced context selector and repo picker and simplified chat in general to help with that... I noticed sourcegraph/jetbrains#258 was closed completed but I'd love some pointers.
That's the VSCode quickpick, it is goofy. Space to select items. Enter to "accept" the whole modal. ESC to cancel. |
@dominiccooney I pushed a commit to my branch I had to tweak the webview protocol a bit to support setting the repo directly without a quickpick, and also to get the remote repo. I have not yet tested |
fae22fa
to
5b46c09
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice one @dominiccooney!
I pushed up some style cleanups, and I've approved from a design POV.
Is it possible to ensure the Enhanced Popover doesn't dismiss itself after you've added some repositories?
I agree "Choose Repositories…" is a better term for this button label too (I think you've suggested this before). I didn't want to pop that commit on in case it broke tests, but feel free to make that change too.
Play around with repo selector. Move repo picker to a component. WIP repo picker Some debug logging. Basic repo picker complete, without account to account or run to run caching or recents. Mass deletion of embeddings etc. Enhanced context status shows add repo button and launches picker. Add a remote search client. Rough first cut plumbing in remote search to chat. Change the default useContext setting to "blended". Hide multi-repo search from consumer. Wire up the repo remove button. Add a title to the quickpick guiding the selection. Automatically populate the workspace root repos. Adding and removing workspace folders works. Show the repositories from the workspace separately. Provide repo ID lookup to the CodebaseStatusProvider. Unwind automatically including all workspace repos. Include the current file codebase automatically. Move remote repo handlers into method. Selected repos are pre-selected in the repo picker. Fix fat-fingered rebase. Attempt at using flexbox for repo list layout. Remove button uses pointer. Show short names in the enhanced context selector. Putting repo names in "detail" so they are still searchable Save and restore selected repos in the chat transcript. Add a "no repositories" message for empty workspaces. biome Add a no-op quickpick to agent. Update agent recordings with repository queries. Fix URI comparison for codebase update. Remove the repo fetching delay. Clean up unused parameter todo Simpler startup without initial codebase; edit uses repo search context. Update changelog.
743b7cb
to
a178802
Compare
Thanks @olafurpg for the agent test and @toolmantim for the style improvements. Recent changes:
|
+1, the little flicker of updated content before it dismisses is particularly distracting. If it is OK, let's do a follow up with There's also something weird going on with the background color of the remote context links being different (transparent) to the local context buttons (15% mix of foreground link color and transparent) I need some help with. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left some questions in line, will continue the review in the morning but lgtm so far!
Exciting feature, well done 🚀
// The name of the repository in the remote provider. For example the | ||
// context group may be "~/projects/frobbler" but the remote name is | ||
// "host.example/universal/frobbler". | ||
remoteName: string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this because the provider can have multiple repositories?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Basically, it is unused, so I removed it. In the old days we could have a source show up one way (like ~/projects/frozzler
) but be provided by something that named it something else (like github.com/widgets/frozzler
.) But now, Enterprise, everything calls it the same thing—the repo name.
repoName: string | ||
commit: string | ||
uri: URI | ||
path: string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is path here = url.path? Or is it referring to something else?
I always find path and fileName confusing 🤣
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, it is not uri.path
. The URI points to a Sourcegraph results page which has blob hashes and stuff. path
is the path to the file from the root of the repository.
Good feedback that this needs a comment.
@@ -706,6 +722,11 @@ export class SourcegraphGraphQLAPIClient { | |||
headers, | |||
}) | |||
.then(verifyResponseCode) | |||
//.then(response => response.text()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Leftover?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, although it is super handy if you want to see the response body, so I was thinking of leaving this here... WDYT?
@@ -160,6 +165,8 @@ export class ChatPanelsManager implements vscode.Disposable { | |||
const provider = this.createProvider() | |||
if (chatID) { | |||
await provider.restoreSession(chatID) | |||
} else { | |||
await provider.newSession() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the provider has just been created, would it has a new session set up already?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
newSession
does steps to set up that session.
The Windows test is failing because the prompt is different on Windows causing the HTTP replay to error. I think it's fine to add a |
See comment why, it's only the test that doesn't run on Windows. The feature works fine on Windows otherwise based on a manual test
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍🏻 I have not reviewed the full diff in detail but I have done the following:
- Manually verified the feature works as expected on macOS and Windows
- Added an automated squirrel test powered by multi-repo context. This test is skipped on Windows because there seems to be some platform-specific logic related to how we send the keyword search requests that doesn't affect the functionality in a live VS Code instance, only how it runs in tests.
- Reviewed the rough structure of the code
I am sure we can address minor issues with separate smaller PRs. Let's merge this as is because it represents a huge milestone for the February launch. Great work @dominiccooney ! 👏🏻
Previously, the agent initialized the VS Code extension against sourcegraph.com with an empty access token. We did this to ensure that initialization succeeded even with an invalid server endpoint. However, by doing so we introduced another problem: the extension sent a lot of network traffic to sourcegraph.com for enterprise accounts. Now, we use the custom server endpoint even during initialization. This change eliminates all automatic requests to sourcegraph.com for the minimized test cases we have in the codebase (covers initialization and sending a chat message). This currently only works out of the box thanks to the PR #2879 that removes embeddings. Before that change, initialization was regularly reporting errors from `EmbeddingDetector`, which has now been removed.
Previously, the agent initialized the VS Code extension against sourcegraph.com with an empty access token. We did this to ensure that initialization succeeded even with an invalid server endpoint. However, by doing so we introduced another problem: the extension sent a lot of network traffic to sourcegraph.com for enterprise accounts. Now, we use the custom server endpoint even during initialization. This change eliminates all automatic requests to sourcegraph.com for the minimized test cases we have in the codebase (covers initialization and sending a chat message). This currently only works out of the box thanks to the PR #2879 that removes embeddings. Before that change, initialization was regularly reporting errors from `EmbeddingDetector`, which has now been removed. ## Test plan Green CI. Manually search for "sourcegraph.com" in the updated recording file and confirm that all matches reference demo.sourcegraph.com. <!-- Required. See https://sourcegraph.com/docs/dev/background-information/testing_principles. -->
getCodyContext
GraphQL endpoint as a new context provider for Enterprisecody.codebase
, is automatically included by this context sourceKnown issues:
Fixes #2622, #2624, #2850
Test plan
This change deletes a lot of unused code so naturally, run the unit tests, e2e tests, etc.
Manual test plan:
Remote embeddings have been removed for consumer users:
git@github.com/react/react.git
Enterprise changes, so sign into an Enterprise account, then:
Repo selection:
Chats use the selected repositories; chats save the selected repositories:
Chats automatically use the repository workspace roots for context:
cody.codebase
set.)Supports multiple workspace roots:
cody.codebase
will override this automatic switching behavior. For example, if you use s2 and open the github.com/sourcegraph/sourcegraph repo the.vscode/settings.json
file sets"cody.codebase": "github.com/sourcegraph/sourcegraph"
. If your second folder is the github.com/sourcegraph/cody repository, you won't get automatic inclusion of the Cody repository by design.cody.codebase
setting, start a new chat, and check the automatically included repository matchescody.codebase
.Inline edits: