Skip to content

Commit 7d09f80

Browse files
authored
tweak editing overlay (microsoft#232977)
* dedupe edit actions * * add open view command * use text and icons * give telemetry source a name
1 parent 52d5bf2 commit 7d09f80

File tree

3 files changed

+38
-42
lines changed

3 files changed

+38
-42
lines changed

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

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { isCodeEditor } from '../../../../editor/browser/editorBrowser.js';
66
import { localize2 } from '../../../../nls.js';
77
import { ServicesAccessor } from '../../../../editor/browser/editorExtensions.js';
88
import { Codicon } from '../../../../base/common/codicons.js';
9-
import { Action2, MenuId, registerAction2 } from '../../../../platform/actions/common/actions.js';
9+
import { Action2, registerAction2 } from '../../../../platform/actions/common/actions.js';
1010
import { KeybindingWeight } from '../../../../platform/keybinding/common/keybindingsRegistry.js';
1111
import { KeyCode, KeyMod } from '../../../../base/common/keyCodes.js';
1212
import { CHAT_CATEGORY } from './actions/chatActions.js';
@@ -35,13 +35,7 @@ abstract class NavigateAction extends Action2 {
3535
weight: KeybindingWeight.EditorContrib,
3636
when: ContextKeyExpr.and(ctxHasEditorModification, EditorContextKeys.focus),
3737
},
38-
f1: true,
39-
menu: {
40-
id: MenuId.EditorTitle,
41-
group: 'navigation',
42-
order: next ? -100 : -101,
43-
when: ctxHasEditorModification
44-
}
38+
f1: true
4539
});
4640
}
4741

@@ -75,12 +69,7 @@ abstract class AcceptDiscardAction extends Action2 {
7569
icon: accept
7670
? Codicon.check
7771
: Codicon.discard,
78-
menu: {
79-
id: MenuId.EditorTitle,
80-
group: 'navigation',
81-
order: accept ? -103 : -102,
82-
when: ctxHasEditorModification
83-
}
72+
f1: true,
8473
});
8574
}
8675

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

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ import { Range } from '../../../../editor/common/core/range.js';
1919
import { Codicon } from '../../../../base/common/codicons.js';
2020
import { ThemeIcon } from '../../../../base/common/themables.js';
2121
import { ChatEditorController } from './chatEditorController.js';
22+
import { IViewsService } from '../../../services/views/common/viewsService.js';
23+
import { EDITS_VIEW_ID } from './chat.js';
24+
import { ActionViewItem } from '../../../../base/browser/ui/actionbar/actionViewItems.js';
2225

2326
class ChatEditorOverlayWidget implements IOverlayWidget {
2427

@@ -33,20 +36,21 @@ class ChatEditorOverlayWidget implements IOverlayWidget {
3336
constructor(
3437
private readonly _editor: ICodeEditor,
3538
@IEditorService private readonly _editorService: IEditorService,
39+
@IViewsService private readonly _viewsService: IViewsService,
3640
@IInstantiationService instaService: IInstantiationService,
3741
) {
3842
this._domNode = document.createElement('div');
3943
this._domNode.classList.add('chat-editor-overlay-widget');
4044

41-
const progressNode = document.createElement('div');
42-
progressNode.classList.add('progress-container');
43-
progressNode.classList.add(...ThemeIcon.asClassNameArray(ThemeIcon.modify(Codicon.loading, 'spin')));
44-
this._domNode.appendChild(progressNode);
45-
46-
const toolbarContainer = document.createElement('div');
47-
toolbarContainer.classList.add('toolbar-container');
48-
this._domNode.appendChild(toolbarContainer);
49-
this._toolbar = instaService.createInstance(WorkbenchToolBar, toolbarContainer, {});
45+
this._toolbar = instaService.createInstance(WorkbenchToolBar, this._domNode, {
46+
telemetrySource: 'chatEditor.overlayToolbar',
47+
actionViewItemProvider: (action, options) => {
48+
if (action.id === 'accept' || action.id === 'discard') {
49+
return new ActionViewItem(undefined, action, { ...options, label: true, icon: false });
50+
}
51+
return undefined;
52+
}
53+
});
5054
}
5155

5256
dispose() {
@@ -104,9 +108,20 @@ class ChatEditorOverlayWidget implements IOverlayWidget {
104108
this._domNode.classList.toggle('busy', busy);
105109

106110
const groups = [[
111+
toAction({
112+
id: 'open',
113+
label: localize('open', 'Open Chat Edit'),
114+
class: ThemeIcon.asClassName(busy
115+
? ThemeIcon.modify(Codicon.loading, 'spin')
116+
: Codicon.goToEditingSession),
117+
run: async () => {
118+
await this._viewsService.openView(EDITS_VIEW_ID);
119+
}
120+
}),
107121
toAction({
108122
id: 'accept',
109-
label: localize('accept', 'Accept Chat Edits'),
123+
label: localize('accept', 'Accept'),
124+
tooltip: localize('acceptTooltip', 'Accept Chat Edits'),
110125
class: ThemeIcon.asClassName(Codicon.check),
111126
enabled: !busy && modified,
112127
run: () => {
@@ -116,7 +131,8 @@ class ChatEditorOverlayWidget implements IOverlayWidget {
116131
}),
117132
toAction({
118133
id: 'discard',
119-
label: localize('discard', 'Discard Chat Edits'),
134+
label: localize('discard', 'Discard'),
135+
tooltip: localize('discardTooltip', 'Discard Chat Edits'),
120136
class: ThemeIcon.asClassName(Codicon.discard),
121137
enabled: !busy && modified,
122138
run: () => {

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

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,35 +4,26 @@
44
*--------------------------------------------------------------------------------------------*/
55

66
.chat-editor-overlay-widget {
7-
padding: 4px;
7+
padding: 0px;
88
color: var(--vscode-button-foreground);
99
background-color: var(--vscode-button-background);
10-
border-radius: 2px;
10+
border-radius: 5px;
1111
border: 1px solid var(--vscode-contrastBorder);
1212
display: flex;
1313
align-items: center
1414
}
1515

16-
17-
.chat-editor-overlay-widget .progress-container {
18-
display: none;
19-
padding: 0 4px;
20-
}
21-
22-
.chat-editor-overlay-widget.busy .progress-container {
23-
display: inherit;
24-
}
25-
26-
.chat-editor-overlay-widget .progress-container.codicon {
27-
color: var(--vscode-button-foreground);
16+
.chat-editor-overlay-widget .action-item > .action-label {
17+
padding: 5px;
2818
}
2919

30-
.chat-editor-overlay-widget .toolbar-container .action-item > .action-label.codicon {
20+
.chat-editor-overlay-widget .action-item > .action-label.codicon {
3121
color: var(--vscode-button-foreground);
3222
}
3323

34-
.chat-editor-overlay-widget .toolbar-container .action-item.disabled > .action-label.codicon::before,
35-
.chat-editor-overlay-widget .toolbar-container .action-item.disabled > .action-label.codicon {
24+
.chat-editor-overlay-widget .action-item.disabled > .action-label.codicon::before,
25+
.chat-editor-overlay-widget .action-item.disabled > .action-label.codicon,
26+
.chat-editor-overlay-widget .action-item.disabled > .action-label {
3627
color: var(--vscode-button-foreground);
3728
opacity: 0.7;
3829
}

0 commit comments

Comments
 (0)