Skip to content

Commit c75b13b

Browse files
authored
implement vscode#268089 (#7849)
* implement microsoft/vscode#268089 * creating from outside a chat session
1 parent c031311 commit c75b13b

File tree

5 files changed

+154
-258
lines changed

5 files changed

+154
-258
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"activeComment",
1515
"chatParticipantAdditions",
1616
"chatParticipantPrivate",
17-
"chatSessionsProvider",
17+
"chatSessionsProvider@2",
1818
"codiconDecoration",
1919
"codeActionRanges",
2020
"commentingRangeHint",

src/@types/vscode.proposed.chatSessionsProvider.d.ts

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
* Licensed under the MIT License. See License.txt in the project root for license information.
44
*--------------------------------------------------------------------------------------------*/
55

6+
// version: 2
7+
68
declare module 'vscode' {
79
/**
810
* Represents the status of a chat session.
@@ -34,6 +36,13 @@ declare module 'vscode' {
3436
readonly onDidChangeChatSessionItems: Event<void>;
3537

3638
/**
39+
* Event that the provider can fire to signal that the current (original) chat session should be replaced with a new (modified) chat session.
40+
* The UI can use this information to gracefully migrate the user to the new session.
41+
*/
42+
readonly onDidCommitChatSessionItem: Event<{ original: ChatSessionItem /** untitled */; modified: ChatSessionItem /** newly created */ }>;
43+
44+
/**
45+
* DEPRECATED: Will be removed!
3746
* Creates a new chat session.
3847
*
3948
* @param options Options for the new session including an optional initial prompt and history
@@ -46,16 +55,6 @@ declare module 'vscode' {
4655
*/
4756
readonly request: ChatRequest;
4857

49-
/**
50-
* Initial prompt to initiate the session
51-
*/
52-
readonly prompt?: string;
53-
54-
/**
55-
* History to initialize the session with
56-
*/
57-
readonly history?: ReadonlyArray<ChatRequestTurn | ChatResponseTurn>;
58-
5958
/**
6059
* Additional metadata to use for session creation
6160
*/
@@ -190,7 +189,16 @@ declare module 'vscode' {
190189
*
191190
* @returns A disposable that unregisters the provider when disposed.
192191
*/
193-
export function registerChatSessionContentProvider(chatSessionType: string, provider: ChatSessionContentProvider, capabilities?: ChatSessionCapabilities): Disposable;
192+
export function registerChatSessionContentProvider(chatSessionType: string, provider: ChatSessionContentProvider, chatParticipant: ChatParticipant, capabilities?: ChatSessionCapabilities): Disposable;
193+
}
194+
195+
export interface ChatContext {
196+
readonly chatSessionContext?: ChatSessionContext;
197+
}
198+
199+
export interface ChatSessionContext {
200+
readonly chatSessionItem: ChatSessionItem; // Maps to URI of chat session editor (could be 'untitled-1', etc..)
201+
readonly isUntitled: boolean;
194202
}
195203

196204
export interface ChatSessionCapabilities {

src/extension.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,11 @@ async function deferredActivate(context: vscode.ExtensionContext, showPRControll
420420
const copilotRemoteAgentManager = new CopilotRemoteAgentManager(credentialStore, reposManager, telemetry, context, apiImpl);
421421
context.subscriptions.push(copilotRemoteAgentManager);
422422
if (vscode.chat?.registerChatSessionItemProvider) {
423+
const chatParticipant = vscode.chat.createChatParticipant(COPILOT_SWE_AGENT, async (request, context, stream, token) =>
424+
await copilotRemoteAgentManager.chatParticipantImpl(request, context, stream, token)
425+
);
426+
context.subscriptions.push(chatParticipant);
427+
423428
const provider = new class implements vscode.ChatSessionContentProvider, vscode.ChatSessionItemProvider {
424429
label = vscode.l10n.t('GitHub Copilot Coding Agent');
425430
provideChatSessionItems = async (token) => {
@@ -429,9 +434,7 @@ async function deferredActivate(context: vscode.ExtensionContext, showPRControll
429434
return await copilotRemoteAgentManager.provideChatSessionContent(id, token);
430435
};
431436
onDidChangeChatSessionItems = copilotRemoteAgentManager.onDidChangeChatSessions;
432-
provideNewChatSessionItem = async (options: { readonly request: vscode.ChatRequest; prompt?: string; history: ReadonlyArray<vscode.ChatRequestTurn | vscode.ChatResponseTurn>; metadata?: any; }, token: vscode.CancellationToken): Promise<vscode.ChatSessionItem> => {
433-
return await copilotRemoteAgentManager.provideNewChatSessionItem(options, token);
434-
};
437+
onDidCommitChatSessionItem = copilotRemoteAgentManager.onDidCommitChatSession;
435438
}();
436439

437440
context.subscriptions.push(vscode.chat?.registerChatSessionItemProvider(
@@ -442,7 +445,8 @@ async function deferredActivate(context: vscode.ExtensionContext, showPRControll
442445
context.subscriptions.push(vscode.chat?.registerChatSessionContentProvider(
443446
COPILOT_SWE_AGENT,
444447
provider,
445-
{ supportsInterruptions: true, }
448+
chatParticipant,
449+
{ supportsInterruptions: true }
446450
));
447451
}
448452

src/github/copilotApi.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,6 @@ export interface ChatSessionWithPR extends vscode.ChatSessionItem {
4646
pullRequest: PullRequestModel;
4747
}
4848

49-
export interface ChatSessionFromSummarizedChat extends vscode.ChatSessionItem {
50-
prompt: string;
51-
summary?: string;
52-
// Cache
53-
pullRequest?: PullRequestModel;
54-
sessionInfo?: SessionInfo;
55-
}
56-
5749
export class CopilotApi {
5850
protected static readonly ID = 'copilotApi';
5951

0 commit comments

Comments
 (0)