@@ -41,6 +41,8 @@ import { MarkdownString } from 'vs/base/common/htmlContent';
41
41
import { MovingAverage } from 'vs/base/common/numbers' ;
42
42
import { ModelDecorationOptions } from 'vs/editor/common/model/textModel' ;
43
43
import { IModelDeltaDecoration } from 'vs/editor/common/model' ;
44
+ import { IChatAgentService } from 'vs/workbench/contrib/chat/common/chatAgents' ;
45
+ import { chatAgentLeader , chatSubcommandLeader } from 'vs/workbench/contrib/chat/common/chatParserTypes' ;
44
46
45
47
export const enum State {
46
48
CREATE_SESSION = 'CREATE_SESSION' ,
@@ -135,7 +137,8 @@ export class InlineChatController implements IEditorContribution {
135
137
@IContextKeyService contextKeyService : IContextKeyService ,
136
138
@IAccessibilityService private readonly _accessibilityService : IAccessibilityService ,
137
139
@IKeybindingService private readonly _keybindingService : IKeybindingService ,
138
- @IChatAccessibilityService private readonly _chatAccessibilityService : IChatAccessibilityService
140
+ @IChatAccessibilityService private readonly _chatAccessibilityService : IChatAccessibilityService ,
141
+ @IChatAgentService private readonly _chatAgentService : IChatAgentService ,
139
142
) {
140
143
this . _ctxHasActiveRequest = CTX_INLINE_CHAT_HAS_ACTIVE_REQUEST . bindTo ( contextKeyService ) ;
141
144
this . _ctxDidEdit = CTX_INLINE_CHAT_DID_EDIT . bindTo ( contextKeyService ) ;
@@ -531,7 +534,21 @@ export class InlineChatController implements IEditorContribution {
531
534
if ( refer ) {
532
535
this . _log ( '[IE] seeing refer command, continuing outside editor' , this . _activeSession . provider . debugName ) ;
533
536
this . _editor . setSelection ( this . _activeSession . wholeRange . value ) ;
534
- this . _instaService . invokeFunction ( sendRequest , input ) ;
537
+ let massagedInput = input ;
538
+ if ( input . startsWith ( chatSubcommandLeader ) ) {
539
+ const withoutSubCommandLeader = input . slice ( 1 ) ;
540
+ const cts = new CancellationTokenSource ( ) ;
541
+ this . _sessionStore . add ( cts ) ;
542
+ for ( const agent of this . _chatAgentService . getAgents ( ) ) {
543
+ const commands = await agent . provideSlashCommands ( cts . token ) ;
544
+ if ( commands . find ( ( command ) => withoutSubCommandLeader . startsWith ( command . name ) ) ) {
545
+ massagedInput = `${ chatAgentLeader } ${ agent . id } ${ input } ` ;
546
+ break ;
547
+ }
548
+ }
549
+ }
550
+ // if agent has a refer command, massage the input to include the agent name
551
+ this . _instaService . invokeFunction ( sendRequest , massagedInput ) ;
535
552
536
553
if ( ! this . _activeSession . lastExchange ) {
537
554
// DONE when there wasn't any exchange yet. We used the inline chat only as trampoline
0 commit comments