Skip to content

Commit 0a85581

Browse files
committed
Some chat session improvements
Use "chat" word instead of "session", and use "new chat" instead of "clear". Add "Clear all chats" command to delete all history microsoft/vscode-copilot-release#725
1 parent 12443ca commit 0a85581

File tree

7 files changed

+59
-42
lines changed

7 files changed

+59
-42
lines changed

src/vs/workbench/contrib/chat/browser/actions/chatActions.ts

+21-11
Original file line numberDiff line numberDiff line change
@@ -155,14 +155,11 @@ export function registerChatActions() {
155155

156156
registerAction2(ChatSubmitSecondaryAgentEditorAction);
157157

158-
registerAction2(class ClearChatHistoryAction extends Action2 {
158+
registerAction2(class ClearChatInputHistoryAction extends Action2 {
159159
constructor() {
160160
super({
161-
id: 'workbench.action.chatEditor.clearHistory',
162-
title: {
163-
value: localize('interactiveSession.clearHistory.label', "Clear Input History"),
164-
original: 'Clear Input History'
165-
},
161+
id: 'workbench.action.chat.clearInputHistory',
162+
title: localize2('interactiveSession.clearHistory.label', "Clear Input History"),
166163
precondition: CONTEXT_PROVIDER_EXISTS,
167164
category: CHAT_CATEGORY,
168165
f1: true,
@@ -174,6 +171,22 @@ export function registerChatActions() {
174171
}
175172
});
176173

174+
registerAction2(class ClearChatHistoryAction extends Action2 {
175+
constructor() {
176+
super({
177+
id: 'workbench.action.chat.clearHistory',
178+
title: localize2('chat.clear.label', "Clear All Workspace Chats"),
179+
precondition: CONTEXT_PROVIDER_EXISTS,
180+
category: CHAT_CATEGORY,
181+
f1: true,
182+
});
183+
}
184+
async run(accessor: ServicesAccessor, ...args: any[]) {
185+
const chatService = accessor.get(IChatService);
186+
chatService.clearAllHistoryEntries();
187+
}
188+
});
189+
177190
registerAction2(class FocusChatAction extends EditorAction2 {
178191
constructor() {
179192
super({
@@ -257,10 +270,7 @@ export function getOpenChatEditorAction(id: string, label: string, when?: string
257270
const getHistoryChatActionDescriptorForViewTitle = (viewId: string, providerId: string): Readonly<IAction2Options> & { viewId: string } => ({
258271
viewId,
259272
id: `workbench.action.chat.${providerId}.history`,
260-
title: {
261-
value: localize('interactiveSession.history.label', "Show History"),
262-
original: 'Show History'
263-
},
273+
title: localize2('chat.history.label', "Show Chats"),
264274
menu: {
265275
id: MenuId.ViewTitle,
266276
when: ContextKeyExpr.equals('view', viewId),
@@ -295,7 +305,7 @@ export function getHistoryAction(viewId: string, providerId: string) {
295305
}));
296306
const selection = await quickInputService.pick(picks,
297307
{
298-
placeHolder: localize('interactiveSession.history.pick', "Switch to chat session"),
308+
placeHolder: localize('interactiveSession.history.pick', "Switch to chat"),
299309
onDidTriggerItemButton: context => {
300310
chatService.removeHistoryEntry(context.item.chat.sessionId);
301311
context.removeItem();

src/vs/workbench/contrib/chat/browser/actions/chatClearActions.ts

+14-14
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,15 @@ import { ChatEditorInput } from 'vs/workbench/contrib/chat/browser/chatEditorInp
2020
import { ChatViewPane } from 'vs/workbench/contrib/chat/browser/chatViewPane';
2121
import { CONTEXT_IN_CHAT_SESSION, CONTEXT_PROVIDER_EXISTS } from 'vs/workbench/contrib/chat/common/chatContextKeys';
2222

23-
export const ACTION_ID_CLEAR_CHAT = `workbench.action.chat.clear`;
23+
export const ACTION_ID_NEW_CHAT = `workbench.action.chat.newChat`;
2424

25-
export function registerClearActions() {
25+
export function registerNewChatActions() {
2626

27-
registerAction2(class ClearEditorAction extends Action2 {
27+
registerAction2(class NewChatEditorAction extends Action2 {
2828
constructor() {
2929
super({
30-
id: 'workbench.action.chatEditor.clear',
31-
title: localize2('chat.newSession.label', "New Session"),
30+
id: 'workbench.action.chatEditor.newChat',
31+
title: localize2('chat.newChat.label', "New Chat"),
3232
icon: Codicon.plus,
3333
f1: false,
3434
precondition: CONTEXT_PROVIDER_EXISTS,
@@ -50,10 +50,10 @@ export function registerClearActions() {
5050
registerAction2(class GlobalClearChatAction extends Action2 {
5151
constructor() {
5252
super({
53-
id: ACTION_ID_CLEAR_CHAT,
54-
title: localize2('chat.newSession.label', "New Session"),
53+
id: ACTION_ID_NEW_CHAT,
54+
title: localize2('chat.newChat.label', "New Chat"),
5555
category: CHAT_CATEGORY,
56-
icon: Codicon.clearAll,
56+
icon: Codicon.plus,
5757
precondition: CONTEXT_PROVIDER_EXISTS,
5858
f1: true,
5959
keybinding: {
@@ -86,10 +86,10 @@ export function registerClearActions() {
8686
});
8787
}
8888

89-
const getClearChatActionDescriptorForViewTitle = (viewId: string, providerId: string): Readonly<IAction2Options> & { viewId: string } => ({
89+
const getNewChatActionDescriptorForViewTitle = (viewId: string, providerId: string): Readonly<IAction2Options> & { viewId: string } => ({
9090
viewId,
91-
id: `workbench.action.chat.${providerId}.clear`,
92-
title: localize2('chat.newSession.label', "New Session"),
91+
id: `workbench.action.chat.${providerId}.newChat`,
92+
title: localize2('chat.newChat.label', "New Chat"),
9393
menu: {
9494
id: MenuId.ViewTitle,
9595
when: ContextKeyExpr.equals('view', viewId),
@@ -102,10 +102,10 @@ const getClearChatActionDescriptorForViewTitle = (viewId: string, providerId: st
102102
f1: false
103103
});
104104

105-
export function getClearAction(viewId: string, providerId: string) {
106-
return class ClearAction extends ViewAction<ChatViewPane> {
105+
export function getNewChatAction(viewId: string, providerId: string) {
106+
return class NewChatAction extends ViewAction<ChatViewPane> {
107107
constructor() {
108-
super(getClearChatActionDescriptorForViewTitle(viewId, providerId));
108+
super(getNewChatActionDescriptorForViewTitle(viewId, providerId));
109109
}
110110

111111
async runInView(accessor: ServicesAccessor, view: ChatViewPane) {

src/vs/workbench/contrib/chat/browser/actions/chatMoveActions.ts

+8-8
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ enum MoveToNewLocation {
2929
const getMoveToChatActionDescriptorForViewTitle = (viewId: string, providerId: string, moveTo: MoveToNewLocation): Readonly<IAction2Options> & { viewId: string } => ({
3030
id: `workbench.action.chat.${providerId}.openIn${moveTo}`,
3131
title: {
32-
value: moveTo === MoveToNewLocation.Editor ? localize('chat.openInEditor.label', "Open Session in Editor") : localize('chat.openInNewWindow.label', "Open Session in New Window"),
33-
original: moveTo === MoveToNewLocation.Editor ? 'Open Session in Editor' : 'Open Session in New Window',
32+
value: moveTo === MoveToNewLocation.Editor ? localize('chat.openInEditor.label', "Open Chat in Editor") : localize('chat.openInNewWindow.label', "Open Chat in New Window"),
33+
original: moveTo === MoveToNewLocation.Editor ? 'Open Chat in Editor' : 'Open Chat in New Window',
3434
},
3535
category: CHAT_CATEGORY,
3636
precondition: CONTEXT_PROVIDER_EXISTS,
@@ -78,8 +78,8 @@ export function registerMoveActions() {
7878
super({
7979
id: `workbench.action.chat.openInEditor`,
8080
title: {
81-
value: localize('interactiveSession.openInEditor.label', "Open Session in Editor"),
82-
original: 'Open Session in Editor'
81+
value: localize('interactiveSession.openInEditor.label', "Open Chat in Editor"),
82+
original: 'Open Chat in Editor'
8383
},
8484
category: CHAT_CATEGORY,
8585
precondition: CONTEXT_PROVIDER_EXISTS,
@@ -98,8 +98,8 @@ export function registerMoveActions() {
9898
super({
9999
id: `workbench.action.chat.openInNewWindow`,
100100
title: {
101-
value: localize('interactiveSession.openInNewWindow.label', "Open Session in New Window"),
102-
original: 'Open Session In New Window'
101+
value: localize('interactiveSession.openInNewWindow.label', "Open Chat in New Window"),
102+
original: 'Open Chat In New Window'
103103
},
104104
category: CHAT_CATEGORY,
105105
precondition: CONTEXT_PROVIDER_EXISTS,
@@ -117,8 +117,8 @@ export function registerMoveActions() {
117117
super({
118118
id: `workbench.action.chat.openInSidebar`,
119119
title: {
120-
value: localize('interactiveSession.openInSidebar.label', "Open Session in Side Bar"),
121-
original: 'Open Session in Side Bar'
120+
value: localize('interactiveSession.openInSidebar.label', "Open Chat in Side Bar"),
121+
original: 'Open Chat in Side Bar'
122122
},
123123
category: CHAT_CATEGORY,
124124
precondition: CONTEXT_PROVIDER_EXISTS,

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

+6-6
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ import { IEditorResolverService, RegisteredEditorPriority } from 'vs/workbench/s
3737
import { LifecyclePhase } from 'vs/workbench/services/lifecycle/common/lifecycle';
3838
import '../common/chatColors';
3939
import { registerMoveActions } from 'vs/workbench/contrib/chat/browser/actions/chatMoveActions';
40-
import { ACTION_ID_CLEAR_CHAT, registerClearActions } from 'vs/workbench/contrib/chat/browser/actions/chatClearActions';
40+
import { ACTION_ID_NEW_CHAT, registerNewChatActions } from 'vs/workbench/contrib/chat/browser/actions/chatClearActions';
4141
import { AccessibleViewType, IAccessibleViewService } from 'vs/workbench/contrib/accessibility/browser/accessibleView';
4242
import { isResponseVM } from 'vs/workbench/contrib/chat/common/chatViewModel';
4343
import { CONTEXT_IN_CHAT_SESSION } from 'vs/workbench/contrib/chat/common/chatContextKeys';
@@ -227,12 +227,12 @@ class ChatSlashStaticSlashCommandsContribution extends Disposable {
227227
) {
228228
super();
229229
this._store.add(slashCommandService.registerSlashCommand({
230-
command: 'clear',
231-
detail: nls.localize('clear', "Clear the session"),
232-
sortText: 'z2_clear',
230+
command: 'newChat',
231+
detail: nls.localize('newChat', "Start a new chat"),
232+
sortText: 'z2_newChat',
233233
executeImmediately: true
234234
}, async () => {
235-
commandService.executeCommand(ACTION_ID_CLEAR_CHAT);
235+
commandService.executeCommand(ACTION_ID_NEW_CHAT);
236236
}));
237237
this._store.add(slashCommandService.registerSlashCommand({
238238
command: 'help',
@@ -295,7 +295,7 @@ registerChatExecuteActions();
295295
registerQuickChatActions();
296296
registerChatExportActions();
297297
registerMoveActions();
298-
registerClearActions();
298+
registerNewChatActions();
299299

300300
registerSingleton(IChatService, ChatService, InstantiationType.Delayed);
301301
registerSingleton(IChatContributionService, ChatContributionService, InstantiationType.Delayed);

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { ViewPaneContainer } from 'vs/workbench/browser/parts/views/viewPaneCont
1414
import { IWorkbenchContribution, IWorkbenchContributionsRegistry, Extensions as WorkbenchExtensions } from 'vs/workbench/common/contributions';
1515
import { IViewContainersRegistry, IViewDescriptor, IViewsRegistry, ViewContainer, ViewContainerLocation, Extensions as ViewExtensions } from 'vs/workbench/common/views';
1616
import { getHistoryAction, getOpenChatEditorAction } from 'vs/workbench/contrib/chat/browser/actions/chatActions';
17-
import { getClearAction } from 'vs/workbench/contrib/chat/browser/actions/chatClearActions';
17+
import { getNewChatAction } from 'vs/workbench/contrib/chat/browser/actions/chatClearActions';
1818
import { getMoveToEditorAction, getMoveToNewWindowAction } from 'vs/workbench/contrib/chat/browser/actions/chatMoveActions';
1919
import { getQuickChatActionForProvider } from 'vs/workbench/contrib/chat/browser/actions/chatQuickInputActions';
2020
import { CHAT_SIDEBAR_PANEL_ID, ChatViewPane, IChatViewOptions } from 'vs/workbench/contrib/chat/browser/chatViewPane';
@@ -135,7 +135,7 @@ export class ChatExtensionPointHandler implements IWorkbenchContribution {
135135
// Actions in view title
136136
const disposables = new DisposableStore();
137137
disposables.add(registerAction2(getHistoryAction(viewId, providerDescriptor.id)));
138-
disposables.add(registerAction2(getClearAction(viewId, providerDescriptor.id)));
138+
disposables.add(registerAction2(getNewChatAction(viewId, providerDescriptor.id)));
139139
disposables.add(registerAction2(getMoveToEditorAction(viewId, providerDescriptor.id)));
140140
disposables.add(registerAction2(getMoveToNewWindowAction(viewId, providerDescriptor.id)));
141141

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

+1
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,7 @@ export interface IChatService {
314314
addCompleteRequest(sessionId: string, message: IParsedChatRequest | string, response: IChatCompleteResponse): void;
315315
sendRequestToProvider(sessionId: string, message: IChatDynamicRequest): void;
316316
getHistory(): IChatDetail[];
317+
clearAllHistoryEntries(): void;
317318
removeHistoryEntry(sessionId: string): void;
318319

319320
onDidPerformUserAction: Event<IChatUserActionEvent>;

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

+7-1
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ export class ChatService extends Disposable implements IChatService {
135135

136136
private readonly _sessionModels = this._register(new DisposableMap<string, ChatModel>());
137137
private readonly _pendingRequests = this._register(new DisposableMap<string, CancellationTokenSource>());
138-
private readonly _persistedSessions: ISerializableChatsData;
138+
private _persistedSessions: ISerializableChatsData;
139139
private readonly _hasProvider: IContextKey<boolean>;
140140

141141
private _transferredSessionData: IChatTransferredSessionData | undefined;
@@ -331,6 +331,12 @@ export class ChatService extends Disposable implements IChatService {
331331

332332
removeHistoryEntry(sessionId: string): void {
333333
delete this._persistedSessions[sessionId];
334+
this.saveState();
335+
}
336+
337+
clearAllHistoryEntries(): void {
338+
this._persistedSessions = {};
339+
this.saveState();
334340
}
335341

336342
startSession(providerId: string, token: CancellationToken): ChatModel {

0 commit comments

Comments
 (0)