@@ -11,7 +11,7 @@ import { ICodeEditor } from 'vs/editor/browser/editorBrowser';
11
11
import { EditorAction2 , ServicesAccessor } from 'vs/editor/browser/editorExtensions' ;
12
12
import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService' ;
13
13
import { EditorContextKeys } from 'vs/editor/common/editorContextKeys' ;
14
- import { localize } from 'vs/nls' ;
14
+ import { localize , localize2 } from 'vs/nls' ;
15
15
import { Action2 , IAction2Options , MenuId , registerAction2 } from 'vs/platform/actions/common/actions' ;
16
16
import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey' ;
17
17
import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry' ;
@@ -26,8 +26,10 @@ import { IChatWidgetService } from 'vs/workbench/contrib/chat/browser/chat';
26
26
import { IChatEditorOptions } from 'vs/workbench/contrib/chat/browser/chatEditor' ;
27
27
import { ChatEditorInput } from 'vs/workbench/contrib/chat/browser/chatEditorInput' ;
28
28
import { ChatViewPane } from 'vs/workbench/contrib/chat/browser/chatViewPane' ;
29
+ import { IChatAgentService } from 'vs/workbench/contrib/chat/common/chatAgents' ;
29
30
import { CONTEXT_IN_CHAT_INPUT , CONTEXT_IN_CHAT_SESSION , CONTEXT_PROVIDER_EXISTS , CONTEXT_REQUEST , CONTEXT_RESPONSE } from 'vs/workbench/contrib/chat/common/chatContextKeys' ;
30
31
import { IChatContributionService } from 'vs/workbench/contrib/chat/common/chatContributionService' ;
32
+ import { chatAgentLeader } from 'vs/workbench/contrib/chat/common/chatParserTypes' ;
31
33
import { IChatDetail , IChatService } from 'vs/workbench/contrib/chat/common/chatService' ;
32
34
import { IChatWidgetHistoryService } from 'vs/workbench/contrib/chat/common/chatWidgetHistoryService' ;
33
35
import { IEditorService } from 'vs/workbench/services/editor/common/editorService' ;
@@ -73,8 +75,67 @@ class QuickChatGlobalAction extends Action2 {
73
75
}
74
76
}
75
77
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
+
76
134
export function registerChatActions ( ) {
77
135
registerAction2 ( QuickChatGlobalAction ) ;
136
+ registerAction2 ( ChatSubmitEditorAction ) ;
137
+
138
+ registerAction2 ( ChatSubmitSecondaryAgentEditorAction ) ;
78
139
79
140
registerAction2 ( class ClearChatHistoryAction extends Action2 {
80
141
constructor ( ) {
0 commit comments