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
6 changes: 3 additions & 3 deletions src/vs/monaco.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5263,7 +5263,7 @@ declare namespace monaco.editor {
export const EditorOptions: {
acceptSuggestionOnCommitCharacter: IEditorOption<EditorOption.acceptSuggestionOnCommitCharacter, boolean>;
acceptSuggestionOnEnter: IEditorOption<EditorOption.acceptSuggestionOnEnter, 'on' | 'off' | 'smart'>;
accessibilitySupport: IEditorOption<EditorOption.accessibilitySupport, AccessibilitySupport>;
accessibilitySupport: IEditorOption<EditorOption.accessibilitySupport, any>;
accessibilityPageSize: IEditorOption<EditorOption.accessibilityPageSize, number>;
allowOverflow: IEditorOption<EditorOption.allowOverflow, boolean>;
allowVariableLineHeights: IEditorOption<EditorOption.allowVariableLineHeights, boolean>;
Expand Down Expand Up @@ -5326,7 +5326,7 @@ declare namespace monaco.editor {
foldingMaximumRegions: IEditorOption<EditorOption.foldingMaximumRegions, number>;
unfoldOnClickAfterEndOfLine: IEditorOption<EditorOption.unfoldOnClickAfterEndOfLine, boolean>;
fontFamily: IEditorOption<EditorOption.fontFamily, string>;
fontInfo: IEditorOption<EditorOption.fontInfo, FontInfo>;
fontInfo: IEditorOption<EditorOption.fontInfo, any>;
fontLigatures2: IEditorOption<EditorOption.fontLigatures, string>;
fontSize: IEditorOption<EditorOption.fontSize, number>;
fontWeight: IEditorOption<EditorOption.fontWeight, string>;
Expand Down Expand Up @@ -5366,7 +5366,7 @@ declare namespace monaco.editor {
pasteAs: IEditorOption<EditorOption.pasteAs, Readonly<Required<IPasteAsOptions>>>;
parameterHints: IEditorOption<EditorOption.parameterHints, Readonly<Required<IEditorParameterHintOptions>>>;
peekWidgetDefaultFocus: IEditorOption<EditorOption.peekWidgetDefaultFocus, 'tree' | 'editor'>;
placeholder: IEditorOption<EditorOption.placeholder, string>;
placeholder: IEditorOption<EditorOption.placeholder, string | undefined>;
definitionLinkOpensInPeek: IEditorOption<EditorOption.definitionLinkOpensInPeek, boolean>;
quickSuggestions: IEditorOption<EditorOption.quickSuggestions, InternalQuickSuggestionsOptions>;
quickSuggestionsDelay: IEditorOption<EditorOption.quickSuggestionsDelay, number>;
Expand Down
15 changes: 6 additions & 9 deletions src/vs/workbench/api/browser/mainThreadChatSessions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import { IEditorGroupsService } from '../../services/editor/common/editorGroupsS
import { IEditorService } from '../../services/editor/common/editorService.js';
import { extHostNamedCustomer, IExtHostContext } from '../../services/extensions/common/extHostCustomers.js';
import { Dto } from '../../services/extensions/common/proxyIdentifier.js';
import { ChatSessionContentContextDto, ExtHostChatSessionsShape, ExtHostContext, IChatProgressDto, IChatSessionHistoryItemDto, IChatSessionItemsChange, MainContext, MainThreadChatSessionsShape } from '../common/extHost.protocol.js';
import { ExtHostChatSessionsShape, ExtHostContext, IChatProgressDto, IChatSessionHistoryItemDto, IChatSessionItemsChange, MainContext, MainThreadChatSessionsShape } from '../common/extHost.protocol.js';

export class ObservableChatSession extends Disposable implements IChatSession {

Expand Down Expand Up @@ -99,17 +99,17 @@ export class ObservableChatSession extends Disposable implements IChatSession {
this._dialogService = dialogService;
}

initialize(token: CancellationToken, context?: ChatSessionContentContextDto): Promise<void> {
initialize(token: CancellationToken): Promise<void> {
if (!this._initializationPromise) {
this._initializationPromise = this._doInitializeContent(token, context);
this._initializationPromise = this._doInitializeContent(token);
}
return this._initializationPromise;
}

private async _doInitializeContent(token: CancellationToken, context?: ChatSessionContentContextDto): Promise<void> {
private async _doInitializeContent(token: CancellationToken): Promise<void> {
try {
const sessionContent = await raceCancellationError(
this._proxy.$provideChatSessionContent(this._providerHandle, this.sessionResource, token, context),
this._proxy.$provideChatSessionContent(this._providerHandle, this.sessionResource, token),
token
);

Expand Down Expand Up @@ -668,10 +668,7 @@ export class MainThreadChatSessions extends Disposable implements MainThreadChat
}

try {
const initialSessionOptions = this._chatSessionsService.getSessionOptions(sessionResource);
await session.initialize(token, initialSessionOptions ? {
initialSessionOptions: [...initialSessionOptions].map(([optionId, value]) => ({ optionId, value }))
} : undefined);
await session.initialize(token);
if (session.options) {
for (const [_, handle] of this._sessionTypeToHandle) {
if (handle === providerHandle) {
Expand Down
6 changes: 1 addition & 5 deletions src/vs/workbench/api/common/extHost.protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3587,10 +3587,6 @@ export interface ChatSessionOptionUpdateDto2 {
readonly value: string | IChatSessionProviderOptionItem;
}

export interface ChatSessionContentContextDto {
readonly initialSessionOptions?: ReadonlyArray<{ optionId: string; value: string }>;
}

export interface ChatSessionDto {
id: string;
resource: UriComponents;
Expand Down Expand Up @@ -3633,7 +3629,7 @@ export interface ExtHostChatSessionsShape {
$onDidChangeChatSessionItemState(providerHandle: number, sessionResource: UriComponents, archived: boolean): void;
$newChatSessionItem(controllerHandle: number, request: IChatNewSessionRequest, token: CancellationToken): Promise<Dto<IChatSessionItem> | undefined>;

$provideChatSessionContent(providerHandle: number, sessionResource: UriComponents, token: CancellationToken, context?: ChatSessionContentContextDto): Promise<ChatSessionDto>;
$provideChatSessionContent(providerHandle: number, sessionResource: UriComponents, token: CancellationToken): Promise<ChatSessionDto>;
$interruptChatSessionActiveResponse(providerHandle: number, sessionResource: UriComponents, requestId: string): Promise<void>;
$disposeChatSessionContent(providerHandle: number, sessionResource: UriComponents): Promise<void>;
$invokeChatSessionRequestHandler(providerHandle: number, sessionResource: UriComponents, request: IChatAgentRequest, history: any[], token: CancellationToken): Promise<IChatAgentResult>;
Expand Down
16 changes: 4 additions & 12 deletions src/vs/workbench/api/common/extHostChatSessions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { IChatNewSessionRequest, IChatSessionProviderOptionItem } from '../../co
import { ChatAgentLocation } from '../../contrib/chat/common/constants.js';
import { IChatAgentRequest, IChatAgentResult } from '../../contrib/chat/common/participants/chatAgents.js';
import { Proxied } from '../../services/extensions/common/proxyIdentifier.js';
import { ChatSessionContentContextDto, ChatSessionDto, ExtHostChatSessionsShape, IChatAgentProgressShape, IChatSessionProviderOptions, MainContext, MainThreadChatSessionsShape } from './extHost.protocol.js';
import { ChatSessionDto, ExtHostChatSessionsShape, IChatAgentProgressShape, IChatSessionProviderOptions, MainContext, MainThreadChatSessionsShape } from './extHost.protocol.js';
import { ChatAgentResponseStream } from './extHostChatAgents2.js';
import { CommandsConverter, ExtHostCommands } from './extHostCommands.js';
import { ExtHostLanguageModels } from './extHostLanguageModels.js';
Expand Down Expand Up @@ -499,17 +499,15 @@ export class ExtHostChatSessions extends Disposable implements ExtHostChatSessio
});
}

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

const sessionResource = URI.revive(sessionResourceComponents);

const session = await provider.provider.provideChatSessionContent(sessionResource, token, {
sessionOptions: context?.initialSessionOptions ?? []
});
const session = await provider.provider.provideChatSessionContent(sessionResource, token);
if (token.isCancellationRequested) {
throw new CancellationError();
}
Expand Down Expand Up @@ -787,13 +785,7 @@ export class ExtHostChatSessions extends Disposable implements ExtHostChatSessio
return undefined;
}

const item = await handler({
request: {
prompt: request.prompt,
command: request.command
},
sessionOptions: request.initialSessionOptions ?? [],
}, token);
const item = await handler({ request: { prompt: request.prompt, command: request.command } }, token);
if (!item) {
return undefined;
}
Expand Down
19 changes: 0 additions & 19 deletions src/vs/workbench/api/test/browser/mainThreadChatSessions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,25 +197,6 @@ suite('ObservableChatSession', function () {
assert.ok((proxy.$provideChatSessionContent as sinon.SinonStub).calledOnce);
});

test('initialization forwards initial session options context', async function () {
const sessionId = 'test-id';
const resource = LocalChatSessionUri.forSession(sessionId);
const session = disposables.add(new ObservableChatSession(resource, 1, proxy, logService, dialogService));
const initialSessionOptions = [{ optionId: 'model', value: 'gpt-4.1' }];

const sessionContent = createSessionContent();
(proxy.$provideChatSessionContent as sinon.SinonStub).resolves(sessionContent);

await session.initialize(CancellationToken.None, { initialSessionOptions });

assert.ok((proxy.$provideChatSessionContent as sinon.SinonStub).calledOnceWith(
1,
resource,
CancellationToken.None,
{ initialSessionOptions }
));
});

test('progress handling works correctly after initialization', async function () {
const sessionContent = createSessionContent();
const session = disposables.add(await createInitializedSession(sessionContent));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -824,14 +824,13 @@ export class ChatService extends Disposable implements IChatService {
const parsedRequest = this.parseChatRequest(sessionResource, request, options?.location ?? model.initialLocation, options);
const commandPart = parsedRequest.parts.find((r): r is ChatRequestSlashCommandPart => r instanceof ChatRequestSlashCommandPart);
const requestText = getPromptText(parsedRequest).message;
const newItem = await this.chatSessionService.createNewChatSessionItem(getChatSessionType(sessionResource), { prompt: requestText, command: commandPart?.text }, CancellationToken.None);
if (newItem) {

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

const newItem = await this.chatSessionService.createNewChatSessionItem(getChatSessionType(sessionResource), { prompt: requestText, command: commandPart?.text, initialSessionOptions }, CancellationToken.None);
if (newItem) {
model = (await this.loadRemoteSession(newItem.resource, model.initialLocation, CancellationToken.None))?.object as ChatModel | undefined;
if (!model) {
throw new Error(`Failed to load session for resource: ${newItem.resource}`);
Expand Down
2 changes: 0 additions & 2 deletions src/vs/workbench/contrib/chat/common/chatSessionsService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,6 @@ export interface IChatSessionContentProvider {
export interface IChatNewSessionRequest {
readonly prompt: string;
readonly command?: string;

readonly initialSessionOptions?: ReadonlyArray<{ optionId: string; value: string | IChatSessionProviderOptionItem }>;
}

export interface IChatSessionItemsDelta {
Expand Down
7 changes: 1 addition & 6 deletions src/vscode-dts/vscode.proposed.chatSessionsProvider.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,6 @@ declare module 'vscode' {
readonly prompt: string;
readonly command?: string;
};

readonly sessionOptions: ReadonlyArray<{ optionId: string; value: string | ChatSessionProviderOptionItem }>;
}

/**
Expand Down Expand Up @@ -449,13 +447,10 @@ declare module 'vscode' {
*
* @param resource The URI of the chat session to resolve.
* @param token A cancellation token that can be used to cancel the operation.
* @param context Additional context for the chat session.
*
* @return The {@link ChatSession chat session} associated with the given URI.
*/
provideChatSessionContent(resource: Uri, token: CancellationToken, context: {
readonly sessionOptions: ReadonlyArray<{ optionId: string; value: string | ChatSessionProviderOptionItem }>;
}): Thenable<ChatSession> | ChatSession;
provideChatSessionContent(resource: Uri, token: CancellationToken): Thenable<ChatSession> | ChatSession;

/**
* @param resource Identifier of the chat session being updated.
Expand Down
Loading