Skip to content

Commit

Permalink
Chat: Include editor selection in chat context by default (#4292)
Browse files Browse the repository at this point in the history
  • Loading branch information
abeatrix committed May 27, 2024
1 parent 3a64d2c commit 6bfefaf
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
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 Down Expand Up @@ -37,7 +38,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 @@ -54,7 +55,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

0 comments on commit 6bfefaf

Please sign in to comment.