Skip to content

Commit 9824285

Browse files
authored
Revert "Pass through the initial options on creation"
1 parent 09f4d8c commit 9824285

File tree

7 files changed

+17
-59
lines changed

7 files changed

+17
-59
lines changed

src/vs/workbench/api/browser/mainThreadChatSessions.ts

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ import { IEditorGroupsService } from '../../services/editor/common/editorGroupsS
3535
import { IEditorService } from '../../services/editor/common/editorService.js';
3636
import { extHostNamedCustomer, IExtHostContext } from '../../services/extensions/common/extHostCustomers.js';
3737
import { Dto } from '../../services/extensions/common/proxyIdentifier.js';
38-
import { ChatSessionContentContextDto, ExtHostChatSessionsShape, ExtHostContext, IChatProgressDto, IChatSessionHistoryItemDto, IChatSessionItemsChange, MainContext, MainThreadChatSessionsShape } from '../common/extHost.protocol.js';
38+
import { ExtHostChatSessionsShape, ExtHostContext, IChatProgressDto, IChatSessionHistoryItemDto, IChatSessionItemsChange, MainContext, MainThreadChatSessionsShape } from '../common/extHost.protocol.js';
3939

4040
export class ObservableChatSession extends Disposable implements IChatSession {
4141

@@ -99,17 +99,17 @@ export class ObservableChatSession extends Disposable implements IChatSession {
9999
this._dialogService = dialogService;
100100
}
101101

102-
initialize(token: CancellationToken, context?: ChatSessionContentContextDto): Promise<void> {
102+
initialize(token: CancellationToken): Promise<void> {
103103
if (!this._initializationPromise) {
104-
this._initializationPromise = this._doInitializeContent(token, context);
104+
this._initializationPromise = this._doInitializeContent(token);
105105
}
106106
return this._initializationPromise;
107107
}
108108

109-
private async _doInitializeContent(token: CancellationToken, context?: ChatSessionContentContextDto): Promise<void> {
109+
private async _doInitializeContent(token: CancellationToken): Promise<void> {
110110
try {
111111
const sessionContent = await raceCancellationError(
112-
this._proxy.$provideChatSessionContent(this._providerHandle, this.sessionResource, token, context),
112+
this._proxy.$provideChatSessionContent(this._providerHandle, this.sessionResource, token),
113113
token
114114
);
115115

@@ -668,10 +668,7 @@ export class MainThreadChatSessions extends Disposable implements MainThreadChat
668668
}
669669

670670
try {
671-
const initialSessionOptions = this._chatSessionsService.getSessionOptions(sessionResource);
672-
await session.initialize(token, initialSessionOptions ? {
673-
initialSessionOptions: [...initialSessionOptions].map(([optionId, value]) => ({ optionId, value }))
674-
} : undefined);
671+
await session.initialize(token);
675672
if (session.options) {
676673
for (const [_, handle] of this._sessionTypeToHandle) {
677674
if (handle === providerHandle) {

src/vs/workbench/api/common/extHost.protocol.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3587,10 +3587,6 @@ export interface ChatSessionOptionUpdateDto2 {
35873587
readonly value: string | IChatSessionProviderOptionItem;
35883588
}
35893589

3590-
export interface ChatSessionContentContextDto {
3591-
readonly initialSessionOptions?: ReadonlyArray<{ optionId: string; value: string }>;
3592-
}
3593-
35943590
export interface ChatSessionDto {
35953591
id: string;
35963592
resource: UriComponents;
@@ -3633,7 +3629,7 @@ export interface ExtHostChatSessionsShape {
36333629
$onDidChangeChatSessionItemState(providerHandle: number, sessionResource: UriComponents, archived: boolean): void;
36343630
$newChatSessionItem(controllerHandle: number, request: IChatNewSessionRequest, token: CancellationToken): Promise<Dto<IChatSessionItem> | undefined>;
36353631

3636-
$provideChatSessionContent(providerHandle: number, sessionResource: UriComponents, token: CancellationToken, context?: ChatSessionContentContextDto): Promise<ChatSessionDto>;
3632+
$provideChatSessionContent(providerHandle: number, sessionResource: UriComponents, token: CancellationToken): Promise<ChatSessionDto>;
36373633
$interruptChatSessionActiveResponse(providerHandle: number, sessionResource: UriComponents, requestId: string): Promise<void>;
36383634
$disposeChatSessionContent(providerHandle: number, sessionResource: UriComponents): Promise<void>;
36393635
$invokeChatSessionRequestHandler(providerHandle: number, sessionResource: UriComponents, request: IChatAgentRequest, history: any[], token: CancellationToken): Promise<IChatAgentResult>;

src/vs/workbench/api/common/extHostChatSessions.ts

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import { IChatNewSessionRequest, IChatSessionProviderOptionItem } from '../../co
2222
import { ChatAgentLocation } from '../../contrib/chat/common/constants.js';
2323
import { IChatAgentRequest, IChatAgentResult } from '../../contrib/chat/common/participants/chatAgents.js';
2424
import { Proxied } from '../../services/extensions/common/proxyIdentifier.js';
25-
import { ChatSessionContentContextDto, ChatSessionDto, ExtHostChatSessionsShape, IChatAgentProgressShape, IChatSessionProviderOptions, MainContext, MainThreadChatSessionsShape } from './extHost.protocol.js';
25+
import { ChatSessionDto, ExtHostChatSessionsShape, IChatAgentProgressShape, IChatSessionProviderOptions, MainContext, MainThreadChatSessionsShape } from './extHost.protocol.js';
2626
import { ChatAgentResponseStream } from './extHostChatAgents2.js';
2727
import { CommandsConverter, ExtHostCommands } from './extHostCommands.js';
2828
import { ExtHostLanguageModels } from './extHostLanguageModels.js';
@@ -499,17 +499,15 @@ export class ExtHostChatSessions extends Disposable implements ExtHostChatSessio
499499
});
500500
}
501501

502-
async $provideChatSessionContent(handle: number, sessionResourceComponents: UriComponents, token: CancellationToken, context?: ChatSessionContentContextDto): Promise<ChatSessionDto> {
502+
async $provideChatSessionContent(handle: number, sessionResourceComponents: UriComponents, token: CancellationToken): Promise<ChatSessionDto> {
503503
const provider = this._chatSessionContentProviders.get(handle);
504504
if (!provider) {
505505
throw new Error(`No provider for handle ${handle}`);
506506
}
507507

508508
const sessionResource = URI.revive(sessionResourceComponents);
509509

510-
const session = await provider.provider.provideChatSessionContent(sessionResource, token, {
511-
sessionOptions: context?.initialSessionOptions ?? []
512-
});
510+
const session = await provider.provider.provideChatSessionContent(sessionResource, token);
513511
if (token.isCancellationRequested) {
514512
throw new CancellationError();
515513
}
@@ -787,13 +785,7 @@ export class ExtHostChatSessions extends Disposable implements ExtHostChatSessio
787785
return undefined;
788786
}
789787

790-
const item = await handler({
791-
request: {
792-
prompt: request.prompt,
793-
command: request.command
794-
},
795-
sessionOptions: request.initialSessionOptions ?? [],
796-
}, token);
788+
const item = await handler({ request: { prompt: request.prompt, command: request.command } }, token);
797789
if (!item) {
798790
return undefined;
799791
}

src/vs/workbench/api/test/browser/mainThreadChatSessions.test.ts

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -197,25 +197,6 @@ suite('ObservableChatSession', function () {
197197
assert.ok((proxy.$provideChatSessionContent as sinon.SinonStub).calledOnce);
198198
});
199199

200-
test('initialization forwards initial session options context', async function () {
201-
const sessionId = 'test-id';
202-
const resource = LocalChatSessionUri.forSession(sessionId);
203-
const session = disposables.add(new ObservableChatSession(resource, 1, proxy, logService, dialogService));
204-
const initialSessionOptions = [{ optionId: 'model', value: 'gpt-4.1' }];
205-
206-
const sessionContent = createSessionContent();
207-
(proxy.$provideChatSessionContent as sinon.SinonStub).resolves(sessionContent);
208-
209-
await session.initialize(CancellationToken.None, { initialSessionOptions });
210-
211-
assert.ok((proxy.$provideChatSessionContent as sinon.SinonStub).calledOnceWith(
212-
1,
213-
resource,
214-
CancellationToken.None,
215-
{ initialSessionOptions }
216-
));
217-
});
218-
219200
test('progress handling works correctly after initialization', async function () {
220201
const sessionContent = createSessionContent();
221202
const session = disposables.add(await createInitializedSession(sessionContent));

src/vs/workbench/contrib/chat/common/chatService/chatServiceImpl.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -824,14 +824,13 @@ export class ChatService extends Disposable implements IChatService {
824824
const parsedRequest = this.parseChatRequest(sessionResource, request, options?.location ?? model.initialLocation, options);
825825
const commandPart = parsedRequest.parts.find((r): r is ChatRequestSlashCommandPart => r instanceof ChatRequestSlashCommandPart);
826826
const requestText = getPromptText(parsedRequest).message;
827+
const newItem = await this.chatSessionService.createNewChatSessionItem(getChatSessionType(sessionResource), { prompt: requestText, command: commandPart?.text }, CancellationToken.None);
828+
if (newItem) {
827829

828-
// Capture session options before loading the remote session,
829-
// since the alias registration below may change the lookup.
830-
const sessionOptions = this.chatSessionService.getSessionOptions(sessionResource);
831-
const initialSessionOptions = sessionOptions ? [...sessionOptions].map(([optionId, value]) => ({ optionId, value })) : undefined;
830+
// Capture session options before loading the remote session,
831+
// since the alias registration below may change the lookup.
832+
const sessionOptions = this.chatSessionService.getSessionOptions(sessionResource);
832833

833-
const newItem = await this.chatSessionService.createNewChatSessionItem(getChatSessionType(sessionResource), { prompt: requestText, command: commandPart?.text, initialSessionOptions }, CancellationToken.None);
834-
if (newItem) {
835834
model = (await this.loadRemoteSession(newItem.resource, model.initialLocation, CancellationToken.None))?.object as ChatModel | undefined;
836835
if (!model) {
837836
throw new Error(`Failed to load session for resource: ${newItem.resource}`);

src/vs/workbench/contrib/chat/common/chatSessionsService.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,8 +196,6 @@ export interface IChatSessionContentProvider {
196196
export interface IChatNewSessionRequest {
197197
readonly prompt: string;
198198
readonly command?: string;
199-
200-
readonly initialSessionOptions?: ReadonlyArray<{ optionId: string; value: string | IChatSessionProviderOptionItem }>;
201199
}
202200

203201
export interface IChatSessionItemsDelta {

src/vscode-dts/vscode.proposed.chatSessionsProvider.d.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,6 @@ declare module 'vscode' {
9999
readonly prompt: string;
100100
readonly command?: string;
101101
};
102-
103-
readonly sessionOptions: ReadonlyArray<{ optionId: string; value: string | ChatSessionProviderOptionItem }>;
104102
}
105103

106104
/**
@@ -449,13 +447,10 @@ declare module 'vscode' {
449447
*
450448
* @param resource The URI of the chat session to resolve.
451449
* @param token A cancellation token that can be used to cancel the operation.
452-
* @param context Additional context for the chat session.
453450
*
454451
* @return The {@link ChatSession chat session} associated with the given URI.
455452
*/
456-
provideChatSessionContent(resource: Uri, token: CancellationToken, context: {
457-
readonly sessionOptions: ReadonlyArray<{ optionId: string; value: string | ChatSessionProviderOptionItem }>;
458-
}): Thenable<ChatSession> | ChatSession;
453+
provideChatSessionContent(resource: Uri, token: CancellationToken): Thenable<ChatSession> | ChatSession;
459454

460455
/**
461456
* @param resource Identifier of the chat session being updated.

0 commit comments

Comments
 (0)