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
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions vscode/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ This is a log of all notable changes to Cody for VS Code. [Unreleased] changes a
- Enterprise: Adds support for the `completions.smartContext` (available in Sourcegraph v5.5.0+) site configuration. [pull/4236](https://github.com/sourcegraph/cody/pull/4236)
- Chat: Integerated OpenCtx providers with @-mention context menu. [pull/4201](https://github.com/sourcegraph/cody/pull/4201/files)
- Keybinding: Assign the same keyboard shortcut for starting a new chat to the "New Chat with Selection" command.
- Chat: Editor selection is now included in all chats by default. []()

### Fixed

Expand All @@ -36,7 +37,7 @@ This is a log of all notable changes to Cody for VS Code. [Unreleased] changes a

### Added

- Feature flags for the fine-tuning model experiment for code completions. [pull/4245](https://github.com/sourcegraph/cody/pull/4245)
- Feature flags for the fine-tuning model experiment for code completions. [pull/4245](https://github.com/sourcegraph/cody/pull/4245)

### Fixed

Expand All @@ -53,7 +54,6 @@ This is a log of all notable changes to Cody for VS Code. [Unreleased] changes a

### Changed


## [1.18.0]

### Added
Expand Down
7 changes: 5 additions & 2 deletions vscode/src/chat/chat-view/SimpleChatPanelProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ import { captureException } from '@sentry/core'
import type { TelemetryEventParameters } from '@sourcegraph/telemetry'
import type { URI } from 'vscode-uri'
import { getContextFileFromUri } from '../../commands/context/file-path'
import { getContextFileFromCursor } from '../../commands/context/selection'
import { getContextFileFromCursor, getContextFileFromSelection } from '../../commands/context/selection'
import type { EnterpriseContextFactory } from '../../context/enterprise-context-factory'
import type { Repo } from '../../context/repo-fetcher'
import type { RemoteRepoPicker } from '../../context/repo-picker'
Expand Down Expand Up @@ -507,9 +507,12 @@ export class SimpleChatPanelProvider implements vscode.Disposable, ChatSession {

this.postEmptyMessageInProgress()

// Add user's current selection as context for chat messages.
const selectionContext = source === 'chat' ? await getContextFileFromSelection() : []

const userContextItems: ContextItemWithContent[] = await resolveContextItems(
this.editor,
userContextFiles || [],
[...userContextFiles, ...selectionContext],
inputText
)

Expand Down
4 changes: 0 additions & 4 deletions vscode/src/chat/chat-view/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ import {
uriBasename,
wrapInActiveSpan,
} from '@sourcegraph/cody-shared'

import { getContextFileFromSelection } from '../../commands/context/selection'
import type { RemoteSearch } from '../../context/remote-search'
import type { VSCodeEditor } from '../../editor/vscode-editor'
import type { ContextRankingController } from '../../local-context/context-ranking'
Expand Down Expand Up @@ -309,8 +307,6 @@ async function getPriorityContext(
): Promise<ContextItem[]> {
return wrapInActiveSpan('chat.context.priority', async () => {
const priorityContext: ContextItem[] = []
const selectionContext = await getContextFileFromSelection()
priorityContext.push(...selectionContext)
if (needsUserAttentionContext(text)) {
// Query refers to current editor
priorityContext.push(...getVisibleEditorContext(editor))
Expand Down
Loading