@@ -11,7 +11,7 @@ import { ICodeEditor } from 'vs/editor/browser/editorBrowser';
1111import { EditorAction2 , ServicesAccessor } from 'vs/editor/browser/editorExtensions' ;
1212import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService' ;
1313import { EditorContextKeys } from 'vs/editor/common/editorContextKeys' ;
14- import { localize } from 'vs/nls' ;
14+ import { localize , localize2 } from 'vs/nls' ;
1515import { Action2 , IAction2Options , MenuId , registerAction2 } from 'vs/platform/actions/common/actions' ;
1616import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey' ;
1717import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry' ;
@@ -26,8 +26,10 @@ import { IChatWidgetService } from 'vs/workbench/contrib/chat/browser/chat';
2626import { IChatEditorOptions } from 'vs/workbench/contrib/chat/browser/chatEditor' ;
2727import { ChatEditorInput } from 'vs/workbench/contrib/chat/browser/chatEditorInput' ;
2828import { ChatViewPane } from 'vs/workbench/contrib/chat/browser/chatViewPane' ;
29+ import { IChatAgentService } from 'vs/workbench/contrib/chat/common/chatAgents' ;
2930import { CONTEXT_IN_CHAT_INPUT , CONTEXT_IN_CHAT_SESSION , CONTEXT_PROVIDER_EXISTS , CONTEXT_REQUEST , CONTEXT_RESPONSE } from 'vs/workbench/contrib/chat/common/chatContextKeys' ;
3031import { IChatContributionService } from 'vs/workbench/contrib/chat/common/chatContributionService' ;
32+ import { chatAgentLeader } from 'vs/workbench/contrib/chat/common/chatParserTypes' ;
3133import { IChatDetail , IChatService } from 'vs/workbench/contrib/chat/common/chatService' ;
3234import { IChatWidgetHistoryService } from 'vs/workbench/contrib/chat/common/chatWidgetHistoryService' ;
3335import { 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+
76134export function registerChatActions ( ) {
77135 registerAction2 ( QuickChatGlobalAction ) ;
136+ registerAction2 ( ChatSubmitEditorAction ) ;
137+
138+ registerAction2 ( ChatSubmitSecondaryAgentEditorAction ) ;
78139
79140 registerAction2 ( class ClearChatHistoryAction extends Action2 {
80141 constructor ( ) {
0 commit comments