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

Chat: Include editor selection in chat context by default #4292

Merged
merged 1 commit into from
May 27, 2024

Conversation

abeatrix
Copy link
Contributor

Summary

This change includes the user's current editor selection as context for all new chat messages by default. The selection context is added to the user context items when creating a new chat message.

To support this, the getContextFileFromSelection function is now imported and used in SimpleChatPanelProvider.ts. If the chat message source is 'chat', the current selection context is retrieved and added to the userContextFiles array before resolving the context items.

The selection context retrieval logic is also removed from getPriorityContext in context.ts since it is now handled in SimpleChatPanelProvider.ts.

Test plan

  1. Build Cody from this branch
  2. Highlight some code in your editor
  3. Start a new chat and ask Cody about the code you highlighted
  4. Submit the question with Opt + Enter (enhanced context disabled)
  5. Confirm your selection is included as context, and Cody is able to answer your question
  6. Start a new empty chat and ask Cody about the code you highlighted
  7. Submit the question with Enter (enhanced context enabled)
  8. Confirm your selection is also included as context with enhanced context added, and Cody is able to answer your question

My highlighted code

image

Enhanced Context disabled:

image

Enhanced Context enabled:

image

## Summary

This change includes the user's current editor selection as context for all new chat messages by default. The selection context is added to the user context items when creating a new chat message.

To support this, the `getContextFileFromSelection` function is now imported and used in `SimpleChatPanelProvider.ts`. If the chat message source is 'chat', the current selection context is retrieved and added to the `userContextFiles` array before resolving the context items.

The selection context retrieval logic is also removed from `getPriorityContext` in `context.ts` since it is now handled in `SimpleChatPanelProvider.ts`.
@abeatrix abeatrix requested review from jtibshirani and a team May 24, 2024 21:51
Copy link
Member

@jtibshirani jtibshirani left a comment

Choose a reason for hiding this comment

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

It makes sense to me to always include the selection, and count it towards the "user-supplied context" budget.

This change looks good to me, but someone from Cody should review too :)

CC @chillatom since you're leading the charge on the enhanced context changes for the next release!

@abeatrix abeatrix requested a review from a team May 24, 2024 23:22
@abeatrix abeatrix merged commit 6bfefaf into main May 27, 2024
19 checks passed
@abeatrix abeatrix deleted the bee/add-selection branch May 27, 2024 02:34
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