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
22 changes: 16 additions & 6 deletions src/vs/workbench/api/browser/mainThreadChatSessions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,17 +120,27 @@ export class ObservableChatSession extends Disposable implements ChatSession {

if (sessionContent.hasActiveResponseCallback && !this.interruptActiveResponseCallback) {
this.interruptActiveResponseCallback = async () => {
const confirmInterrupt = () => {
if (this._disposalPending) {
this._proxy.$disposeChatSessionContent(this._providerHandle, this.sessionId);
this._disposalPending = false;
}
this._proxy.$interruptChatSessionActiveResponse(this._providerHandle, this.sessionId, 'ongoing');
return true;
};

if (sessionContent.supportsInterruption) {
// If the session supports hot reload, interrupt without confirmation
return confirmInterrupt();
}

// Prompt the user to confirm interruption
return this._dialogService.confirm({
message: localize('interruptActiveResponse', 'Are you sure you want to interrupt the active session?')
}).then(confirmed => {
if (confirmed.confirmed) {
// User confirmed interruption - dispose the session content on extension host
if (this._disposalPending) {
this._proxy.$disposeChatSessionContent(this._providerHandle, this.sessionId);
this._disposalPending = false;
}
this._proxy.$interruptChatSessionActiveResponse(this._providerHandle, this.sessionId, 'ongoing');
return true;
return confirmInterrupt();
} else {
// When user cancels the interruption, fire an empty progress message to keep the session alive
// This matches the behavior of the old implementation
Expand Down
4 changes: 2 additions & 2 deletions src/vs/workbench/api/common/extHost.api.impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1518,9 +1518,9 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I
checkProposedApiEnabled(extension, 'chatSessionsProvider');
return extHostChatSessions.registerChatSessionItemProvider(extension, chatSessionType, provider);
},
registerChatSessionContentProvider(chatSessionType: string, provider: vscode.ChatSessionContentProvider) {
registerChatSessionContentProvider(chatSessionType: string, provider: vscode.ChatSessionContentProvider, capabilities?: vscode.ChatSessionCapabilities) {
checkProposedApiEnabled(extension, 'chatSessionsProvider');
return extHostChatSessions.registerChatSessionContentProvider(extension, chatSessionType, provider);
return extHostChatSessions.registerChatSessionContentProvider(extension, chatSessionType, provider, capabilities);
},
registerChatOutputRenderer: (viewType: string, renderer: vscode.ChatOutputRenderer) => {
checkProposedApiEnabled(extension, 'chatOutputRenderer');
Expand Down
1 change: 1 addition & 0 deletions src/vs/workbench/api/common/extHost.protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3145,6 +3145,7 @@ export interface ChatSessionDto {
history: Array<IChatSessionHistoryItemDto>;
hasActiveResponseCallback: boolean;
hasRequestHandler: boolean;
supportsInterruption: boolean;
}


Expand Down
8 changes: 5 additions & 3 deletions src/vs/workbench/api/common/extHostChatSessions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ export class ExtHostChatSessions extends Disposable implements ExtHostChatSessio
private readonly _chatSessionContentProviders = new Map<number, {
readonly provider: vscode.ChatSessionContentProvider;
readonly extension: IExtensionDescription;
readonly capabilities?: vscode.ChatSessionCapabilities;
readonly disposable: DisposableStore;
}>();
private _nextChatSessionItemProviderHandle = 0;
Expand Down Expand Up @@ -110,11 +111,11 @@ export class ExtHostChatSessions extends Disposable implements ExtHostChatSessio
};
}

registerChatSessionContentProvider(extension: IExtensionDescription, chatSessionType: string, provider: vscode.ChatSessionContentProvider): vscode.Disposable {
registerChatSessionContentProvider(extension: IExtensionDescription, chatSessionType: string, provider: vscode.ChatSessionContentProvider, capabilities?: vscode.ChatSessionCapabilities): vscode.Disposable {
const handle = this._nextChatSessionContentProviderHandle++;
const disposables = new DisposableStore();

this._chatSessionContentProviders.set(handle, { provider, extension, disposable: disposables });
this._chatSessionContentProviders.set(handle, { provider, extension, capabilities, disposable: disposables });
this._proxy.$registerChatSessionContentProvider(handle, chatSessionType);

return new extHostTypes.Disposable(() => {
Expand Down Expand Up @@ -243,11 +244,12 @@ export class ExtHostChatSessions extends Disposable implements ExtHostChatSessio
this._proxy.$handleProgressComplete(handle, id, 'ongoing');
});
}

const { capabilities } = provider;
return {
id: sessionId + '',
hasActiveResponseCallback: !!session.activeResponseCallback,
hasRequestHandler: !!session.requestHandler,
supportsInterruption: !!capabilities?.supportsInterruptions,
history: session.history.map(turn => {
if (turn instanceof extHostTypes.ChatRequestTurn) {
return { type: 'request' as const, prompt: turn.prompt, participant: turn.participant };
Expand Down
10 changes: 8 additions & 2 deletions src/vscode-dts/vscode.proposed.chatSessionsProvider.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ declare module 'vscode' {
}

export interface ChatSession {

/**
* The full history of the session
*
Expand Down Expand Up @@ -171,7 +170,14 @@ declare module 'vscode' {
*
* @returns A disposable that unregisters the provider when disposed.
*/
export function registerChatSessionContentProvider(chatSessionType: string, provider: ChatSessionContentProvider): Disposable;
export function registerChatSessionContentProvider(chatSessionType: string, provider: ChatSessionContentProvider, capabilities?: ChatSessionCapabilities): Disposable;
}

export interface ChatSessionCapabilities {
/**
* Whether sessions can be interrupted and resumed without side-effects.
*/
supportsInterruptions?: boolean;
}

export interface ChatSessionShowOptions {
Expand Down
Loading