Skip to content
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
1 change: 0 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
// --- Chat ---
"inlineChat.enableV2": true,
"inlineChat.affordance": "editor",
"chat.tools.terminal.autoApprove": {
"scripts/test.bat": true,
Expand Down
59 changes: 1 addition & 58 deletions extensions/copilot/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -1473,64 +1473,7 @@
"locations": [
"editor"
],
"commands": [
{
"name": "generate",
"when": "!config.inlineChat.enableV2",
"description": "%copilot.workspace.generate.description%",
"disambiguation": [
{
"category": "generate",
"description": "Generate new code",
"examples": [
"Add a function that returns the sum of two numbers"
]
}
]
},
{
"name": "edit",
"when": "!config.inlineChat.enableV2",
"description": "%copilot.workspace.edit.inline.description%",
"disambiguation": [
{
"category": "edit",
"description": "Make changes to existing code",
"examples": [
"Change this method to use async/await"
]
}
]
},
{
"name": "fix",
"when": "!config.inlineChat.enableV2",
"description": "%copilot.workspace.fix.description%",
"disambiguation": [
{
"category": "fix",
"description": "Propose a fix for the problems in the selected code",
"examples": [
"There is a problem in this code. Rewrite the code to show it with the bug fixed."
]
}
]
},
{
"name": "tests",
"when": "!config.inlineChat.enableV2",
"description": "%copilot.workspace.tests.description%",
"disambiguation": [
{
"category": "tests",
"description": "Generate unit tests for the selected code. The user does not want to fix their existing tests.",
"examples": [
"Write a set of detailed unit test functions for the code above."
]
}
]
}
]
"commands": []
},
{
"id": "github.copilot.editsAgent",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,16 @@ import { isNonEmptyArray } from '../../../util/vs/base/common/arrays';
import { timeout } from '../../../util/vs/base/common/async';
import { CancellationToken } from '../../../util/vs/base/common/cancellation';
import { ResourceSet } from '../../../util/vs/base/common/map';
import { isFalsyOrWhitespace } from '../../../util/vs/base/common/strings';
import { assertType, isDefined } from '../../../util/vs/base/common/types';
import { IInstantiationService } from '../../../util/vs/platform/instantiation/common/instantiation';
import { ChatRequestEditorData, ChatResponseTextEditPart, LanguageModelTextPart, LanguageModelToolResult } from '../../../vscodeTypes';
import { Intent } from '../../common/constants';
import { getAgentTools } from '../../intents/node/agentIntent';
import { IIntentService } from '../../intents/node/intentService';
import { ChatVariablesCollection } from '../../prompt/common/chatVariablesCollection';
import { Conversation, Turn } from '../../prompt/common/conversation';
import { Conversation } from '../../prompt/common/conversation';
import { IToolCall } from '../../prompt/common/intents';
import { ToolCallRound } from '../../prompt/common/toolCallRound';
import { ChatTelemetryBuilder, InlineChatTelemetry } from '../../prompt/node/chatParticipantTelemetry';
import { DefaultIntentRequestHandler } from '../../prompt/node/defaultIntentRequestHandler';
import { IDocumentContext } from '../../prompt/node/documentContext';
import { IIntent } from '../../prompt/node/intents';
import { PromptRenderer } from '../../prompts/node/base/promptRenderer';
Expand Down Expand Up @@ -79,8 +76,6 @@ export class InlineChatIntent implements IIntent {
@IToolsService private readonly _toolsService: IToolsService,
@IIgnoreService private readonly _ignoreService: IIgnoreService,
@IEditSurvivalTrackerService private readonly _editSurvivalTrackerService: IEditSurvivalTrackerService,
@IIntentService private readonly _intentService: IIntentService,
@IConfigurationService private readonly _configurationService: IConfigurationService,
@IOctoKitService private readonly _octoKitService: IOctoKitService,
) {
this._progressMessages = this._instantiationService.createInstance(InlineChatProgressMessages);
Expand Down Expand Up @@ -109,71 +104,6 @@ export class InlineChatIntent implements IIntent {
};
}

const enableV2 = this._configurationService.getNonExtensionConfig<boolean>('inlineChat.enableV2');

if (!enableV2) {
// OLD world
return this._handleRequestWithOldWorld(conversation, request, stream, token, documentContext, chatTelemetry);
}

return this._handleRequestWithNewWorld(endpoint, conversation, request, stream, token, documentContext, chatTelemetry);
}

// --- OLD world

private async _handleRequestWithOldWorld(conversation: Conversation, request: vscode.ChatRequest, stream: vscode.ChatResponseStream, token: CancellationToken, documentContext: IDocumentContext, chatTelemetry: ChatTelemetryBuilder): Promise<vscode.ChatResult> {
// OLD world
let didEmitEdits = false;
stream = ChatResponseStreamImpl.spy(stream, part => {
if (part instanceof ChatResponseTextEditPart) {
didEmitEdits = true;
}
});

const intent = await this._selectIntent(conversation.turns, documentContext, request);

if (isFalsyOrWhitespace(request.prompt)) {
request = { ...request, prompt: intent.description };
}

const handler = this._instantiationService.createInstance(DefaultIntentRequestHandler, intent, conversation, request, stream, token, documentContext, ChatLocation.Editor, chatTelemetry, undefined, undefined);
const result = await handler.getResult();

if (!didEmitEdits && !result.errorDetails) {
// BAILOUT: when no edits were emitted, invoke the exit tool manually
await this._toolsService.invokeTool(INLINE_CHAT_EXIT_TOOL_NAME, { toolInvocationToken: request.toolInvocationToken, input: undefined }, token);
}
return result;
}

