Skip to content

Commit 29e9d4f

Browse files
committed
Fill in mode description, align with chatSetup
1 parent e5784a9 commit 29e9d4f

File tree

4 files changed

+18
-19
lines changed

4 files changed

+18
-19
lines changed

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

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ import { ChatContextKeys } from '../common/chatContextKeys.js';
7474
import { IChatEditingSession } from '../common/chatEditingService.js';
7575
import { ChatEntitlement, IChatEntitlementService } from '../common/chatEntitlementService.js';
7676
import { IChatRequestVariableEntry, isElementVariableEntry, isImageVariableEntry, isNotebookOutputVariableEntry, isPasteVariableEntry, isSCMHistoryItemVariableEntry } from '../common/chatModel.js';
77-
import { IChatMode, ChatMode2, BuiltinChatMode } from '../common/chatModes.js';
77+
import { ChatMode2, IChatMode, validateChatMode2 } from '../common/chatModes.js';
7878
import { IChatFollowup } from '../common/chatService.js';
7979
import { IChatVariablesService } from '../common/chatVariables.js';
8080
import { IChatResponseViewModel } from '../common/chatViewModel.js';
@@ -561,14 +561,8 @@ export class ChatInputPart extends Disposable implements IHistoryNavigationWidge
561561
return;
562562
}
563563

564-
mode = validateChatMode(mode) ?? ChatMode.Ask;
565-
this._currentMode = new BuiltinChatMode(mode);
566-
this.chatMode.set(mode);
567-
this._onDidChangeCurrentChatMode.fire();
568-
569-
if (storeSelection) {
570-
this.storageService.store(GlobalLastChatModeKey, mode, StorageScope.APPLICATION, StorageTarget.USER);
571-
}
564+
const mode2 = validateChatMode2(mode) ?? ChatMode2.Ask;
565+
this.setChatMode2(mode2, storeSelection);
572566
}
573567

574568
setChatMode2(mode: IChatMode, storeSelection = true): void {

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ import { coalesce } from '../../../../base/common/arrays.js';
7070
import { ThemeIcon } from '../../../../base/common/themables.js';
7171
import { IButton } from '../../../../base/browser/ui/button/button.js';
7272
import { IContextMenuService } from '../../../../platform/contextview/browser/contextView.js';
73+
import { ChatMode2 } from '../common/chatModes.js';
7374

7475
const defaultChat = {
7576
extensionId: product.defaultChatAgent?.extensionId ?? '',
@@ -109,17 +110,17 @@ class SetupAgent extends Disposable implements IChatAgentImplementation {
109110
const chatAgentService = accessor.get(IChatAgentService);
110111

111112
let id: string;
112-
let description = localize('chatDescription', "Ask Copilot");
113+
let description = ChatMode2.Ask.description;
113114
switch (location) {
114115
case ChatAgentLocation.Panel:
115116
if (mode === ChatMode.Ask) {
116117
id = 'setup.chat';
117118
} else if (mode === ChatMode.Edit) {
118119
id = 'setup.edits';
119-
description = localize('editsDescription', "Edit files in your workspace");
120+
description = ChatMode2.Edit.description;
120121
} else {
121122
id = 'setup.agent';
122-
description = localize('agentDescription', "Edit files in your workspace in agent mode");
123+
description = ChatMode2.Agent.description;
123124
}
124125
break;
125126
case ChatAgentLocation.Terminal:

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ class InputEditorDecorations extends Disposable {
115115
}
116116

117117
if (!inputValue) {
118-
const defaultAgent = this.chatAgentService.getDefaultAgent(this.widget.location, this.widget.input.currentMode);
118+
const description = this.widget.input.currentMode2.description;
119119
const decoration: IDecorationOptions[] = [
120120
{
121121
range: {
@@ -126,7 +126,7 @@ class InputEditorDecorations extends Disposable {
126126
},
127127
renderOptions: {
128128
after: {
129-
contentText: viewModel.inputPlaceholder || (defaultAgent?.description ?? ''),
129+
contentText: viewModel.inputPlaceholder || (description ?? ''),
130130
color: this.getPlaceholderColor()
131131
}
132132
}

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

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

6+
import { localize } from '../../../../nls.js';
67
import { IContextKey, IContextKeyService } from '../../../../platform/contextkey/common/contextkey.js';
78
import { createDecorator } from '../../../../platform/instantiation/common/instantiation.js';
89
import { ILogService } from '../../../../platform/log/common/log.js';
@@ -105,7 +106,8 @@ export class CustomChatMode implements IChatMode {
105106

106107
export class BuiltinChatMode implements IChatMode {
107108
constructor(
108-
public readonly kind: ChatMode
109+
public readonly kind: ChatMode,
110+
public readonly description: string
109111
) { }
110112

111113
get id(): string {
@@ -119,17 +121,19 @@ export class BuiltinChatMode implements IChatMode {
119121
}
120122

121123
export namespace ChatMode2 {
122-
export const Ask = new BuiltinChatMode(ChatMode.Ask);
123-
export const Edit = new BuiltinChatMode(ChatMode.Edit);
124-
export const Agent = new BuiltinChatMode(ChatMode.Agent);
124+
export const Ask = new BuiltinChatMode(ChatMode.Ask, localize('chatDescription', "Ask Copilot"));
125+
export const Edit = new BuiltinChatMode(ChatMode.Edit, localize('editsDescription', "Edit files in your workspace"));
126+
export const Agent = new BuiltinChatMode(ChatMode.Agent, localize('agentDescription', "Edit files in your workspace in agent mode"));
125127
}
126128

127129
export function validateChatMode2(mode: unknown): IChatMode | undefined {
128130
switch (mode) {
129131
case ChatMode.Ask:
132+
return ChatMode2.Ask;
130133
case ChatMode.Edit:
134+
return ChatMode2.Edit;
131135
case ChatMode.Agent:
132-
return new BuiltinChatMode(mode);
136+
return ChatMode2.Agent;
133137
default:
134138
if (isIChatMode(mode)) {
135139
return mode;

0 commit comments

Comments
 (0)