Skip to content
This repository was archived by the owner on Aug 1, 2025. It is now read-only.

feat: add experimental chat panel#1486

Merged
abeatrix merged 29 commits into
mainfrom
bee/new-chat-ui
Oct 30, 2023
Merged

feat: add experimental chat panel#1486
abeatrix merged 29 commits into
mainfrom
bee/new-chat-ui

Conversation

@abeatrix

@abeatrix abeatrix commented Oct 24, 2023

Copy link
Copy Markdown
Contributor

Close https://github.com/sourcegraph/cody/issues/1522

New Chat UI

image

  • This PR adds a new experimental chat panel UI behind cody.experimental.chatPanel config that create separate views for commands, search, chats, and settings.
  • It also adds chat panel-related configuration options and commands.
  • Also updated the chat behavior to always start with empty chat, other than that, the chat behavior remains the same as the current one
  • Support multiple chat session

How does it work

The ChatViewManager class manages different chat view provider instances and handles switching between them based on config, and uses currentProvider or sidebarViewProvider to run chat commands.

A chat view provider (ChatViewProvider or ChatPanelProvider) is a class that implements the VS Code WebviewViewProvider interface to display a webview or webview panel for chat.

The ChatViewManager maintains:

  • sidebarViewProvider - An instance of ChatViewProvider for the sidebar auth flow and default chat view. This is always kept around.
  • chatPanelProviders - A map of ChatPanelProvider instances for editor panels, enabled when experimentalChatPanel config is true.
  • currentProvider - The currently active provider instance.

It decides which provider to use based on the experimentalChatPanel config:

  • When false, it uses the sidebarViewProvider.
  • When true, it creates a ChatPanelProvider if none exists yet, and uses that.

To execute commands, it first checks currentProvider, and if not set, defaults to using sidebarViewProvider.

After executing the command, it sets currentProvider to the provider used.

Next

Here are the items to be completed in future PRs:

  • Add @ context
  • Add context picker
  • Update /test to inline
  • Provider dropdown

Test plan

You can switch between the new chat UI and the current one from Cody Setting under New Chat UI:

image

See video below for a quick walkthrough:

Demo_.New.Chat.UI.v0.mp4

WIP

To do items from @toolmantim

Bugs

  • Looks like it’s enabled by default for me (have been testing w/ separate instance)
  • Chats opening multiple tabs
  • Chats not opening - pending for repro steps
  • Changing active chat should change selected item in treeview
  • Delete all chats sometimes just deletes the last one, sometimes deletes all
  • Sign out with chat window open doesn't close existing chats
  • Sometimes it gets in a state where clicking the buttons in the chats treeview fail with command not found errors
  • Creating new chats in succession causes some to fail to load
  • This may be existing behaviour, but a blank unsaved editor seems to work but if you add some lines of code then it fails saying no file is open