private async _selectIntent(history: readonly Turn[], documentContext: IDocumentContext, request: vscode.ChatRequest): Promise<IIntent> {

if (request.command) {
const result = this._intentService.getIntent(request.command, ChatLocation.Editor);
if (result) {
return result;
}
}

let preferredIntent: Intent | undefined;
if (documentContext && request.attempt === 0 && history.length === 1) {
if (documentContext.selection.isEmpty && documentContext.document.lineAt(documentContext.selection.start.line).text.trim() === '') {
preferredIntent = Intent.Generate;
} else if (!documentContext.selection.isEmpty && documentContext.selection.start.line !== documentContext.selection.end.line) {
preferredIntent = Intent.Edit;
}
}
if (preferredIntent) {
return this._intentService.getIntent(preferredIntent, ChatLocation.Editor) ?? this._intentService.unknownIntent;
}
return this._intentService.unknownIntent;
}

// --- NEW world

private async _handleRequestWithNewWorld(endpoint: IChatEndpoint, conversation: Conversation, request: vscode.ChatRequest, stream: vscode.ChatResponseStream, token: CancellationToken, documentContext: IDocumentContext, chatTelemetry: ChatTelemetryBuilder): Promise<vscode.ChatResult> {
assertType(request.location2 instanceof ChatRequestEditorData);
assertType(documentContext);

const editSurvivalTracker = this._editSurvivalTrackerService.initialize(request.location2.document);

Expand Down
11 changes: 1 addition & 10 deletions extensions/copilot/src/extension/prompt/node/intentDetector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import { BasePromptElementProps, PromptElement, PromptElementProps, PromptMetadata, Raw, SystemMessage, UserMessage } from '@vscode/prompt-tsx';
import type { CancellationToken, ChatContext, ChatParticipantDetectionProvider, ChatParticipantDetectionResult, ChatParticipantMetadata, ChatRequest, Uri, ChatLocation as VscodeChatLocation } from 'vscode';
import { CHAT_PARTICIPANT_ID_PREFIX, editingSessionAgentEditorName, getChatParticipantIdFromName } from '../../../platform/chat/common/chatAgents';
import { CHAT_PARTICIPANT_ID_PREFIX, getChatParticipantIdFromName } from '../../../platform/chat/common/chatAgents';
import { ChatFetchResponseType, ChatLocation, ChatResponse } from '../../../platform/chat/common/commonTypes';
import { getTextPart, roleToString } from '../../../platform/chat/common/globalStringUtils';
import { ConfigKey, IConfigurationService } from '../../../platform/configuration/common/configurationService';
Expand Down Expand Up @@ -347,15 +347,6 @@ export class IntentDetector implements ChatParticipantDetectionProvider {
}
}

if (location === ChatLocation.Editor
&& !this.configurationService.getNonExtensionConfig('inlineChat.enableV2')
&& chosenIntent !== Intent.InlineChat
) {
return {
command: chosenIntent,
participant: getChatParticipantIdFromName(editingSessionAgentEditorName)
};
}

