@@ -13,12 +13,15 @@ import {
1313 TextEdit ,
1414 chatRequestType ,
1515 InlineChatParams ,
16+ CreatePromptParams ,
17+ FileClickParams ,
1618} from '@aws/language-server-runtimes/protocol'
1719import {
1820 CancellationToken ,
1921 Chat ,
2022 ChatParams ,
2123 ChatResult ,
24+ FileList ,
2225 EndChatParams ,
2326 LSPErrorCodes ,
2427 QuickActionParams ,
@@ -52,15 +55,14 @@ import {
5255} from '../../shared/amazonQServiceManager/errors'
5356import { AmazonQTokenServiceManager } from '../../shared/amazonQServiceManager/AmazonQTokenServiceManager'
5457import { AmazonQWorkspaceConfig } from '../../shared/amazonQServiceManager/configurationUtils'
58+ import { ContextCommandsProvider } from './context/contextCommandsProvider'
5559
5660type ChatHandlers = Omit <
5761 LspHandlers < Chat > ,
5862 | 'openTab'
5963 | 'sendChatUpdate'
60- | 'onFileClicked'
6164 | 'onInlineChatPrompt'
6265 | 'sendContextCommands'
63- | 'onCreatePrompt'
6466 | 'onListConversations'
6567 | 'onConversationClick'
6668>
@@ -70,6 +72,7 @@ export class AgenticChatController implements ChatHandlers {
7072 #chatSessionManagementService: ChatSessionManagementService
7173 #telemetryController: ChatTelemetryController
7274 #triggerContext: QChatTriggerContext
75+ #contextCommandsProvider: ContextCommandsProvider
7376 #customizationArn?: string
7477 #telemetryService: TelemetryService
7578 #amazonQServiceManager?: AmazonQTokenServiceManager
@@ -86,11 +89,17 @@ export class AgenticChatController implements ChatHandlers {
8689 this . #telemetryController = new ChatTelemetryController ( features , telemetryService )
8790 this . #telemetryService = telemetryService
8891 this . #amazonQServiceManager = amazonQServiceManager
92+ this . #contextCommandsProvider = new ContextCommandsProvider ( features )
93+ }
94+
95+ async onCreatePrompt ( params : CreatePromptParams ) : Promise < void > {
96+ await this . #contextCommandsProvider?. handleCreatePrompt ( params . promptName )
8997 }
9098
9199 dispose ( ) {
92100 this . #chatSessionManagementService. dispose ( )
93101 this . #telemetryController. dispose ( )
102+ this . #contextCommandsProvider?. dispose ( )
94103 }
95104
96105 async onChatPrompt ( params : ChatParams , token : CancellationToken ) : Promise < ChatResult | ResponseError < ChatResult > > {
@@ -134,6 +143,7 @@ export class AgenticChatController implements ChatHandlers {
134143 this . #customizationArn,
135144 profileArn
136145 )
146+ await this . #contextCommandsProvider. addAdditionalContext ( triggerContext )
137147
138148 metric . recordStart ( )
139149 response = await session . sendMessage ( requestInput )
@@ -386,13 +396,20 @@ export class AgenticChatController implements ChatHandlers {
386396 return success
387397 }
388398
399+ async onFileClicked ( params : FileClickParams ) {
400+ // TODO: also pass in selection and handle on client side
401+ await this . #features. lsp . window . showDocument ( { uri : params . filePath } )
402+ }
403+
389404 onFollowUpClicked ( ) { }
390405
391406 onInfoLinkClick ( ) { }
392407
393408 onLinkClick ( ) { }
394409
395- onReady ( ) { }
410+ onReady ( ) {
411+ void this . #contextCommandsProvider?. processContextCommandUpdate ( )
412+ }
396413
397414 onSendFeedback ( { tabId, feedbackPayload } : FeedbackParams ) {
398415 this . #features. telemetry . emitMetric ( {
0 commit comments