Skip to content

Commit

Permalink
Polish the enterprise enhanced context selector (#1669)
Browse files Browse the repository at this point in the history
Fixes #1322, fixes #1425, fixes #1544, fixes #1532, fixes #1542

To summarize the changes:

- There are some repo resolution caches to make checking and unchecking
faster.
- The summary line has been simplified from counting total, ignored,
etc. repos to a simple count of repos which will be used (that is, the
enabled and not ignored repos, including the automatically included repo
if it is not ignored.)
- The automatically included repository is represented in the tree view
with a "Project repository" label.
- There's a separator between the tree view and the rest of the chat
panel. There's an expansive tooltip when you hover the separator, but
not the tree view so the tooltip does not impede expanding and
collapsing the tree view.
- The right hand side toolbar is gone, instead, you click on a tree view
item to bring up the repo list editor. You can also highlight it with
the keyboard and hit "enter".
- If you try to enable more than 10 repositories, you get feedback in
the form of an error notification.
- You can select and deselect repositories and they stay in the
repository tree view and are saved in chat state.
- The tree view reflects what you wrote in the popup. "Not found"
repositories are present with a label. You can delete a repository from
the text box to remove it from the tree view.
- The contrast and consistency of icons have been improved.
- The popup is positioned above the repository list, and is larger.
- The intermediate "Repositories" node of the tree view has been
removed.

Known bugs/caveats:

- When selecting/deselecting repositories in the tree view with the
keyboard, the item loses focus as the view is reconstructed.
- You can add an eleventh repository by specifying 10 repositories that
are not the automatically included repository. This one goes up to 11.
- Loading a chat with a de-selecting repository that has since been
filtered and checking it will result in the "ignored" state appearing.
This is because Cody Ignore is applied at late stage of remote repo
handling.
- Some of the new icons proposed in the design are not incorporated.
There are many overlapping versions of the design for this component...
I have to draw a line under this and handle any other feedback as
follow-ups.
- This does not address the https feedback in issue #1322; https URLs
are filed in #1354 and will be looked at separately.
- Repositories where the entered spec and the resolved name are
different may present as duplicates with one "not found."

## Test plan

Tested locally

![Screenshot 2024-05-28 at 19 19
09](https://github.com/sourcegraph/jetbrains/assets/55120/1640c6ca-5672-45dc-9f9e-617dfba1966d)
  • Loading branch information
dominiccooney authored May 28, 2024
1 parent 1216733 commit f483e3e
Show file tree
Hide file tree
Showing 27 changed files with 715 additions and 287 deletions.
2 changes: 2 additions & 0 deletions src/main/java/com/sourcegraph/cody/Icons.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ public interface Icons {
Icon HiImCody = IconLoader.getIcon("/icons/hiImCodyLogo.svg", Icons.class);

interface Actions {
Icon Add = IconLoader.getIcon("/icons/actions/huge_plus.svg", Icons.class);
Icon Edit = IconLoader.getIcon("/icons/actions/pencil.svg", Icons.class);
Icon Hide = IconLoader.getIcon("/icons/actions/hide.svg", Icons.class);
Icon Send = IconLoader.getIcon("/icons/actions/send.svg", Icons.class);
Icon DisabledSend = IconLoader.getIcon("/icons/actions/disabledSend.svg", Icons.class);
Expand Down
24 changes: 5 additions & 19 deletions src/main/kotlin/com/sourcegraph/cody/chat/AgentChatSession.kt
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,15 @@ import com.sourcegraph.cody.chat.ui.ChatPanel
import com.sourcegraph.cody.commands.CommandId
import com.sourcegraph.cody.config.CodyAuthenticationManager
import com.sourcegraph.cody.config.RateLimitStateManager
import com.sourcegraph.cody.context.RemoteRepoUtils
import com.sourcegraph.cody.error.CodyErrorSubmitter
import com.sourcegraph.cody.history.HistoryService
import com.sourcegraph.cody.history.state.ChatState
import com.sourcegraph.cody.history.state.EnhancedContextState
import com.sourcegraph.cody.history.state.MessageState
import com.sourcegraph.cody.vscode.CancellationToken
import com.sourcegraph.common.CodyBundle
import com.sourcegraph.common.CodyBundle.fmt
import com.sourcegraph.telemetry.GraphQlLogger
import com.sourcegraph.vcs.CodebaseName
import java.util.UUID
import java.util.concurrent.CompletableFuture
import java.util.concurrent.ExecutionException
Expand Down Expand Up @@ -276,23 +275,10 @@ private constructor(
restoreChatSession(agent, chatMessages, chatModelProviderFromState, state.internalId!!)
connectionId.getAndSet(newConnectionId)

// Update the Agent-side state.
val remoteRepos = state.enhancedContext?.remoteRepositories
if (remoteRepos != null &&
CodyAuthenticationManager.getInstance(project).getActiveAccount()?.isDotcomAccount() ==
false) {
RemoteRepoUtils.resolveReposWithErrorNotification(
project,
remoteRepos
.filter { it -> it.isEnabled && it.codebaseName != null }
.map { it -> CodebaseName(it.codebaseName!!) }
.toList()) { resolvedRepos ->
sendWebviewMessage(
WebviewMessage(
command = "context/choose-remote-search-repo",
explicitRepos = resolvedRepos))
}
.join()
// Update the context view, controller, and Agent-side state.
if (CodyAuthenticationManager.getInstance(project).getActiveAccount()?.isDotcomAccount() ==
false) {
chatPanel.contextView.updateFromSavedState(state.enhancedContext ?: EnhancedContextState())
}
}

Expand Down
5 changes: 3 additions & 2 deletions src/main/kotlin/com/sourcegraph/cody/chat/ui/Pluralize.kt
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package com.sourcegraph.cody.chat.ui

// Can pluralize "file", "line" and "repo" by adding -s
// Can pluralize "file", "line", "repo" and "repository"
fun String.pluralize(count: Int): String =
when {
count == 1 -> this
else -> "${this}s"
this.endsWith("y") -> this.dropLast(1) + "ies"
else -> this + "s"
}
Loading

0 comments on commit f483e3e

Please sign in to comment.