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

VSCode Extension #70

Closed
wants to merge 29 commits into from
Closed

VSCode Extension #70

wants to merge 29 commits into from

Conversation

granawkins
Copy link
Member

Implement Mentat as a Visual Studio Code extension. Basic functionality:

  • Add a "Mentat" tab in VSCode which opens a new vscode webview
  • Page 1: Select files and click a start button
  • Page 2: A standard chat interface for the cli workflow, with buttons for interrupt and restart (back to Page 1)

See /vscode/README.md for setup instructions.

@granawkins granawkins marked this pull request as draft August 22, 2023 03:30
@granawkins granawkins changed the title VSCode Extension (DRAFT) VSCode Extension Aug 22, 2023
@biobootloader
Copy link
Member

@waydegg want to help review this? It's waiting on me to finish #74 , but it'd be good to have you eyes on the VS Code extension implementation

@biobootloader
Copy link
Member

I wonder if the LSP portion (vscode/bundled/tool/lsp_server.py) could be general enough to support other editor extensions at some point, like for NeoVim?

@waydegg
Copy link
Contributor

waydegg commented Aug 27, 2023

@granawkins do you have any references to VSCode plugins made with Svelte that are somewhat popular/high-quality that you like? Asking since I've never used Svelte before and wanted to see how other plugins do it.

@waydegg
Copy link
Contributor

waydegg commented Aug 27, 2023

Need to find a way to make the UI work well with light themes:

image

@waydegg
Copy link
Contributor

waydegg commented Aug 27, 2023

I'm a big fan of what Cursor is doing for their chat UI/UX. Any thoughts on this?

image

They have some good feedback in their Discord on what people have liked/disliked too.

@waydegg
Copy link
Contributor

waydegg commented Aug 27, 2023

Is this just blocked on #74? Happy to review but I also don't wanna add a bunch of comments per-maturely if you're still making big additions/edits :) Pretty dope to see this working in VSCode btw!

@biobootloader
Copy link
Member

Is this just blocked on #74? Happy to review but I also don't wanna add a bunch of comments per-maturely if you're still making big additions/edits :)

@waydegg yes #74 needs to be merged first. The big open question is the best way to run both Mentat and the Python side of the LSP defined here - should we set up an async loop that runs both? Run on different processes?

I'm a big fan of what Cursor is doing for their chat UI/UX. Any thoughts on this?

Looks nice! My hope for this PR is to get a working Mentat experience in VS Code that we can then iterate on. So higher level comments on the best way to set this up are most useful. We should also track interface feature ideas somewhere, feel free to create issues for individual ideas or maybe we can start a list somewhere.

@granawkins
Copy link
Member Author

granawkins commented Aug 27, 2023

I wonder if the LSP portion (vscode/bundled/tool/lsp_server.py) could be general enough to support other editor extensions at some point, like for NeoVim?

Absolutely, that's what I was thinking too. That's how Rift does it. Since this is from a template I figure we leave it like this for now, and if/when we add NeoVim we can separate it out.

@granawkins do you have any references to VSCode plugins made with Svelte that are somewhat popular/high-quality that you like? Asking since I've never used Svelte before and wanted to see how other plugins do it.

Yes - the main one is Rift. I also noticed it in some templates last week which I'm afraid I've lost. There are a few others if you search GitHub for vscode language:svelte.

I'm not married to Svelte though, it's my first time using it as well. It's really similar to Vue, which I've used a lot, but the bundle is lighter and it builds really fast. Open to suggestions.

Need to find a way to make the UI work well with light themes:

image

Ya, that's top of my list :) Cursor looks awesome - I'm going to try to just get something basic up to start, but love that direction.

Is this just blocked on #74? Happy to review but I also don't wanna add a bunch of comments per-maturely if you're still making big additions/edits :) Pretty dope to see this working in VSCode btw!

The VSCode side is close to ready - go ahead and comment as much as you'd like. If you have a lot of comments/questions it might be easier just to do a videocall? HMU @waydegg

@waydegg
Copy link
Contributor

waydegg commented Aug 31, 2023

The big open question is the best way to run both Mentat and the Python side of the LSP defined here - should we set up an async loop that runs both? Run on different processes?

I think we should def be building towards running everything async (electron already eats up enough processing as is haha). pygls, the library the VSCode extension template uses that interfaces w/ language servers, has first-class async support. Most of Mentat latency is network io also.

Would love you hear what you guys are thinking.

@waydegg
Copy link
Contributor

waydegg commented Aug 31, 2023

