Skip to content

Commit cfe8020

Browse files
authored
Add ChatErrorLevel to ChatErrorDetails (microsoft#242139)
We need this so that the error when the rate limit is exceeded can show as 'info' without having to set `responseIsFiltered`
1 parent 3fdefcd commit cfe8020

File tree

7 files changed

+33
-9
lines changed

7 files changed

+33
-9
lines changed

src/vs/platform/extensions/common/extensionsApiProposals.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ const _allApiProposals = {
3333
},
3434
chatParticipantPrivate: {
3535
proposal: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.chatParticipantPrivate.d.ts',
36-
version: 4
36+
version: 5
3737
},
3838
chatProvider: {
3939
proposal: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.chatProvider.d.ts',

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1806,6 +1806,7 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I
18061806
TextSearchContext2: TextSearchContext2,
18071807
TextSearchMatch2: TextSearchMatch2,
18081808
TextSearchCompleteMessageTypeNew: TextSearchCompleteMessageType,
1809+
ChatErrorLevel: extHostTypes.ChatErrorLevel,
18091810
};
18101811
};
18111812
}

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4750,6 +4750,12 @@ export class PreparedTerminalToolInvocation {
47504750
) { }
47514751
}
47524752

4753+
export enum ChatErrorLevel {
4754+
Info = 0,
4755+
Warning = 1,
4756+
Error = 2
4757+
}
4758+
47534759
export class LanguageModelChatMessage implements vscode.LanguageModelChatMessage {
47544760

47554761
static User(content: string | (LanguageModelTextPart | LanguageModelToolResultPart | LanguageModelToolCallPart)[], name?: string): LanguageModelChatMessage {

src/vs/workbench/contrib/chat/browser/chatContentParts/chatWarningContentPart.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,15 @@ import { Disposable } from '../../../../../base/common/lifecycle.js';
1111
import { MarkdownRenderer } from '../../../../../editor/browser/widget/markdownRenderer/browser/markdownRenderer.js';
1212
import { IChatContentPart } from './chatContentParts.js';
1313
import { IChatProgressRenderableResponseContent } from '../../common/chatModel.js';
14+
import { ChatErrorLevel } from '../../common/chatService.js';
1415

1516
const $ = dom.$;
1617

1718
export class ChatWarningContentPart extends Disposable implements IChatContentPart {
1819
public readonly domNode: HTMLElement;
1920

2021
constructor(
21-
kind: 'info' | 'warning' | 'error',
22+
kind: ChatErrorLevel,
2223
content: IMarkdownString,
2324
renderer: MarkdownRenderer,
2425
) {
@@ -28,15 +29,15 @@ export class ChatWarningContentPart extends Disposable implements IChatContentPa
2829
let icon;
2930
let iconClass;
3031
switch (kind) {
31-
case 'warning':
32+
case ChatErrorLevel.Warning:
3233
icon = Codicon.warning;
3334
iconClass = '.chat-warning-codicon';
3435
break;
35-
case 'error':
36+
case ChatErrorLevel.Error:
3637
icon = Codicon.error;
3738
iconClass = '.chat-error-codicon';
3839
break;
39-
case 'info':
40+
case ChatErrorLevel.Info:
4041
icon = Codicon.info;
4142
iconClass = '.chat-info-codicon';
4243
break;

src/vs/workbench/contrib/chat/browser/chatListRenderer.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ import { ChatAgentLocation, IChatAgentMetadata } from '../common/chatAgents.js';
4747
import { ChatContextKeys } from '../common/chatContextKeys.js';
4848
import { IChatRequestVariableEntry, IChatTextEditGroup } from '../common/chatModel.js';
4949
import { chatSubcommandLeader } from '../common/chatParserTypes.js';
50-
import { ChatAgentVoteDirection, ChatAgentVoteDownReason, IChatConfirmation, IChatContentReference, IChatFollowup, IChatMarkdownContent, IChatTask, IChatToolInvocation, IChatToolInvocationSerialized, IChatTreeData, IChatUndoStop } from '../common/chatService.js';
50+
import { ChatAgentVoteDirection, ChatAgentVoteDownReason, ChatErrorLevel, IChatConfirmation, IChatContentReference, IChatFollowup, IChatMarkdownContent, IChatTask, IChatToolInvocation, IChatToolInvocationSerialized, IChatTreeData, IChatUndoStop } from '../common/chatService.js';
5151
import { IChatCodeCitations, IChatReferences, IChatRendererContent, IChatRequestViewModel, IChatResponseViewModel, IChatWorkingProgress, isRequestVM, isResponseVM } from '../common/chatViewModel.js';
5252
import { getNWords } from '../common/chatWordCounter.js';
5353
import { CodeBlockModelCollection } from '../common/codeBlockModelCollection.js';
@@ -613,7 +613,8 @@ export class ChatListItemRenderer extends Disposable implements ITreeRenderer<Ch
613613
templateData.value.appendChild(renderedError.domNode);
614614
templateData.elementDisposables.add(renderedError.onDidChangeHeight(() => this.updateItemHeight(templateData)));
615615
} else {
616-
const renderedError = this.instantiationService.createInstance(ChatWarningContentPart, element.errorDetails.responseIsFiltered ? 'info' : 'error', new MarkdownString(element.errorDetails.message), this.renderer);
616+
const level = element.errorDetails.level ?? (element.errorDetails.responseIsFiltered ? ChatErrorLevel.Info : ChatErrorLevel.Error);
617+
const renderedError = this.instantiationService.createInstance(ChatWarningContentPart, level, new MarkdownString(element.errorDetails.message), this.renderer);
617618
templateData.elementDisposables.add(renderedError);
618619
templateData.value.appendChild(renderedError.domNode);
619620
}
@@ -882,7 +883,7 @@ export class ChatListItemRenderer extends Disposable implements ITreeRenderer<Ch
882883
} else if (content.kind === 'confirmation') {
883884
return this.renderConfirmation(context, content, templateData);
884885
} else if (content.kind === 'warning') {
885-
return this.instantiationService.createInstance(ChatWarningContentPart, 'warning', content.content, this.renderer);
886+
return this.instantiationService.createInstance(ChatWarningContentPart, ChatErrorLevel.Warning, content.content, this.renderer);
886887
} else if (content.kind === 'markdownContent') {
887888
return this.renderMarkdown(content, templateData, context);
888889
} else if (content.kind === 'references') {

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,19 @@ export interface IChatRequest {
2828
variables: Record<string, IChatRequestVariableValue[]>;
2929
}
3030

31+
export enum ChatErrorLevel {
32+
Info = 0,
33+
Warning = 1,
34+
Error = 2
35+
}
36+
3137
export interface IChatResponseErrorDetails {
3238
message: string;
3339
responseIsIncomplete?: boolean;
3440
responseIsFiltered?: boolean;
3541
responseIsRedacted?: boolean;
3642
isQuotaExceeded?: boolean;
43+
level?: ChatErrorLevel;
3744
}
3845

3946
export interface IChatResponseProgressFileTreeData {

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Licensed under the MIT License. See License.txt in the project root for license information.
44
*--------------------------------------------------------------------------------------------*/
55

6-
// version: 4
6+
// version: 5
77

88
declare module 'vscode' {
99

@@ -83,13 +83,21 @@ declare module 'vscode' {
8383
supportIssueReporting?: boolean;
8484
}
8585

86+
export enum ChatErrorLevel {
87+
Info = 0,
88+
Warning = 1,
89+
Error = 2,
90+
}
91+
8692
export interface ChatErrorDetails {
8793
/**
8894
* If set to true, the message content is completely hidden. Only ChatErrorDetails#message will be shown.
8995
*/
9096
responseIsRedacted?: boolean;
9197

9298
isQuotaExceeded?: boolean;
99+
100+
level?: ChatErrorLevel;
93101
}
94102

95103
export namespace chat {

0 commit comments

Comments
 (0)