if (baseUserTelemetry) {
const promptTelemetryData = baseUserTelemetry.extendedBy({
Expand Down
4 changes: 2 additions & 2 deletions extensions/copilot/test/inline/fixing.stest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ import { Intent } from '../../src/extension/common/constants';
import '../../src/extension/intents/node/allIntents';
import { ssuite, stest } from '../base/stest';
import { KnownDiagnosticProviders } from '../simulation/diagnosticProviders';
import { forInlineAndInlineChatIntent, simulateInlineChatWithStrategy } from '../simulation/inlineChatSimulator';
import { forInlineChatIntent, simulateInlineChatWithStrategy } from '../simulation/inlineChatSimulator';
import { assertLessDiagnosticsAsync, assertNoDiagnosticsAsync, getWorkspaceDiagnostics } from '../simulation/outcomeValidators';
import { assertConversationalOutcome, assertInlineEdit, assertNoOccurrence, assertOccursOnce, fromFixture, toFile } from '../simulation/stestUtil';


forInlineAndInlineChatIntent((strategy, nonExtensionConfigurations, suffix) => {
forInlineChatIntent((strategy, nonExtensionConfigurations, suffix) => {

ssuite({ title: `fix${suffix}`, subtitle: 'ruff', location: 'inline' }, () => {
stest({ description: `Ruff(E231) Missing whitespace after ':'`, language: 'python', nonExtensionConfigurations }, (testingServiceCollection) => {
Expand Down
7 changes: 3 additions & 4 deletions extensions/copilot/test/inline/inlineEditCode.stest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,11 @@ function executeEditTest(
}
}

function forInlineAndInlineChatIntent(callback: (strategy: EditTestStrategy, location: 'inline' | 'panel', variant: string | undefined, configurations?: NonExtensionConfiguration[]) => void): void {
callback(EditTestStrategy.Inline, 'inline', '', undefined);
callback(EditTestStrategy.InlineChatIntent, 'inline', '-InlineChatIntent', [['inlineChat.enableV2', true], ['chat.agent.autoFix', false]]);
function forInlineChatIntent(callback: (strategy: EditTestStrategy, location: 'inline' | 'panel', variant: string | undefined, configurations?: NonExtensionConfiguration[]) => void): void {
callback(EditTestStrategy.InlineChatIntent, 'inline', '-InlineChatIntent', [['chat.agent.autoFix', false]]);
}

forInlineAndInlineChatIntent((strategy, location, variant, nonExtensionConfigurations) => {
forInlineChatIntent((strategy, location, variant, nonExtensionConfigurations) => {

ssuite({ title: `edit${variant}`, location }, () => {
stest({ description: 'Context Outline: TypeScript between methods', language: 'typescript', nonExtensionConfigurations }, (testingServiceCollection) => {
Expand Down
7 changes: 3 additions & 4 deletions extensions/copilot/test/inline/inlineGenerateCode.stest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,11 @@ function executeEditTestStrategy(
}
}

function forInlineAndInlineChatIntent(callback: (strategy: EditTestStrategy, variant: '-InlineChatIntent' | '', nonExtensionConfigurations?: NonExtensionConfiguration[]) => void): void {
callback(EditTestStrategy.Inline, '', undefined);
callback(EditTestStrategy.InlineChatIntent, '-InlineChatIntent', [['inlineChat.enableV2', true], ['chat.agent.autoFix', false]]);
function forInlineChatIntent(callback: (strategy: EditTestStrategy, variant: '-InlineChatIntent', nonExtensionConfigurations?: NonExtensionConfiguration[]) => void): void {
callback(EditTestStrategy.InlineChatIntent, '-InlineChatIntent', [['chat.agent.autoFix', false]]);
}

forInlineAndInlineChatIntent((strategy, variant, nonExtensionConfigurations) => {
forInlineChatIntent((strategy, variant, nonExtensionConfigurations) => {

ssuite({ title: `generate${variant}`, location: 'inline' }, () => {
stest({ description: 'gen-ts-ltrim', language: 'typescript', nonExtensionConfigurations }, (testingServiceCollection) => {
Expand Down
3 changes: 1 addition & 2 deletions extensions/copilot/test/outcome/-tests-inline.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@
{
"name": "/tests [inline] [js] - issue #1261: Failed to create new test file when in an untitled file",
"requests": [
"3ff8d64fed825b20d0fb3ada0c4dc880477bc82580a2ece057b9de9f4ad29995",
"4bb3317b9d74ae64f5b2d006a0b7c90fd9d501c20dacc411023860883ed0aecc"
"59b8750686db284d87c0ab2f385eb6a593f939296b42d895fda731b30084eece"
]
},
{
Expand Down
12 changes: 4 additions & 8 deletions extensions/copilot/test/outcome/-tests-real-world-inline.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,29 +8,25 @@
{
"name": "/tests (real world) [inline] [typescript] - add another test for containsUppercaseCharacter with other non latin chars",
"requests": [
"31032a78e3858810de4f26625f84210ee84c9a9dc5e30d0d2b7b5d314074fe7c",
"4a380419eacdcf047e45478f4cc61a35961c56c993cc30ad7c7836f74580046e"
"31032a78e3858810de4f26625f84210ee84c9a9dc5e30d0d2b7b5d314074fe7c"
]
},
{
"name": "/tests (real world) [inline] [typescript] - generate a unit test",
"requests": [
"06c4be5d76877ee10242f9578b5cde4a215d743a5e658213bc165860ebb5aae1",
"91f4cd921642732fa20af80b1e53288bd3d9518df39a6d9a9e8ef3c6da1f5633"
"5925599e184809bb553c5dd0d3be503cfe89fa479b3fa342472f210790a2f839"
]
},
{
"name": "/tests (real world) [inline] [typescript] - issue #3699: add test for function",
"requests": [
"6b83bb554c4c05d65c7e5b94d9a8f7d84bc29785db46bb129f592de99f8c6f76",
"c6a9939626574472a09fee16025fbe701ef3146377d3b20101d9ec58b9cce3ea"
"8d3fbfd87a95cf2b7ea55d16bbdee81948d5f9b6f7deda07609ddefa6751e952"
]
},
{
"name": "/tests (real world) [inline] [typescript] - issue #3701: add some more tests for folding",
"requests": [
"9fc1ca3d160530b2703dc7ae5a3838d965aa36a2d45dc0cee199e1d4a6122d1b",
"f877475232558f704cbb4de3d40b537776726a959e3bfa44d34c3bc97ee7865a"
"fb778bd2353aa4fb54e01e8f8a1187a30720ad5bff8398f3677e465cfd429a1a"
]
}
]
Loading
Loading