Changes

  • Just a single “Settings” option that goes to our settings
  • Add “@ext:sourcegraph.cody-ai” to “Keyboard shortcuts” command arg (command: { command: - [ ] 'workbench.action.openGlobalKeybindings', args: ['@ext:sourcegraph.cody-ai’]})
  • “Clear Chat” -> “Delete Chat” and “Delete All Chats”
  • “Delete All Chats” needs a confirmation
  • Clicking “Custom” should run “cody.action.commands.custom.menu”
  • Remove timestamp label on chat items, because it gets cut off anyhow when chat messages are long
  • Search: hide for now behind a hidden setting for dev testing? - REMOVED
  • Add version number in Help sidebar: Let's just add the same between "Keyboard Shortcuts" and "Sign Out", but "Version 0.14.2" (no v) and the icon github and have it link to the GitHub release?
  • We can make “Switch Account” an action button (icon: sign-in… I couldn’t find a better one) on “Sign Out” and remove the “…”
  • New chat should immediately show in tree view

TBD

  • “Custom Commands” item too strong for experimental feature I think, and we move to just an action button on panel root. If they have custom commands defined, we can have a collapsed “Custom Commands” item with a badge count that expands to show all the commands?
  • Clicking command with no editor open does nothing. Can we disable treeview items that need a file? Notification would feel too abrupt. Something else?

I'm going to move the following items to a seperate PRs since they affect the current behavior:

@abeatrix abeatrix requested review from a team, beyang and toolmantim October 24, 2023 23:07

@valerybugakov valerybugakov left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Exciting! Thank you for the video overview. 🙌
I reviewed the PR, focusing on the implementation details, leaving UI/UX to @toolmantim.

this.treeView = treeView
}

private async onDidReceiveMessage(message: WebviewMessage): Promise<void> {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Does it make sense to share part of the existing logic from ChatViewProvider with the new ChatPanelProvider to ensure we fix bugs for both implementations while ChatPanelProvider is behind the feature flag? Do we need to handle all the same messages as ChatViewProvider here?

Comment thread vscode/src/chat/ChatViewManager.ts Outdated
Comment thread vscode/src/chat/ChatPanelProvider.ts
Comment thread vscode/src/chat/ChatViewManager.ts Outdated
Comment thread vscode/src/services/TreeViewProvider.ts
Comment thread vscode/src/editor/active-editor.ts Outdated
Comment thread vscode/src/editor/active-editor.ts

@toolmantim toolmantim left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Woohoo! Just gave it a test, and left you some testing notes in Slack.

Comment thread vscode/src/services/TreeViewProvider.ts Outdated
Comment thread vscode/webviews/Chat.tsx Outdated
@abeatrix

abeatrix commented Oct 25, 2023

Copy link
Copy Markdown
Contributor Author

To do items from @toolmantim

Edit: moved to PR description under WIP

@toolmantim toolmantim left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It's starting to feel much more solid now! The pre-existing bugs which you asked for repo-steps for seem to be fixed 🙌🏼

Left a few small suggestions and found a few more bugs in testing:

  1. Sign out with chat window open doesn't close existing chats, which has some odd side-effects:
Screen.Recording.2023-10-26.at.4.52.41.pm.mov
Screen.Recording.2023-10-26.at.4.52.41.pm.1.mov
  1. Sometimes it gets in a state where clicking the buttons in the chats treeview fail with command not found errors:
Screen.Recording.2023-10-26.at.7.38.06.pm.mov
  1. Creating new chats in succession causes some to fail to load:
Screen.Recording.2023-10-26.at.7.36.14.pm.mov
  1. This may be existing behaviour, but a blank unsaved editor seems to work but if you add some lines of code then it fails saying no file is open:
Screen.Recording.2023-10-26.at.4.54.00.pm.mov

Comment thread vscode/src/services/TreeViewProvider.ts Outdated
Comment thread vscode/package.json Outdated
@abeatrix

Copy link
Copy Markdown
Contributor Author

@toolmantim Thank you so much for reporting all the bugs you found! I think I fixed all the bugs you last reported 🤞 Can you give the latest commit a try and let me know if you find other bugs before I move onto implementing the items on the rest of the list (see PR description under WIP section)? 🙇‍♀️

@toolmantim toolmantim left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks great! I just pushed some tweaks after playing with it for real.

@abeatrix abeatrix merged commit 0b78461 into main Oct 30, 2023
@abeatrix abeatrix deleted the bee/new-chat-ui branch October 30, 2023 18:50
burmudar pushed a commit that referenced this pull request Nov 21, 2024
…ch don't support inlay models. (#1490)

ImaginaryEditor does not support InlayModel and throws an
UnsupportedOperationException; IntentionPreviewEditor throws an
IntentionPreviewUnsupportedOperationException:
UnsupportedOperationException, etc.

Fixes #1488, #1486, #1485, #1480, #1466, #1462, #1435, #1363

## Test plan

```
./gradlew test --tests InlayModelUtilTest
```

Ran the IDE and clicked between editors, requesting autocompletes.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

VSCE: New Chat - Move chat from sidebar to panel

3 participants