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

Agent protocol and implementation for searching, listing, testing remote repository names #3775

Merged
merged 8 commits into from
Apr 15, 2024

Conversation

dominiccooney
Copy link
Contributor

@dominiccooney dominiccooney commented Apr 11, 2024

This adds Agent endpoints for:

  • Testing whether a remote has a specific repository.
  • Retrieving repository names from a remote matching a fuzzysort.
  • Retrieving all repository names from a remote, with pagination.

Closes sourcegraph/jetbrains#605.

Test plan

Manually tested with sourcegraph/jetbrains#1308

Added agent tests, run with pnpm test

Copy link
Contributor

@abeatrix abeatrix left a comment

Choose a reason for hiding this comment

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

Is there an instance I can connect to to test it on JetBrains?
I tried to connect to demo.sourcegraph but it is showing up as 0 repo 😆
image

Copy link
Contributor

@abeatrix abeatrix left a comment

Choose a reason for hiding this comment

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

I tried to run it with JetBrains but somehow it's showing that demo has 0 repo.
But the repositories are showing up in VS Code for the same instance, so I'm not sure if I am running the JetBrains dev env incorrectly.

From VS Code for reference:
image


if (!this.fuzzyIndex || !this.fuzzyTargetRepoMap) {
// Update the fuzzy search index.
// TODO: When speed is necessary, improve this by only indexing
Copy link
Contributor

Choose a reason for hiding this comment

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

This sounds like a good plan! Reasons we don't want to do that now?

// repositories and merging the result with the cached results, if any.
// Could also limit the result set and cap the maximum size of any list.
const result = fuzzysort.go(query, this.fuzzyIndex, {
threshold: -1000,
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
threshold: -1000,
limit: 20,
threshold: -1000,

would it make sense to limit the results for UI? I don't imagine people would want to go through a long list but that's just me, so feel free to ignore this 😄

@dominiccooney
Copy link
Contributor Author

@abeatrix thank you for the review 🙇

Is there an instance I can connect to to test it on JetBrains?
I tried to connect to demo.sourcegraph but it is showing up as 0 repo

demo.sourcegraph.com is a good one to test. 0 is working as intended: you haven't selected a repo.

I tried to run it with JetBrains but somehow it's showing that demo has 0 repo.
But the repositories are showing up in VS Code for the same instance, so I'm not sure if I am running the JetBrains dev env incorrectly.

The UX is: Hit the pencil, then type repo names. Autocomplete will appear. Command-space to manually trigger it.

[Various perf ideas] sounds like a good plan! Reasons we don't want to do that now?

I removed these TODOs. It seems fast enough, so I will keep it simple for now.

would it make sense to limit the results for UI? I don't imagine people would want to go through a long list but that's just me, so feel free to ignore this 😄

There's two levels of filtering: This -1000 limit, and then IntelliJ autocomplete requests a subset of that list. I tried to do something which would work for a lot of clients:

  • Rich clients that can handle the full repo list can call remoteRepo/list without a query and get paginated access to the full list, which they can then filter down.
  • Limited clients can call remoteRepo/list with a query and get paginated access to the matching score > -1000 items.
  • I don't limit the fuzzysort to the number of results the client requests, because you'd get an n^2 blow up if the client paged through the whole list. So it does the fuzzysearch once, caches the result, then lets the client page through it.

It's not super elegant but it should work for a range of client capabilities.

@dominiccooney dominiccooney merged commit d7717d1 into main Apr 15, 2024
22 checks passed
@dominiccooney dominiccooney deleted the dpc/repo-search-api branch April 15, 2024 06:53
dominiccooney added a commit to sourcegraph/jetbrains that referenced this pull request Apr 16, 2024
…1308)

This facilitates bulk editing of multiple remote repositories, with an
autocompleter and fuzzy search to make it easy to find repositories.

Agent side in sourcegraph/cody#3775
version.

Fixes #982 

## Test plan

Manually tested:

- Switch from an Enterprise to dotcom account and back. The enhanced
context selector in the chat panel should change presentation.
- Click the pencil and enter repository names. Duplicates should have
yellow underlines. More than 10 repositories should have yellow
underlines. Unknown repositories should have red underlines. Note, in
JetBrains 2022.x, Annotators are not DumbAware: The underlines will only
appear after the project finishes indexing.
- Ctrl-Space should open an autocomplete with fuzzy search of remote
repositories.
- Command/Ctrl-Enter should update the selected repositories in the
enhanced context selector. The entered text, including errors, should
persist for the life of the chat panel to facilitate incremental
editing; new chat panels should pick up a list of repositories separated
with newlines.
- Opening and closing the enhanced context selector tree view should
resize the bottom of the panel. Checking and unchecking the tree nodes
should influence whether enhanced context is used for chats (root node)
or for specific repositories (leaf nodes.) Note, the repository
associated with the open workspace is included implicitly when enhanced
context is enabled.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add agent endpoint to search for remote repositories for multi-repo context
2 participants