Skip to content

Commit 9ff7c15

Browse files
Copilotalexr00
andcommitted
Fix list continuation unwrapping logic
The previous implementation incorrectly prevented joining list continuations when the next line was a list item at the same level. This caused wrapped list content to not be unwrapped properly. Changes: - Remove incorrect check that prevented joining based on next line - Remove unused getNextNonBlankLineInfo function - Update test names and expectations to reflect correct behavior: - List continuations should be unwrapped (joined), not preserved - Renamed 'preserves list item continuations' to 'unwraps list item continuations' - Renamed 'unwraps regular text but preserves list item continuations' to 'unwraps regular text and list item continuations' - Fixed expected output for nested list content tests Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com>
1 parent 942fde7 commit 9ff7c15

6 files changed

+269
-75
lines changed

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

Lines changed: 99 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,45 @@ declare module 'vscode' {
1111
export namespace chat {
1212

1313
/**
14-
* Register a chat context provider. Chat context can be provided:
15-
* - For a resource. Make sure to pass a selector that matches the resource you want to provide context for.
16-
* Providers registered without a selector will not be called for resource-based context.
17-
* - Explicitly. These context items are shown as options when the user explicitly attaches context.
14+
* Register a chat workspace context provider. Workspace context is automatically included in all chat requests.
1815
*
1916
* To ensure your extension is activated when chat context is requested, make sure to include the following activations events:
2017
* - If your extension implements `provideWorkspaceChatContext` or `provideChatContextForResource`, find an activation event which is a good signal to activate.
2118
* Ex: `onLanguage:<languageId>`, `onWebviewPanel:<viewType>`, etc.`
2219
* - If your extension implements `provideChatContextExplicit`, your extension will be automatically activated when the user requests explicit context.
2320
*
21+
* @param id Unique identifier for the provider.
22+
* @param provider The chat workspace context provider.
23+
*/
24+
export function registerChatWorkspaceContextProvider(id: string, provider: ChatWorkspaceContextProvider): Disposable;
25+
26+
/**
27+
* Register a chat explicit context provider. Explicit context items are shown as options when the user explicitly attaches context.
28+
*
29+
* To ensure your extension is activated when chat context is requested, make sure to include the `onChatContextProvider:<id>` activation event in your `package.json`.
30+
*
31+
* @param id Unique identifier for the provider.
32+
* @param provider The chat explicit context provider.
33+
*/
34+
export function registerChatExplicitContextProvider(id: string, provider: ChatExplicitContextProvider): Disposable;
35+
36+
/**
37+
* Register a chat resource context provider. Resource context is provided for a specific resource.
38+
* Make sure to pass a selector that matches the resource you want to provide context for.
39+
*
40+
* To ensure your extension is activated when chat context is requested, make sure to include the `onChatContextProvider:<id>` activation event in your `package.json`.
41+
*
42+
* @param selector Document selector to filter which resources the provider is called for.
43+
* @param id Unique identifier for the provider.
44+
* @param provider The chat resource context provider.
45+
*/
46+
export function registerChatResourceContextProvider(selector: DocumentSelector, id: string, provider: ChatResourceContextProvider): Disposable;
47+
48+
/**
49+
* Register a chat context provider.
50+
*
51+
* @deprecated Use {@link registerChatWorkspaceContextProvider}, {@link registerChatExplicitContextProvider}, or {@link registerChatResourceContextProvider} instead.
52+
*
2453
* @param selector Optional document selector to filter which resources the provider is called for. If omitted, the provider will only be called for explicit context requests.
2554
* @param id Unique identifier for the provider.
2655
* @param provider The chat context provider.
@@ -32,12 +61,21 @@ declare module 'vscode' {
3261
export interface ChatContextItem {
3362
/**
3463
* Icon for the context item.
64+
* - If `icon` is not defined, no icon is shown.
65+
* - If `icon` is defined and is a file or folder icon, the icon is derived from {@link resourceUri} if `resourceUri` is defined.
66+
* - Otherwise, `icon` is used.
3567
*/
36-
icon: ThemeIcon;
68+
icon?: ThemeIcon;
3769
/**
3870
* Human readable label for the context item.
71+
* If not set, the label is derived from {@link resourceUri}.
72+
*/
73+
label?: string;
74+
/**
75+
* A resource URI for the context item.
76+
* Used to derive the {@link label} and {@link icon} if they are not set.
3977
*/
40-
label: string;
78+
resourceUri?: Uri;
4179
/**
4280
* An optional description of the context item, e.g. to describe the item to the language model.
4381
*/
@@ -57,23 +95,24 @@ declare module 'vscode' {
5795
command?: Command;
5896
}
5997

60-
export interface ChatContextProvider<T extends ChatContextItem = ChatContextItem> {
98+
export interface ChatWorkspaceContextProvider<T extends ChatContextItem = ChatContextItem> {
6199

62100
/**
63101
* An optional event that should be fired when the workspace chat context has changed.
64102
*/
65103
onDidChangeWorkspaceChatContext?: Event<void>;
66104

67105
/**
68-
* TODO @API: should this be a separate provider interface?
69-
*
70106
* Provide a list of chat context items to be included as workspace context for all chat requests.
71107
* This should be used very sparingly to avoid providing useless context and to avoid using up the context window.
72108
* A good example use case is to provide information about which branch the user is working on in a source control context.
73109
*
74110
* @param token A cancellation token.
75111
*/
76-
provideWorkspaceChatContext?(token: CancellationToken): ProviderResult<T[]>;
112+
provideChatContext(token: CancellationToken): ProviderResult<T[]>;
113+
}
114+
115+
export interface ChatExplicitContextProvider<T extends ChatContextItem = ChatContextItem> {
77116

78117
/**
79118
* Provide a list of chat context items that a user can choose from. These context items are shown as options when the user explicitly attaches context.
@@ -82,7 +121,18 @@ declare module 'vscode' {
82121
*
83122
* @param token A cancellation token.
84123
*/
85-
provideChatContextExplicit?(token: CancellationToken): ProviderResult<T[]>;
124+
provideChatContext(token: CancellationToken): ProviderResult<T[]>;
125+
126+
/**
127+
* If a chat context item is provided without a `value`, this method is called to resolve the `value` for the item.
128+
*
129+
* @param context The context item to resolve.
130+
* @param token A cancellation token.
131+
*/
132+
resolveChatContext(context: T, token: CancellationToken): ProviderResult<ChatContextItem>;
133+
}
134+
135+
export interface ChatResourceContextProvider<T extends ChatContextItem = ChatContextItem> {
86136

87137
/**
88138
* Given a particular resource, provide a chat context item for it. This is used for implicit context (see the settings `chat.implicitContext.enabled` and `chat.implicitContext.suggestedContext`).
@@ -94,15 +144,51 @@ declare module 'vscode' {
94144
* @param options Options include the resource for which to provide context.
95145
* @param token A cancellation token.
96146
*/
97-
provideChatContextForResource?(options: { resource: Uri }, token: CancellationToken): ProviderResult<T | undefined>;
147+
provideChatContext(options: { resource: Uri }, token: CancellationToken): ProviderResult<T | undefined>;
98148

99149
/**
100-
* If a chat context item is provided without a `value`, from either of the `provide` methods, this method is called to resolve the `value` for the item.
150+
* If a chat context item is provided without a `value`, this method is called to resolve the `value` for the item.
101151
*
102152
* @param context The context item to resolve.
103153
* @param token A cancellation token.
104154
*/
105155
resolveChatContext(context: T, token: CancellationToken): ProviderResult<ChatContextItem>;
106156
}
107157

158+
/**
159+
* @deprecated Use {@link ChatWorkspaceContextProvider}, {@link ChatExplicitContextProvider}, or {@link ChatResourceContextProvider} instead.
160+
*/
161+
export interface ChatContextProvider<T extends ChatContextItem = ChatContextItem> {
162+
163+
/**
164+
* An optional event that should be fired when the workspace chat context has changed.
165+
* @deprecated Use {@link ChatWorkspaceContextProvider.onDidChangeWorkspaceChatContext} instead.
166+
*/
167+
onDidChangeWorkspaceChatContext?: Event<void>;
168+
169+
/**
170+
* Provide a list of chat context items to be included as workspace context for all chat requests.
171+
* @deprecated Use {@link ChatWorkspaceContextProvider.provideChatContext} instead.
172+
*/
173+
provideWorkspaceChatContext?(token: CancellationToken): ProviderResult<T[]>;
174+
175+
/**
176+
* Provide a list of chat context items that a user can choose from.
177+
* @deprecated Use {@link ChatExplicitContextProvider.provideChatContext} instead.
178+
*/
179+
provideChatContextExplicit?(token: CancellationToken): ProviderResult<T[]>;
180+
181+
/**
182+
* Given a particular resource, provide a chat context item for it.
183+
* @deprecated Use {@link ChatResourceContextProvider.provideChatContext} instead.
184+
*/
185+
provideChatContextForResource?(options: { resource: Uri }, token: CancellationToken): ProviderResult<T | undefined>;
186+
187+
/**
188+
* If a chat context item is provided without a `value`, this method is called to resolve the `value` for the item.
189+
* @deprecated Use the `resolveChatContext` method on the specific provider type instead.
190+
*/
191+
resolveChatContext?(context: T, token: CancellationToken): ProviderResult<ChatContextItem>;
192+
}
193+
108194
}

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

Lines changed: 137 additions & 9 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: 1
7+
68
declare module 'vscode' {
79

810
export interface ChatParticipant {
@@ -96,6 +98,108 @@ declare module 'vscode' {
9698
constructor(title: string, message: string | MarkdownString, data: any, buttons?: string[]);
9799
}
98100

101+
/**
102+
* An option for a question in a carousel.
103+
*/
104+
export interface ChatQuestionOption {
105+
/**
106+
* Unique identifier for the option.
107+
*/
108+
id: string;
109+
/**
110+
* The display label for the option.
111+
*/
112+
label: string;
113+
/**
114+
* The value returned when this option is selected.
115+
*/
116+
value: unknown;
117+
}
118+
119+
/**
120+
* The type of question for a chat question carousel.
121+
*/
122+
export enum ChatQuestionType {
123+
/**
124+
* A free-form text input question.
125+
*/
126+
Text = 1,
127+
/**
128+
* A single-select question with radio buttons.
129+
*/
130+
SingleSelect = 2,
131+
/**
132+
* A multi-select question with checkboxes.
133+
*/
134+
MultiSelect = 3
135+
}
136+
137+
/**
138+
* A question to be displayed in a question carousel.
139+
*/
140+
export class ChatQuestion {
141+
/**
142+
* Unique identifier for the question.
143+
*/
144+
id: string;
145+
/**
146+
* The type of question: Text for free-form input, SingleSelect for radio buttons, MultiSelect for checkboxes.
147+
*/
148+
type: ChatQuestionType;
149+
/**
150+
* The title/header of the question.
151+
*/
152+
title: string;
153+
/**
154+
* Optional detailed message or description for the question.
155+
*/
156+
message?: string | MarkdownString;
157+
/**
158+
* Options for singleSelect or multiSelect questions.
159+
*/
160+
options?: ChatQuestionOption[];
161+
/**
162+
* The id(s) of the default selected option(s).
163+
* For SingleSelect, this should be a single option id.
164+
* For MultiSelect, this can be an array of option ids.
165+
*/
166+
defaultValue?: string | string[];
167+
/**
168+
* Whether to allow free-form text input in addition to predefined options.
169+
* When true, users can provide their own text answer even for SingleSelect or MultiSelect questions.
170+
*/
171+
allowFreeformInput?: boolean;
172+
173+
constructor(
174+
id: string,
175+
type: ChatQuestionType,
176+
title: string,
177+
options?: {
178+
message?: string | MarkdownString;
179+
options?: ChatQuestionOption[];
180+
defaultValue?: string | string[];
181+
allowFreeformInput?: boolean;
182+
}
183+
);
184+
}
185+
186+
/**
187+
* A carousel view for presenting multiple questions inline in the chat.
188+
* The UI is displayed but does not block the chat input.
189+
*/
190+
export class ChatResponseQuestionCarouselPart {
191+
/**
192+
* The questions to display in the carousel.
193+
*/
194+
questions: ChatQuestion[];
195+
/**
196+
* Whether users can skip answering the questions.
197+
*/
198+
allowSkip: boolean;
199+
200+
constructor(questions: ChatQuestion[], allowSkip?: boolean);
201+
}
202+
99203
export class ChatResponseCodeCitationPart {
100204
value: Uri;
101205
license: string;
@@ -162,6 +266,20 @@ declare module 'vscode' {
162266
output: McpToolInvocationContentData[];
163267
}
164268

269+
export enum ChatTodoStatus {
270+
NotStarted = 1,
271+
InProgress = 2,
272+
Completed = 3
273+
}
274+
275+
export interface ChatTodoToolInvocationData {
276+
todoList: Array<{
277+
id: number;
278+
title: string;
279+
status: ChatTodoStatus;
280+
}>;
281+
}
282+
165283
export class ChatToolInvocationPart {
166284
toolName: string;
167285
toolCallId: string;
@@ -171,8 +289,8 @@ declare module 'vscode' {
171289
pastTenseMessage?: string | MarkdownString;
172290
isConfirmed?: boolean;
173291
isComplete?: boolean;
174-
toolSpecificData?: ChatTerminalToolInvocationData;
175-
fromSubAgent?: boolean;
292+
toolSpecificData?: ChatTerminalToolInvocationData | ChatMcpToolInvocationData | ChatTodoToolInvocationData;
293+
subAgentInvocationId?: string;
176294
presentation?: 'hidden' | 'hiddenAfterComplete' | undefined;
177295

178296
constructor(toolName: string, toolCallId: string, isError?: boolean);
@@ -244,7 +362,7 @@ declare module 'vscode' {
244362
constructor(uris: Uri[], callback: () => Thenable<unknown>);
245363
}
246364

247-
export type ExtendedChatResponsePart = ChatResponsePart | ChatResponseTextEditPart | ChatResponseNotebookEditPart | ChatResponseConfirmationPart | ChatResponseCodeCitationPart | ChatResponseReferencePart2 | ChatResponseMovePart | ChatResponseExtensionsPart | ChatResponsePullRequestPart | ChatPrepareToolInvocationPart | ChatToolInvocationPart | ChatResponseMultiDiffPart | ChatResponseThinkingProgressPart | ChatResponseExternalEditPart;
365+
export type ExtendedChatResponsePart = ChatResponsePart | ChatResponseTextEditPart | ChatResponseNotebookEditPart | ChatResponseWorkspaceEditPart | ChatResponseConfirmationPart | ChatResponseCodeCitationPart | ChatResponseReferencePart2 | ChatResponseMovePart | ChatResponseExtensionsPart | ChatResponsePullRequestPart | ChatToolInvocationPart | ChatResponseMultiDiffPart | ChatResponseThinkingProgressPart | ChatResponseExternalEditPart | ChatResponseQuestionCarouselPart;
248366
export class ChatResponseWarningPart {
249367
value: MarkdownString;
250368
constructor(value: string | MarkdownString);
@@ -408,6 +526,15 @@ declare module 'vscode' {
408526
*/
409527
confirmation(title: string, message: string | MarkdownString, data: any, buttons?: string[]): void;
410528

529+
/**
530+
* Show an inline carousel of questions to gather information from the user.
531+
* This is a blocking call that waits for the user to submit or skip the questions.
532+
* @param questions Array of questions to display to the user
533+
* @param allowSkip Whether the user can skip questions without answering
534+
* @returns A promise that resolves with the user's answers, or undefined if skipped
535+
*/
536+
questionCarousel(questions: ChatQuestion[], allowSkip?: boolean): Thenable<Record<string, unknown> | undefined>;
537+
411538
/**
412539
* Push a warning to this stream. Short-hand for
413540
* `push(new ChatResponseWarningPart(message))`.
@@ -442,6 +569,13 @@ declare module 'vscode' {
442569
push(part: ExtendedChatResponsePart): void;
443570

444571
clearToPreviousToolInvocation(reason: ChatResponseClearToPreviousToolInvocationReason): void;
572+
573+
/**
574+
* Report token usage information for this request.
575+
* This is typically called when the underlying language model provides usage statistics.
576+
* @param usage Token usage information including prompt and completion tokens
577+
*/
578+
usage(usage: ChatResultUsage): void;
445579
}
446580

447581
export enum ChatResponseReferencePartStatusKind {
@@ -633,12 +767,6 @@ declare module 'vscode' {
633767
* An optional detail string that will be rendered at the end of the response in certain UI contexts.
634768
*/
635769
details?: string;
636-
637-
/**
638-
* Token usage information for this request, if available.
639-
* This is typically provided by the underlying language model.
640-
*/
641-
readonly usage?: ChatResultUsage;
642770
}
643771

644772
export namespace chat {

0 commit comments

Comments
 (0)