I'm not married to Svelte though, it's my first time using it as well. It's really similar to Vue, which I've used a lot, but the bundle is lighter and it builds really fast. Open to suggestions.

I'm not married to any particular framework either (I've been wanting an excuse to learn Svelte anyways haha). I guess my only concern would be ease-of-contributing since most ppl already know React/Vue and there's obv a huge library ecosystem for both frameworks.

@waydegg
Copy link
Contributor

waydegg commented Aug 31, 2023

At a high level I think this looks good! I'll create a github discussion/issue for feature suggestions we can all collaborate on. Happy to review and approve once #74 is merged

Copy link
Member

@jakethekoenig jakethekoenig left a comment

Choose a reason for hiding this comment

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

Two notes around latency. I don't think either need to be addressed in this PR (though one is quick to fix) but I wanted to flag them for later.

Also are we sure we want this as a sub-directory in the mentat repo? I guess if the VSCode and NeoVim plugins end up sharing code it'll be simplest. But it will interfere with the standard way of installing vim plugins: cloning a repo into a plugin directory.

</div>

<div class="children-container {isOpen ? 'open' : ''}">
{#if file.children}
Copy link
Member

Choose a reason for hiding this comment

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

I notice a ~1 second latency when toggling expand/contract for large directories which can be fixed by checking isOpen here.

constructor(
public file: WorkspaceGraphElement, // File metadata
) {
if (this.file.children) {
Copy link
Member

Choose a reason for hiding this comment

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

For me there's an ~11s time to load after clicking the refresh button on this project (with python and node dependencies installed). Moving this to handleClick and loading files lazily cut it to ~3s.

Copy link
Member Author

Choose a reason for hiding this comment

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

Aha - great idea. I've now done something a bit different but same principle.

Copy link
Member

Choose a reason for hiding this comment

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

Your approach is really clean. Nice!

@jakethekoenig
Copy link
Member

Interesting: rift already included mentat as an agent.
Also @waydegg I don't see a cursor discord. Do you mean their forum?

@biobootloader
Copy link
Member

Also are we sure we want this as a sub-directory in the mentat repo? I guess if the VSCode and NeoVim plugins end up sharing code it'll be simplest. But it will interfere with the standard way of installing vim plugins: cloning a repo into a plugin directory.

@granawkins and I were talking about this - the benefit of a shared repo is it's easier to coordinate versions and changes between "core" Mentat and the VS Code extension. We do want any code that would be shared by VS Code and NeoVim plugins here (and those bits would probably be useful as well for the community if they make extensions for other editors). @jakethekoenig is the way you see it interfering with vim plugin install just that the cloned repo would be bigger?

Overall my vote is we keep it here for now and see how it goes, but that's not a strong opinion

Interesting: rift already included mentat as an agent.

Just announced today! They way they've included it involves inserting callbacks into the code / patching some input / output functions. When we finish getting Mentat setup for multiple interfaces they'll have an easier time connecting to it.

Also @waydegg I don't see a cursor discord. Do you mean their forum?

They have a discord but looks like they disabled invites for it and are switching to the forum

@jakethekoenig
Copy link
Member

Also are we sure we want this as a sub-directory in the mentat repo? I guess if the VSCode and NeoVim plugins end up sharing code it'll be simplest. But it will interfere with the standard way of installing vim plugins: cloning a repo into a plugin directory.

@granawkins and I were talking about this - the benefit of a shared repo is it's easier to coordinate versions and changes between "core" Mentat and the VS Code extension. We do want any code that would be shared by VS Code and NeoVim plugins here (and those bits would probably be useful as well for the community if they make extensions for other editors). @jakethekoenig is the way you see it interfering with vim plugin install just that the cloned repo would be bigger?

I have two concerns:

  1. Yeah it would make the cloned repo bigger. I guess that's not actually a big concern because storage/bandwidth is cheap and if becomes one we can make instruct the users to use use git clone --filter and git sparse-checkout to just get what they need. Though it's complicated because normally if I wanted to instruct a user to do something non trivial I'd put it in a script for them to run but if they have access to the script they've already cloned the repo.
  2. Vim plugins expect their files in a specific structure so we may have to litter the root of the project with autoload, doc, plugin and syntax and won't be able to bunch them all up under vim. I suppose there's no need to handle vscode and vim in the same way so we could have the vim plugin be a git submodule but the vscode plugin be a subdirectory like it is now.

Sorry if this is getting off topic for this PR.

@waydegg
Copy link
Contributor

waydegg commented Oct 23, 2023

Closing this b/c of #213

@waydegg waydegg closed this Oct 23, 2023
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.

4 participants