From a1f2ea3162c704a5890c35dde4df6ee46283d957 Mon Sep 17 00:00:00 2001 From: Rob Lourens Date: Fri, 3 May 2024 04:40:52 +0000 Subject: [PATCH] Move from chat variable values array to a single value (#211897) * Move from chat variable values array to a single value * Update --- .../api/browser/mainThreadChatAgents2.ts | 2 +- .../api/browser/mainThreadChatVariables.ts | 4 +- .../workbench/api/common/extHost.protocol.ts | 4 +- .../api/common/extHostChatVariables.ts | 12 ++-- .../api/common/extHostTypeConverters.ts | 59 +------------------ .../chatMarkdownDecorationsRenderer.ts | 5 +- .../contrib/chat/browser/chatVariables.ts | 16 ++--- .../browser/contrib/chatDynamicVariables.ts | 12 ++-- .../browser/contrib/chatHistoryVariables.ts | 2 +- .../contrib/chat/common/chatModel.ts | 6 +- .../contrib/chat/common/chatParserTypes.ts | 4 +- .../contrib/chat/common/chatServiceImpl.ts | 9 ++- .../contrib/chat/common/chatVariables.ts | 15 ++--- .../chat/test/browser/chatVariables.test.ts | 4 +- .../chat/test/common/mockChatVariables.ts | 2 +- .../browser/inlineChatSessionServiceImpl.ts | 16 ++--- ...ode.proposed.chatParticipantAdditions.d.ts | 5 -- 17 files changed, 57 insertions(+), 120 deletions(-) diff --git a/src/vs/workbench/api/browser/mainThreadChatAgents2.ts b/src/vs/workbench/api/browser/mainThreadChatAgents2.ts index a30b4026dbb4e..e0cebf411d944 100644 --- a/src/vs/workbench/api/browser/mainThreadChatAgents2.ts +++ b/src/vs/workbench/api/browser/mainThreadChatAgents2.ts @@ -212,7 +212,7 @@ export class MainThreadChatAgents2 extends Disposable implements MainThreadChatA kind: CompletionItemKind.Text, detail: v.detail, documentation: v.documentation, - command: { id: AddDynamicVariableAction.ID, title: '', arguments: [{ widget, range: rangeAfterInsert, variableData: revive(v.values), command: v.command } satisfies IAddDynamicVariableContext] } + command: { id: AddDynamicVariableAction.ID, title: '', arguments: [{ widget, range: rangeAfterInsert, variableData: revive(v.value) as any, command: v.command } satisfies IAddDynamicVariableContext] } } satisfies CompletionItem; }); diff --git a/src/vs/workbench/api/browser/mainThreadChatVariables.ts b/src/vs/workbench/api/browser/mainThreadChatVariables.ts index fbdc3060424db..9e08e5d14232c 100644 --- a/src/vs/workbench/api/browser/mainThreadChatVariables.ts +++ b/src/vs/workbench/api/browser/mainThreadChatVariables.ts @@ -31,10 +31,10 @@ export class MainThreadChatVariables implements MainThreadChatVariablesShape { const registration = this._chatVariablesService.registerVariable(data, async (messageText, _arg, model, progress, token) => { const varRequestId = `${model.sessionId}-${handle}`; this._pendingProgress.set(varRequestId, progress); - const result = revive(await this._proxy.$resolveVariable(handle, varRequestId, messageText, token)); + const result = revive(await this._proxy.$resolveVariable(handle, varRequestId, messageText, token)); this._pendingProgress.delete(varRequestId); - return result; + return result as any; // 'revive' type signature doesn't like this type for some reason }); this._variables.set(handle, registration); } diff --git a/src/vs/workbench/api/common/extHost.protocol.ts b/src/vs/workbench/api/common/extHost.protocol.ts index ed133c366b22d..b316611fba6ed 100644 --- a/src/vs/workbench/api/common/extHost.protocol.ts +++ b/src/vs/workbench/api/common/extHost.protocol.ts @@ -1235,7 +1235,7 @@ export interface MainThreadChatAgentsShape2 extends IDisposable { export interface IChatAgentCompletionItem { insertText?: string; label: string | languages.CompletionItemLabel; - values: IChatRequestVariableValueDto[]; + value: IChatRequestVariableValueDto; detail?: string; documentation?: string | IMarkdownString; command?: ICommandDto; @@ -1273,7 +1273,7 @@ export interface MainThreadChatVariablesShape extends IDisposable { export type IChatRequestVariableValueDto = Dto; export interface ExtHostChatVariablesShape { - $resolveVariable(handle: number, requestId: string, messageText: string, token: CancellationToken): Promise; + $resolveVariable(handle: number, requestId: string, messageText: string, token: CancellationToken): Promise; } export interface MainThreadInlineChatShape extends IDisposable { diff --git a/src/vs/workbench/api/common/extHostChatVariables.ts b/src/vs/workbench/api/common/extHostChatVariables.ts index afc7ef7d1d561..c0587e4ef0622 100644 --- a/src/vs/workbench/api/common/extHostChatVariables.ts +++ b/src/vs/workbench/api/common/extHostChatVariables.ts @@ -25,7 +25,7 @@ export class ExtHostChatVariables implements ExtHostChatVariablesShape { this._proxy = mainContext.getProxy(MainContext.MainThreadChatVariables); } - async $resolveVariable(handle: number, requestId: string, messageText: string, token: CancellationToken): Promise { + async $resolveVariable(handle: number, requestId: string, messageText: string, token: CancellationToken): Promise { const item = this._resolver.get(handle); if (!item) { return undefined; @@ -35,13 +35,15 @@ export class ExtHostChatVariables implements ExtHostChatVariablesShape { checkProposedApiEnabled(item.extension, 'chatParticipantAdditions'); const stream = new ChatVariableResolverResponseStream(requestId, this._proxy); const value = await item.resolver.resolve2(item.data.name, { prompt: messageText }, stream.apiObject, token); - if (value) { - return value.map(typeConvert.ChatVariable.from); + + // Temp, ignoring other returned values to convert the array into a single value + if (value && value[0]) { + return value[0].value; } } else { const value = await item.resolver.resolve(item.data.name, { prompt: messageText }, token); - if (value) { - return value.map(typeConvert.ChatVariable.from); + if (value && value[0]) { + return value[0].value; } } } catch (err) { diff --git a/src/vs/workbench/api/common/extHostTypeConverters.ts b/src/vs/workbench/api/common/extHostTypeConverters.ts index e22323422fd14..3e63c89dfc117 100644 --- a/src/vs/workbench/api/common/extHostTypeConverters.ts +++ b/src/vs/workbench/api/common/extHostTypeConverters.ts @@ -16,6 +16,7 @@ import { Mimes } from 'vs/base/common/mime'; import { cloneAndChange } from 'vs/base/common/objects'; import { IPrefixTreeNode, WellDefinedPrefixTree } from 'vs/base/common/prefixTree'; import { basename } from 'vs/base/common/resources'; +import { ThemeIcon } from 'vs/base/common/themables'; import { isDefined, isEmptyObject, isNumber, isString, isUndefinedOrNull } from 'vs/base/common/types'; import { URI, UriComponents, isUriComponents } from 'vs/base/common/uri'; import { IURITransformer } from 'vs/base/common/uriIpc'; @@ -40,7 +41,6 @@ import { IViewBadge } from 'vs/workbench/common/views'; import { ChatAgentLocation, IChatAgentRequest, IChatAgentResult } from 'vs/workbench/contrib/chat/common/chatAgents'; import { IChatRequestVariableEntry } from 'vs/workbench/contrib/chat/common/chatModel'; import { IChatAgentDetection, IChatAgentMarkdownContentWithVulnerability, IChatCommandButton, IChatContentInlineReference, IChatContentReference, IChatFollowup, IChatMarkdownContent, IChatProgressMessage, IChatTextEdit, IChatTreeData, IChatUserActionEvent, IChatWarningMessage } from 'vs/workbench/contrib/chat/common/chatService'; -import { IChatRequestVariableValue } from 'vs/workbench/contrib/chat/common/chatVariables'; import * as chatProvider from 'vs/workbench/contrib/chat/common/languageModels'; import { DebugTreeItemCollapsibleState, IDebugVisualizationTreeItem } from 'vs/workbench/contrib/debug/common/debug'; import { IInlineChatCommandFollowup, IInlineChatFollowup, IInlineChatReplyFollowup, InlineChatResponseFeedbackKind } from 'vs/workbench/contrib/inlineChat/common/inlineChat'; @@ -54,7 +54,6 @@ import { ACTIVE_GROUP, SIDE_GROUP } from 'vs/workbench/services/editor/common/ed import { Dto } from 'vs/workbench/services/extensions/common/proxyIdentifier'; import type * as vscode from 'vscode'; import * as types from './extHostTypes'; -import { ThemeIcon } from 'vs/base/common/themables'; export namespace Command { @@ -2286,58 +2285,6 @@ export namespace LanguageModelMessage { } } -export namespace ChatVariable { - export function objectTo(variableObject: Record): Record { - const result: Record = {}; - for (const key of Object.keys(variableObject)) { - result[key] = variableObject[key].map(ChatVariable.to); - } - - return result; - } - - export function to(variable: IChatRequestVariableValue): vscode.ChatVariableValue { - return { - level: ChatVariableLevel.to(variable.level), - kind: variable.kind, - value: isUriComponents(variable.value) ? URI.revive(variable.value) : variable.value, - description: variable.description - }; - } - - export function from(variable: vscode.ChatVariableValue): IChatRequestVariableValue { - return { - level: ChatVariableLevel.from(variable.level), - kind: variable.kind, - value: variable.value, - description: variable.description - }; - } -} - -export namespace ChatVariableLevel { - - - export function to(level: 'short' | 'medium' | 'full'): vscode.ChatVariableLevel { - switch (level) { - case 'short': return types.ChatVariableLevel.Short; - case 'medium': return types.ChatVariableLevel.Medium; - case 'full': - default: - return types.ChatVariableLevel.Full; - } - } - export function from(level: vscode.ChatVariableLevel): 'short' | 'medium' | 'full' { - switch (level) { - case types.ChatVariableLevel.Short: return 'short'; - case types.ChatVariableLevel.Medium: return 'medium'; - case types.ChatVariableLevel.Full: - default: - return 'full'; - } - } -} - export namespace InteractiveEditorResponseFeedbackKind { export function to(kind: InlineChatResponseFeedbackKind): vscode.InteractiveEditorResponseFeedbackKind { @@ -2628,7 +2575,7 @@ export namespace ChatLocation { export namespace ChatAgentValueReference { export function to(request: IChatRequestVariableEntry): vscode.ChatValueReference { - const value = request.values[0]?.value; + const value = request.value; if (!value) { throw new Error('Invalid value reference'); } @@ -2645,7 +2592,7 @@ export namespace ChatAgentCompletionItem { export function from(item: vscode.ChatCompletionItem, commandsConverter: CommandsConverter, disposables: DisposableStore): extHostProtocol.IChatAgentCompletionItem { return { label: item.label, - values: item.values.map(ChatVariable.from), + value: item.values[0].value, insertText: item.insertText, detail: item.detail, documentation: item.documentation, diff --git a/src/vs/workbench/contrib/chat/browser/chatMarkdownDecorationsRenderer.ts b/src/vs/workbench/contrib/chat/browser/chatMarkdownDecorationsRenderer.ts index ad7c537bd212b..13e3a369b7fb0 100644 --- a/src/vs/workbench/contrib/chat/browser/chatMarkdownDecorationsRenderer.ts +++ b/src/vs/workbench/contrib/chat/browser/chatMarkdownDecorationsRenderer.ts @@ -47,8 +47,9 @@ export class ChatMarkdownDecorationsRenderer { result += `[${text}](${agentRefUrl}?${encodeURIComponent(part.agent.id)})`; } else { - const uri = part instanceof ChatRequestDynamicVariablePart && part.data.map(d => d.value).find((d): d is URI => d instanceof URI) - || undefined; + const uri = part instanceof ChatRequestDynamicVariablePart && part.data instanceof URI ? + part.data : + undefined; const title = uri ? encodeURIComponent(this.labelService.getUriLabel(uri, { relative: true })) : part instanceof ChatRequestAgentPart ? part.agent.id : ''; diff --git a/src/vs/workbench/contrib/chat/browser/chatVariables.ts b/src/vs/workbench/contrib/chat/browser/chatVariables.ts index 9547c45ba3624..3051205846d95 100644 --- a/src/vs/workbench/contrib/chat/browser/chatVariables.ts +++ b/src/vs/workbench/contrib/chat/browser/chatVariables.ts @@ -47,18 +47,20 @@ export class ChatVariablesService implements IChatVariablesService { } progress(item); }; - jobs.push(data.resolver(prompt.text, part.variableArg, model, variableProgressCallback, token).then(values => { - resolvedVariables[i] = { name: part.variableName, range: part.range, values: values ?? [], references }; + jobs.push(data.resolver(prompt.text, part.variableArg, model, variableProgressCallback, token).then(value => { + if (value) { + resolvedVariables[i] = { name: part.variableName, range: part.range, value, references }; + } }).catch(onUnexpectedExternalError)); } } else if (part instanceof ChatRequestDynamicVariablePart) { - resolvedVariables[i] = { name: part.referenceText, range: part.range, values: part.data }; + resolvedVariables[i] = { name: part.referenceText, range: part.range, value: part.data }; } }); await Promise.allSettled(jobs); - resolvedVariables = coalesce(resolvedVariables); + resolvedVariables = coalesce(resolvedVariables); // "reverse", high index first so that replacement is simple resolvedVariables.sort((a, b) => b.range!.start - a.range!.start); @@ -68,13 +70,13 @@ export class ChatVariablesService implements IChatVariablesService { }; } - async resolveVariable(variableName: string, promptText: string, model: IChatModel, progress: (part: IChatVariableResolverProgress) => void, token: CancellationToken): Promise { + async resolveVariable(variableName: string, promptText: string, model: IChatModel, progress: (part: IChatVariableResolverProgress) => void, token: CancellationToken): Promise { const data = this._resolver.get(variableName.toLowerCase()); if (!data) { - return Promise.resolve([]); + return undefined; } - return (await data.resolver(promptText, undefined, model, progress, token)) ?? []; + return (await data.resolver(promptText, undefined, model, progress, token)); } hasVariable(name: string): boolean { diff --git a/src/vs/workbench/contrib/chat/browser/contrib/chatDynamicVariables.ts b/src/vs/workbench/contrib/chat/browser/contrib/chatDynamicVariables.ts index 6cc582770b0bf..12163ceaf0308 100644 --- a/src/vs/workbench/contrib/chat/browser/contrib/chatDynamicVariables.ts +++ b/src/vs/workbench/contrib/chat/browser/contrib/chatDynamicVariables.ts @@ -106,11 +106,11 @@ export class ChatDynamicVariableModel extends Disposable implements IChatWidgetC } private getHoverForReference(ref: IDynamicVariable): string | IMarkdownString { - const value = ref.data[0]; - if (URI.isUri(value.value)) { - return new MarkdownString(this.labelService.getUriLabel(value.value, { relative: true })); + const value = ref.data; + if (URI.isUri(value)) { + return new MarkdownString(this.labelService.getUriLabel(value, { relative: true })); } else { - return value.value.toString(); + return (value as any).toString(); } } } @@ -209,7 +209,7 @@ export class SelectAndInsertFileAction extends Action2 { context.widget.getContrib(ChatDynamicVariableModel.ID)?.addReference({ range: { startLineNumber: range.startLineNumber, startColumn: range.startColumn, endLineNumber: range.endLineNumber, endColumn: range.startColumn + text.length }, - data: [{ level: 'full', value: resource }] + data: resource }); } } @@ -218,7 +218,7 @@ registerAction2(SelectAndInsertFileAction); export interface IAddDynamicVariableContext { widget: IChatWidget; range: IRange; - variableData: IChatRequestVariableValue[]; + variableData: IChatRequestVariableValue; command?: Command; } diff --git a/src/vs/workbench/contrib/chat/browser/contrib/chatHistoryVariables.ts b/src/vs/workbench/contrib/chat/browser/contrib/chatHistoryVariables.ts index 5df9a406f5be2..1d8dfd377d81e 100644 --- a/src/vs/workbench/contrib/chat/browser/contrib/chatHistoryVariables.ts +++ b/src/vs/workbench/contrib/chat/browser/contrib/chatHistoryVariables.ts @@ -26,7 +26,7 @@ class ChatHistoryVariables extends Disposable { return undefined; } - return [{ level: 'full', value: response.response.asString() }]; + return response.response.asString(); })); } } diff --git a/src/vs/workbench/contrib/chat/common/chatModel.ts b/src/vs/workbench/contrib/chat/common/chatModel.ts index 7d44af6bba552..1cc4dd7898dd4 100644 --- a/src/vs/workbench/contrib/chat/common/chatModel.ts +++ b/src/vs/workbench/contrib/chat/common/chatModel.ts @@ -23,14 +23,10 @@ import { ChatRequestTextPart, IParsedChatRequest, getPromptText, reviveParsedCha import { IChatAgentMarkdownContentWithVulnerability, IChatCommandButton, IChatContentInlineReference, IChatContentReference, IChatFollowup, IChatMarkdownContent, IChatProgress, IChatProgressMessage, IChatResponseProgressFileTreeData, IChatTextEdit, IChatTreeData, IChatUsedContext, IChatWarningMessage, InteractiveSessionVoteDirection, isIUsedContext } from 'vs/workbench/contrib/chat/common/chatService'; import { IChatRequestVariableValue } from 'vs/workbench/contrib/chat/common/chatVariables'; -export interface IChatPromptVariableData { - variables: { name: string; range: IOffsetRange; values: IChatRequestVariableValue[] }[]; -} - export interface IChatRequestVariableEntry { name: string; range?: IOffsetRange; - values: IChatRequestVariableValue[]; + value: IChatRequestVariableValue; references?: IChatContentReference[]; } diff --git a/src/vs/workbench/contrib/chat/common/chatParserTypes.ts b/src/vs/workbench/contrib/chat/common/chatParserTypes.ts index ec93399b26a57..d5643a2653446 100644 --- a/src/vs/workbench/contrib/chat/common/chatParserTypes.ts +++ b/src/vs/workbench/contrib/chat/common/chatParserTypes.ts @@ -123,7 +123,7 @@ export class ChatRequestSlashCommandPart implements IParsedChatRequestPart { export class ChatRequestDynamicVariablePart implements IParsedChatRequestPart { static readonly Kind = 'dynamic'; readonly kind = ChatRequestDynamicVariablePart.Kind; - constructor(readonly range: OffsetRange, readonly editorRange: IRange, readonly text: string, readonly data: IChatRequestVariableValue[]) { } + constructor(readonly range: OffsetRange, readonly editorRange: IRange, readonly text: string, readonly data: IChatRequestVariableValue) { } get referenceText(): string { return this.text.replace(chatVariableLeader, ''); @@ -183,7 +183,7 @@ export function reviveParsedChatRequest(serialized: IParsedChatRequest): IParsed new OffsetRange(part.range.start, part.range.endExclusive), part.editorRange, (part as ChatRequestDynamicVariablePart).text, - revive((part as ChatRequestDynamicVariablePart).data) + revive((part as ChatRequestDynamicVariablePart).data) as any ); } else { throw new Error(`Unknown chat request part: ${part.kind}`); diff --git a/src/vs/workbench/contrib/chat/common/chatServiceImpl.ts b/src/vs/workbench/contrib/chat/common/chatServiceImpl.ts index 6a18b363fa307..90f32ecbd1096 100644 --- a/src/vs/workbench/contrib/chat/common/chatServiceImpl.ts +++ b/src/vs/workbench/contrib/chat/common/chatServiceImpl.ts @@ -4,6 +4,7 @@ *--------------------------------------------------------------------------------------------*/ import { Action } from 'vs/base/common/actions'; +import { coalesce } from 'vs/base/common/arrays'; import { CancellationToken, CancellationTokenSource } from 'vs/base/common/cancellation'; import { ErrorNoTelemetry } from 'vs/base/common/errors'; import { Emitter, Event } from 'vs/base/common/event'; @@ -544,8 +545,12 @@ export class ChatService extends Disposable implements IChatService { if (implicitVariablesEnabled) { const implicitVariables = agent.defaultImplicitVariables; if (implicitVariables) { - const resolvedImplicitVariables = await Promise.all(implicitVariables.map(async v => ({ name: v, values: await this.chatVariablesService.resolveVariable(v, parsedRequest.text, model, progressCallback, token) } satisfies IChatRequestVariableEntry))); - updatedVariableData.variables.push(...resolvedImplicitVariables); + const resolvedImplicitVariables = await Promise.all(implicitVariables.map(async v => { + const value = await this.chatVariablesService.resolveVariable(v, parsedRequest.text, model, progressCallback, token); + return value ? { name: v, value } satisfies IChatRequestVariableEntry : + undefined; + })); + updatedVariableData.variables.push(...coalesce(resolvedImplicitVariables)); } } diff --git a/src/vs/workbench/contrib/chat/common/chatVariables.ts b/src/vs/workbench/contrib/chat/common/chatVariables.ts index dc999f8081f3b..056620616e033 100644 --- a/src/vs/workbench/contrib/chat/common/chatVariables.ts +++ b/src/vs/workbench/contrib/chat/common/chatVariables.ts @@ -7,6 +7,7 @@ import { CancellationToken } from 'vs/base/common/cancellation'; import { IDisposable } from 'vs/base/common/lifecycle'; import { URI } from 'vs/base/common/uri'; import { IRange } from 'vs/editor/common/core/range'; +import { Location } from 'vs/editor/common/languages'; import { createDecorator } from 'vs/platform/instantiation/common/instantiation'; import { IChatModel, IChatRequestVariableData } from 'vs/workbench/contrib/chat/common/chatModel'; import { IParsedChatRequest } from 'vs/workbench/contrib/chat/common/chatParserTypes'; @@ -19,20 +20,14 @@ export interface IChatVariableData { canTakeArgument?: boolean; } -export interface IChatRequestVariableValue { - level: 'short' | 'medium' | 'full'; - kind?: string; - value: string | URI; - description?: string; -} +export type IChatRequestVariableValue = string | URI | Location | unknown; export type IChatVariableResolverProgress = | IChatContentReference | IChatProgressMessage; export interface IChatVariableResolver { - // TODO should we spec "zoom level" - (messageText: string, arg: string | undefined, model: IChatModel, progress: (part: IChatVariableResolverProgress) => void, token: CancellationToken): Promise; + (messageText: string, arg: string | undefined, model: IChatModel, progress: (part: IChatVariableResolverProgress) => void, token: CancellationToken): Promise; } export const IChatVariablesService = createDecorator('IChatVariablesService'); @@ -49,10 +44,10 @@ export interface IChatVariablesService { * Resolves all variables that occur in `prompt` */ resolveVariables(prompt: IParsedChatRequest, model: IChatModel, progress: (part: IChatVariableResolverProgress) => void, token: CancellationToken): Promise; - resolveVariable(variableName: string, promptText: string, model: IChatModel, progress: (part: IChatVariableResolverProgress) => void, token: CancellationToken): Promise; + resolveVariable(variableName: string, promptText: string, model: IChatModel, progress: (part: IChatVariableResolverProgress) => void, token: CancellationToken): Promise; } export interface IDynamicVariable { range: IRange; - data: IChatRequestVariableValue[]; + data: IChatRequestVariableValue; } diff --git a/src/vs/workbench/contrib/chat/test/browser/chatVariables.test.ts b/src/vs/workbench/contrib/chat/test/browser/chatVariables.test.ts index 5da221f7ad11b..492a80f54a08e 100644 --- a/src/vs/workbench/contrib/chat/test/browser/chatVariables.test.ts +++ b/src/vs/workbench/contrib/chat/test/browser/chatVariables.test.ts @@ -41,8 +41,8 @@ suite('ChatVariables', function () { test('ChatVariables - resolveVariables', async function () { - const v1 = service.registerVariable({ name: 'foo', description: 'bar' }, async () => ([{ level: 'full', value: 'farboo' }])); - const v2 = service.registerVariable({ name: 'far', description: 'boo' }, async () => ([{ level: 'full', value: 'farboo' }])); + const v1 = service.registerVariable({ name: 'foo', description: 'bar' }, async () => 'farboo'); + const v2 = service.registerVariable({ name: 'far', description: 'boo' }, async () => 'farboo'); const parser = instantiationService.createInstance(ChatRequestParser); diff --git a/src/vs/workbench/contrib/chat/test/common/mockChatVariables.ts b/src/vs/workbench/contrib/chat/test/common/mockChatVariables.ts index 0df8e2b57e78f..902631c259a38 100644 --- a/src/vs/workbench/contrib/chat/test/common/mockChatVariables.ts +++ b/src/vs/workbench/contrib/chat/test/common/mockChatVariables.ts @@ -37,7 +37,7 @@ export class MockChatVariablesService implements IChatVariablesService { }; } - resolveVariable(variableName: string, promptText: string, model: IChatModel, progress: (part: IChatVariableResolverProgress) => void, token: CancellationToken): Promise { + resolveVariable(variableName: string, promptText: string, model: IChatModel, progress: (part: IChatVariableResolverProgress) => void, token: CancellationToken): Promise { throw new Error('Method not implemented.'); } } diff --git a/src/vs/workbench/contrib/inlineChat/browser/inlineChatSessionServiceImpl.ts b/src/vs/workbench/contrib/inlineChat/browser/inlineChatSessionServiceImpl.ts index 7282aa13c876d..1b75d87272409 100644 --- a/src/vs/workbench/contrib/inlineChat/browser/inlineChatSessionServiceImpl.ts +++ b/src/vs/workbench/contrib/inlineChat/browser/inlineChatSessionServiceImpl.ts @@ -80,8 +80,8 @@ class BridgeAgent implements IChatAgentImplementation { throw new Error('FAILED to find last input'); } - const inlineChatContextValue = request.variables.variables.find(candidate => candidate.name === _inlineChatContext)?.values[0]; - const inlineChatContext = typeof inlineChatContextValue?.value === 'string' && JSON.parse(inlineChatContextValue.value); + const inlineChatContextValue = request.variables.variables.find(candidate => candidate.name === _inlineChatContext)?.value; + const inlineChatContext = typeof inlineChatContextValue === 'string' && JSON.parse(inlineChatContextValue); const modelAltVersionIdNow = session.textModelN.getAlternativeVersionId(); const progressEdits: TextEdit[][] = []; @@ -385,10 +385,7 @@ export class InlineChatSessionServiceImpl implements IInlineChatSessionService { async (_message, _arg, model) => { for (const [, data] of this._sessions) { if (data.session.chatModel === model) { - return [{ - level: 'full', - value: JSON.stringify(new InlineChatContext(data.session.textModelN.uri, data.editor.getSelection()!, data.session.wholeRange.trackedInitialRange)) - }]; + return JSON.stringify(new InlineChatContext(data.session.textModelN.uri, data.editor.getSelection()!, data.session.wholeRange.trackedInitialRange)); } } return undefined; @@ -399,7 +396,7 @@ export class InlineChatSessionServiceImpl implements IInlineChatSessionService { async (_message, _arg, model) => { for (const [, data] of this._sessions) { if (data.session.chatModel === model) { - return [{ level: 'full', value: data.session.textModelN.uri }]; + return data.session.textModelN.uri; } } return undefined; @@ -802,10 +799,7 @@ export class AgentInlineChatProvider implements IInlineChatSessionProvider { variables: { variables: [{ name: InlineChatContext.variableName, - values: [{ - level: 'full', - value: JSON.stringify(new InlineChatContext(request.previewDocument, request.selection, request.wholeRange)) - }] + value: JSON.stringify(new InlineChatContext(request.previewDocument, request.selection, request.wholeRange)) }] } }, part => { diff --git a/src/vscode-dts/vscode.proposed.chatParticipantAdditions.d.ts b/src/vscode-dts/vscode.proposed.chatParticipantAdditions.d.ts index b1f69e37a06ab..fe78e9389a685 100644 --- a/src/vscode-dts/vscode.proposed.chatParticipantAdditions.d.ts +++ b/src/vscode-dts/vscode.proposed.chatParticipantAdditions.d.ts @@ -247,11 +247,6 @@ declare module 'vscode' { * A description of this value, which could be provided to the LLM as a hint. */ description?: string; - - /** - * An optional type tag for extensions to communicate the kind of the variable. An extension might use it to interpret the shape of `value`. - */ - kind?: string; } export interface ChatVariableResolverResponseStream {