Skip to content

Commit 6d27939

Browse files
authored
undo button to undo requests, adds request in input (microsoft#251306)
change to undo, setting for exp
1 parent 6582eb5 commit 6d27939

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,12 @@ configurationRegistry.registerConfiguration({
239239
type: 'boolean',
240240
tags: ['experimental']
241241
},
242+
'chat.undoRequests.restoreInput': {
243+
default: true,
244+
markdownDescription: nls.localize('chat.undoRequests.restoreInput', "Controls whether the input of the chat should be restored when an undo request is made. The input will be filled with the text of the request that was restored."),
245+
type: 'boolean',
246+
tags: ['experimental']
247+
},
242248
[mcpEnabledSection]: {
243249
type: 'boolean',
244250
description: nls.localize('chat.mcp.enabled', "Enables integration with Model Context Protocol servers to provide additional tools and functionality."),

src/vs/workbench/contrib/chat/browser/chatEditing/chatEditingActions.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ registerAction2(class RemoveAction extends Action2 {
312312
title: localize2('chat.undoEdits.label', "Undo Requests"),
313313
f1: false,
314314
category: CHAT_CATEGORY,
315-
icon: Codicon.x,
315+
icon: Codicon.discard,
316316
keybinding: {
317317
primary: KeyCode.Delete,
318318
mac: {
@@ -334,9 +334,9 @@ registerAction2(class RemoveAction extends Action2 {
334334

335335
async run(accessor: ServicesAccessor, ...args: any[]) {
336336
let item: ChatTreeItem | undefined = args[0];
337+
const chatWidgetService = accessor.get(IChatWidgetService);
338+
const widget = chatWidgetService.lastFocusedWidget;
337339
if (!isResponseVM(item) && !isRequestVM(item)) {
338-
const chatWidgetService = accessor.get(IChatWidgetService);
339-
const widget = chatWidgetService.lastFocusedWidget;
340340
item = widget?.getFocus();
341341
}
342342

@@ -409,6 +409,11 @@ registerAction2(class RemoveAction extends Action2 {
409409
const snapshotRequestId = chatRequests[itemIndex].id;
410410
await session.restoreSnapshot(snapshotRequestId, undefined);
411411
}
412+
413+
if (isRequestVM(item) && configurationService.getValue('chat.undoRequests.restoreInput')) {
414+
widget?.focusInput();
415+
widget?.input.setValue(item.messageText, false);
416+
}
412417
}
413418
});
414419

src/vs/workbench/contrib/chat/browser/media/chat.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1928,7 +1928,7 @@ have to be updated for changes to the rules above, or to support more deeply nes
19281928
height: 22px;
19291929
}
19301930

1931-
.request-hover .actions-container .action-label.codicon-x {
1931+
.request-hover .actions-container .action-label.codicon-discard {
19321932
margin-top: 4px;
19331933
padding: 3px 3px;
19341934
}

0 commit comments

Comments
 (0)