diff --git a/vscode/CHANGELOG.md b/vscode/CHANGELOG.md index cb48c19f7f..2c763e42ef 100644 --- a/vscode/CHANGELOG.md +++ b/vscode/CHANGELOG.md @@ -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 @@ -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 @@ -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 diff --git a/vscode/src/chat/chat-view/SimpleChatPanelProvider.ts b/vscode/src/chat/chat-view/SimpleChatPanelProvider.ts index 93331176c1..fc2d3a4fe8 100644 --- a/vscode/src/chat/chat-view/SimpleChatPanelProvider.ts +++ b/vscode/src/chat/chat-view/SimpleChatPanelProvider.ts @@ -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' @@ -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 ) diff --git a/vscode/src/chat/chat-view/context.ts b/vscode/src/chat/chat-view/context.ts index 268dc706bc..7e49f12db1 100644 --- a/vscode/src/chat/chat-view/context.ts +++ b/vscode/src/chat/chat-view/context.ts @@ -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' @@ -309,8 +307,6 @@ async function getPriorityContext( ): Promise { 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))