Skip to content

Commit 055458f

Browse files
authored
Fix 'enter' not working in chat suggest widget (#199120)
* Fix progress codicon colors * Fix 'enter' not working in chat suggest widget Actually, we do need the EditorActions that I removed in #199099
1 parent 3b41744 commit 055458f

File tree

4 files changed

+75
-52
lines changed

4 files changed

+75
-52
lines changed

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

+62-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { ICodeEditor } from 'vs/editor/browser/editorBrowser';
1111
import { EditorAction2, ServicesAccessor } from 'vs/editor/browser/editorExtensions';
1212
import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService';
1313
import { EditorContextKeys } from 'vs/editor/common/editorContextKeys';
14-
import { localize } from 'vs/nls';
14+
import { localize, localize2 } from 'vs/nls';
1515
import { Action2, IAction2Options, MenuId, registerAction2 } from 'vs/platform/actions/common/actions';
1616
import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
1717
import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry';
@@ -26,8 +26,10 @@ import { IChatWidgetService } from 'vs/workbench/contrib/chat/browser/chat';
2626
import { IChatEditorOptions } from 'vs/workbench/contrib/chat/browser/chatEditor';
2727
import { ChatEditorInput } from 'vs/workbench/contrib/chat/browser/chatEditorInput';
2828
import { ChatViewPane } from 'vs/workbench/contrib/chat/browser/chatViewPane';
29+
import { IChatAgentService } from 'vs/workbench/contrib/chat/common/chatAgents';
2930
import { CONTEXT_IN_CHAT_INPUT, CONTEXT_IN_CHAT_SESSION, CONTEXT_PROVIDER_EXISTS, CONTEXT_REQUEST, CONTEXT_RESPONSE } from 'vs/workbench/contrib/chat/common/chatContextKeys';
3031
import { IChatContributionService } from 'vs/workbench/contrib/chat/common/chatContributionService';
32+
import { chatAgentLeader } from 'vs/workbench/contrib/chat/common/chatParserTypes';
3133
import { IChatDetail, IChatService } from 'vs/workbench/contrib/chat/common/chatService';
3234
import { IChatWidgetHistoryService } from 'vs/workbench/contrib/chat/common/chatWidgetHistoryService';
3335
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
@@ -73,8 +75,67 @@ class QuickChatGlobalAction extends Action2 {
7375
}
7476
}
7577

