TabbyML / tabby

Self-hosted AI coding assistant
https://tabby.tabbyml.com/
Other
18.28k stars 771 forks source link

feat(vscode): send chat message with selection if available #2556

Closed wwayne closed 2 hours ago

wwayne commented 2 days ago

Main feature

When code is selected in the editor, the chat panel can send a message containing the selected code to the server

Screenshot 2024-07-03 15 42 25

If no code is selected, the chat panel will not include additional information

2

Implementation

  1. The /chat page has a new query parameter handle-message-submit. When handle-message-submit=true, /chat page delegates the handling of the submitted message to its parent container (e.g., VSCode).
  2. In VSCode, when onSubmitMessage is called, it attempts to fetch the selected code snippets.
  3. VSCode then calls the /chat endpoint to process the new message, including the selected code as relavantContext, and inside the /chat, it will take relavantContext as code_query.
icycodes commented 2 days ago

I think it is not always good to explicitly display the selection code in the user message.
It could be that if the user asks a question with 'this/that'. But it appears to be confusing if the user asks a generic question with some text selected.

wwayne commented 1 day ago

@icycodes I started the discussion on slack