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

feature: add support for Codeium chat #485

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

etaldot
Copy link

@etaldot etaldot commented Apr 10, 2024

No description provided.

Tool/Sources/Preferences/Keys.swift Outdated Show resolved Hide resolved
@@ -27,6 +27,15 @@
"version" : "1.0.2"
}
},
{
"identity" : "generative-ai-swift",
Copy link

Choose a reason for hiding this comment

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

What do these changes do?

Copy link
Owner

Choose a reason for hiding this comment

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

The Package.resolved file is updated because I mostly develop in another workspace. Maybe it's better to just uncheck the file for this pull request if no dependency is added?

Tool/Sources/CodeiumService/CodeiumLanguageServer.swift Outdated Show resolved Hide resolved
@intitni
Copy link
Owner

intitni commented Apr 11, 2024

Wow, I was also planning to do this in the next phase when the chat feature is upgraded, but pull requests are always welcomed.

Do you mind explaining how Codeium chat will be integrated in this pull request?

@khou22
Copy link

khou22 commented Apr 11, 2024

Wow, I was also planning to do this in the next phase when the chat feature is upgraded, but pull requests are always welcomed.

Do you mind explaining how Codeium chat will be integrated in this pull request?

Kevin from the Codeium team here. We are going to be bringing Codeium Chat to Xcode! @etaldot is implementing this right now and will be opening PRs in the next week. How it works at a high level:

  1. Language server has two process that we will enable: web socket server and chat web client bundle
  2. The web client bundle will be served on a free port and will be embedded via iFrame or browser window. This will connect to the web socket server.
  3. In future PRs, there will be links, inline buttons, etc. that will enable users to click a "Code Lens" above a function definition to explain a piece of code. This will send a request to the web socket server and the result will be streamed to any open chat clients.

Let me know if you have other questions! We're excited to be releasing this soon 🙂

Copy link
Author

@etaldot etaldot left a comment

Choose a reason for hiding this comment

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

@intitni I left a question. Any help would be awesome. Looking forward to contribute to this!

@@ -35,6 +35,10 @@ public protocol XPCServiceProtocol {
editorContent: Data,
withReply reply: @escaping (Data?, Error?) -> Void
)
func openChat(
Copy link
Author

Choose a reason for hiding this comment

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

@intitni one question. I want to show this command only if codeium is setup to open chat. Additionally, I want to be able to call this directly. Right now it goes through the XPCService to get API keys etc, do you know of a better way

Copy link
Owner

Choose a reason for hiding this comment

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

Please reuse the ChatWithSelectionCommand and handle it in the service target. This command is named Open Chat but the type name was unchanged back then.

If you want to call a command programmatically, please use XcodeInspector.shared.safe.latestActiveXcode?.triggerCopilotCommand(name: "command name").

Copy link
Author

@etaldot etaldot Apr 16, 2024

Choose a reason for hiding this comment

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

Can you explain what do you mean by service target @intitni ?

Copy link
Owner

@intitni intitni Apr 16, 2024

Choose a reason for hiding this comment

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

I would suggest adding a picker in the chat settings to allow users to select what the open chat command will do. And handle it in func chatWithSelection(editor: EditorContent) in WindowBaseCommandHandler.swift.

It's just not recommended to add dynamic items to the Xcode menu because it can't be refreshed until Xcode is restarted.

I mean this.

@etaldot etaldot force-pushed the feat/add-support-for-codeium-chat branch from e8187c0 to d0a79c6 Compare April 13, 2024 05:23
@etaldot etaldot marked this pull request as ready for review April 13, 2024 05:24
@etaldot etaldot requested review from intitni and khou22 April 13, 2024 05:24
@@ -35,6 +35,10 @@ public protocol XPCServiceProtocol {
editorContent: Data,
withReply reply: @escaping (Data?, Error?) -> Void
)
func openChat(
Copy link
Owner

Choose a reason for hiding this comment

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

Please reuse the ChatWithSelectionCommand and handle it in the service target. This command is named Open Chat but the type name was unchanged back then.

If you want to call a command programmatically, please use XcodeInspector.shared.safe.latestActiveXcode?.triggerCopilotCommand(name: "command name").

@@ -47,6 +47,7 @@ public protocol SuggestionServiceProvider {
func notifyChangeTextDocument(fileURL: URL, content: String) async throws
func notifyCloseTextDocument(fileURL: URL) async throws
func notifySaveTextDocument(fileURL: URL) async throws
func openChat() async throws
Copy link
Owner

Choose a reason for hiding this comment

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

Please handle the openChat in a different place. SuggestionProvider is for suggestions only. If the code is too hard to reach, you can use NotificationCenter to post a notification.

Copy link
Author

@etaldot etaldot Apr 16, 2024

Choose a reason for hiding this comment

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

The reason I added this as a separate command called open chat rather than chat with selection was to distinguish between chatting with ChatGPT vs Codeium Chat. Can you explain further how would this look like if I were to move this out @intitni

Copy link
Owner

@intitni intitni Apr 16, 2024

Choose a reason for hiding this comment

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

I would suggest adding a picker in the chat settings to allow users to select what the open chat command will do. And handle it in func chatWithSelection(editor: EditorContent) in WindowBaseCommandHandler.swift.

It's just not recommended to add dynamic items to the Xcode menu because it can't be refreshed until Xcode is restarted.

Copy link
Owner

Choose a reason for hiding this comment

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

I also found that the openChat method is added to SuggestionWorkspacePlugin.swift, Please create a CodeiumWorkspacePlugin.swift and register it in Service.swift

Copy link
Owner

@intitni intitni Apr 16, 2024

Choose a reason for hiding this comment

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

Actually there is no API suitable for accessing the CodeiumService in another workspace plugin at the moment. Let's keep the changes in SuggestionProvider/WorkspacePlugin in this pr and only change the command.

Copy link
Author

Choose a reason for hiding this comment

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

@intitni just to be clear, you are suggesting continuing to use the suggestion service but only change the command to use ChatWithSelection with a toggle that allows users to either use github copilot or codeium as a chat method correct?

Copy link
Owner

Choose a reason for hiding this comment

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

Correct.

either use github copilot or codeium as a chat method

Please use words like builtin instead of GitHub Copilot because we don't support GitHub Copilot chat at all.

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.

None yet

3 participants