78+
export class ChatSubmitSecondaryAgentEditorAction extends EditorAction2 {
79+
static readonly ID = 'workbench.action.chat.submitSecondaryAgent';
80+
81+
constructor() {
82+
super({
83+
id: ChatSubmitSecondaryAgentEditorAction.ID,
84+
title: localize2({ key: 'actions.chat.submitSecondaryAgent', comment: ['Send input from the chat input box to the secondary agent'] }, "Submit to Secondary Agent"),
85+
precondition: CONTEXT_IN_CHAT_INPUT,
86+
keybinding: {
87+
when: EditorContextKeys.textInputFocus,
88+
primary: KeyMod.CtrlCmd | KeyCode.Enter,
89+
weight: KeybindingWeight.EditorContrib
90+
}
91+
});
92+
}
93+
94+
runEditorCommand(accessor: ServicesAccessor, editor: ICodeEditor): void | Promise<void> {
95+
const editorUri = editor.getModel()?.uri;
96+
if (editorUri) {
97+
const agentService = accessor.get(IChatAgentService);
98+
const secondaryAgent = agentService.getSecondaryAgent();
99+
if (!secondaryAgent) {
100+
return;
101+
}
102+
103+
const widgetService = accessor.get(IChatWidgetService);
104+
widgetService.getWidgetByInputUri(editorUri)?.acceptInputWithPrefix(`${chatAgentLeader}${secondaryAgent.id}`);
105+
}
106+
}
107+
}
108+
109+
export class ChatSubmitEditorAction extends EditorAction2 {
110+
static readonly ID = 'workbench.action.chat.acceptInput';
111+
112+
constructor() {
113+
super({
114+
id: ChatSubmitEditorAction.ID,
115+
title: localize2({ key: 'actions.chat.submit', comment: ['Apply input from the chat input box'] }, "Submit"),
116+
precondition: CONTEXT_IN_CHAT_INPUT,
117+
keybinding: {
118+
when: EditorContextKeys.textInputFocus,
119+
primary: KeyCode.Enter,
120+
weight: KeybindingWeight.EditorContrib
121+
}
122+
});
123+
}
124+
125+
runEditorCommand(accessor: ServicesAccessor, editor: ICodeEditor): void | Promise<void> {
126+
const editorUri = editor.getModel()?.uri;
127+
if (editorUri) {
128+
const widgetService = accessor.get(IChatWidgetService);
129+
widgetService.getWidgetByInputUri(editorUri)?.acceptInput();
130+
}
131+
}
132+
}
133+
76134
export function registerChatActions() {
77135
registerAction2(QuickChatGlobalAction);
136+
registerAction2(ChatSubmitEditorAction);
137+
138+
registerAction2(ChatSubmitSecondaryAgentEditorAction);
78139

79140
registerAction2(class ClearChatHistoryAction extends Action2 {
80141
constructor() {

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

+2-46
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,12 @@
44
*--------------------------------------------------------------------------------------------*/
55

66
import { Codicon } from 'vs/base/common/codicons';
7-
import { KeyCode, KeyMod } from 'vs/base/common/keyCodes';
87
import { ServicesAccessor } from 'vs/editor/browser/editorExtensions';
9-
import { localize, localize2 } from 'vs/nls';
8+
import { localize } from 'vs/nls';
109
import { Action2, MenuId, registerAction2 } from 'vs/platform/actions/common/actions';
11-
import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry';
1210
import { CHAT_CATEGORY } from 'vs/workbench/contrib/chat/browser/actions/chatActions';
1311
import { IChatWidget, IChatWidgetService } from 'vs/workbench/contrib/chat/browser/chat';
14-
import { IChatAgentService } from 'vs/workbench/contrib/chat/common/chatAgents';
15-
import { CONTEXT_CHAT_INPUT_HAS_TEXT, CONTEXT_CHAT_REQUEST_IN_PROGRESS, CONTEXT_IN_CHAT_INPUT } from 'vs/workbench/contrib/chat/common/chatContextKeys';
16-
import { chatAgentLeader } from 'vs/workbench/contrib/chat/common/chatParserTypes';
12+
import { CONTEXT_CHAT_INPUT_HAS_TEXT, CONTEXT_CHAT_REQUEST_IN_PROGRESS } from 'vs/workbench/contrib/chat/common/chatContextKeys';
1713
import { IChatService } from 'vs/workbench/contrib/chat/common/chatService';
1814

1915
export interface IChatExecuteActionContext {
@@ -40,11 +36,6 @@ export class SubmitAction extends Action2 {
4036
when: CONTEXT_CHAT_REQUEST_IN_PROGRESS.negate(),
4137
group: 'navigation',
4238
},
43-
keybinding: {
44-
when: CONTEXT_IN_CHAT_INPUT,
45-
primary: KeyCode.Enter,
46-
weight: KeybindingWeight.WorkbenchContrib
47-
},
4839
});
4940
}
5041

@@ -57,43 +48,8 @@ export class SubmitAction extends Action2 {
5748
}
5849
}
5950

60-
export class SubmitSecondaryAgentAction extends Action2 {
61-
static readonly ID = 'workbench.action.chat.submitSecondaryAgent';
62-
63-
constructor() {
64-
super({
65-
id: SubmitSecondaryAgentAction.ID,
66-
title: localize2('chat.label.submitSecondaryAgent', "Submit to Secondary Agent"),
67-
f1: false,
68-
category: CHAT_CATEGORY,
69-
precondition: CONTEXT_CHAT_INPUT_HAS_TEXT,
70-
keybinding: {
71-
when: CONTEXT_IN_CHAT_INPUT,
72-
primary: KeyMod.CtrlCmd | KeyCode.Enter,
73-
weight: KeybindingWeight.WorkbenchContrib
74-
},
75-
});
76-
}
77-
78-
run(accessor: ServicesAccessor, ...args: any[]) {
79-
const context: IChatExecuteActionContext | undefined = args[0];
80-
81-
const agentService = accessor.get(IChatAgentService);
82-
const secondaryAgent = agentService.getSecondaryAgent();
83-
if (!secondaryAgent) {
84-
return;
85-
}
86-
87-
const widgetService = accessor.get(IChatWidgetService);
88-
const widget = context?.widget ?? widgetService.lastFocusedWidget;
89-
widget?.acceptInputWithPrefix(`${chatAgentLeader}${secondaryAgent.id}`);
90-
}
91-
}
92-
9351
export function registerChatExecuteActions() {
9452
registerAction2(SubmitAction);
95-
registerAction2(SubmitSecondaryAgentAction);
96-
9753
registerAction2(class CancelAction extends Action2 {
9854
constructor() {
9955
super({

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

+4-3
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
3131
import { DEFAULT_FONT_FAMILY } from 'vs/workbench/browser/style';
3232
import { AccessibilityVerbositySettingId } from 'vs/workbench/contrib/accessibility/browser/accessibilityConfiguration';
3333
import { AccessibilityCommandId } from 'vs/workbench/contrib/accessibility/common/accessibilityCommands';
34-
import { IChatExecuteActionContext, SubmitAction, SubmitSecondaryAgentAction } from 'vs/workbench/contrib/chat/browser/actions/chatExecuteActions';
34+
import { IChatExecuteActionContext, SubmitAction } from 'vs/workbench/contrib/chat/browser/actions/chatExecuteActions';
3535
import { IChatWidget } from 'vs/workbench/contrib/chat/browser/chat';
3636
import { ChatFollowups } from 'vs/workbench/contrib/chat/browser/chatFollowups';
3737
import { IChatAgentService } from 'vs/workbench/contrib/chat/common/chatAgents';
@@ -41,6 +41,7 @@ import { IChatReplyFollowup } from 'vs/workbench/contrib/chat/common/chatService
4141
import { IChatResponseViewModel } from 'vs/workbench/contrib/chat/common/chatViewModel';
4242
import { IChatWidgetHistoryService } from 'vs/workbench/contrib/chat/common/chatWidgetHistoryService';
4343
import { getSimpleCodeEditorWidgetOptions, getSimpleEditorOptions } from 'vs/workbench/contrib/codeEditor/browser/simpleEditorOptions';
44+
import { ChatSubmitEditorAction, ChatSubmitSecondaryAgentEditorAction } from 'vs/workbench/contrib/chat/browser/actions/chatActions';
4445
import { IPosition } from 'vs/editor/common/core/position';
4546

4647
const $ = dom.$;
@@ -379,15 +380,15 @@ class SubmitButtonActionViewItem extends ActionViewItem {
379380
) {
380381
super(context, action, options);
381382

382-
const primaryKeybinding = keybindingService.lookupKeybinding(SubmitAction.ID)?.getLabel();
383+
const primaryKeybinding = keybindingService.lookupKeybinding(ChatSubmitEditorAction.ID)?.getLabel();
383384
let tooltip = action.label;
384385
if (primaryKeybinding) {
385386
tooltip += ` (${primaryKeybinding})`;
386387
}
387388

388389
const secondaryAgent = chatAgentService.getSecondaryAgent();
389390
if (secondaryAgent) {
390-
const secondaryKeybinding = keybindingService.lookupKeybinding(SubmitSecondaryAgentAction.ID)?.getLabel();
391+
const secondaryKeybinding = keybindingService.lookupKeybinding(ChatSubmitSecondaryAgentEditorAction.ID)?.getLabel();
391392
if (secondaryKeybinding) {
392393
tooltip += `\n${chatAgentLeader}${secondaryAgent.id} (${secondaryKeybinding})`;
393394
}

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

+7-2
Original file line numberDiff line numberDiff line change
@@ -612,7 +612,12 @@
612612
opacity: 0.7;
613613
}
614614

615-
.interactive-item-container .progress-steps .progress-step .codicon-check {
615+
.interactive-item-container .progress-steps .progress-step .codicon {
616+
/* Very aggressive list styles try to apply focus colors to every codicon in a list row. */
617+
color: var(--vscode-icon-foreground) !important;
618+
}
619+
620+
.interactive-item-container .progress-steps .progress-step .codicon.codicon-check {
616621
font-size: 14px;
617-
color: var(--vscode-debugIcon-startForeground);
622+
color: var(--vscode-debugIcon-startForeground) !important;
618623
}

0 commit comments

Comments
 (0)