@@ -13,12 +13,15 @@ import {
13
13
TextEdit ,
14
14
chatRequestType ,
15
15
InlineChatParams ,
16
+ CreatePromptParams ,
17
+ FileClickParams ,
16
18
} from '@aws/language-server-runtimes/protocol'
17
19
import {
18
20
CancellationToken ,
19
21
Chat ,
20
22
ChatParams ,
21
23
ChatResult ,
24
+ FileList ,
22
25
EndChatParams ,
23
26
LSPErrorCodes ,
24
27
QuickActionParams ,
@@ -52,15 +55,14 @@ import {
52
55
} from '../../shared/amazonQServiceManager/errors'
53
56
import { AmazonQTokenServiceManager } from '../../shared/amazonQServiceManager/AmazonQTokenServiceManager'
54
57
import { AmazonQWorkspaceConfig } from '../../shared/amazonQServiceManager/configurationUtils'
58
+ import { ContextCommandsProvider } from './context/contextCommandsProvider'
55
59
56
60
type ChatHandlers = Omit <
57
61
LspHandlers < Chat > ,
58
62
| 'openTab'
59
63
| 'sendChatUpdate'
60
- | 'onFileClicked'
61
64
| 'onInlineChatPrompt'
62
65
| 'sendContextCommands'
63
- | 'onCreatePrompt'
64
66
| 'onListConversations'
65
67
| 'onConversationClick'
66
68
>
@@ -70,6 +72,7 @@ export class AgenticChatController implements ChatHandlers {
70
72
#chatSessionManagementService: ChatSessionManagementService
71
73
#telemetryController: ChatTelemetryController
72
74
#triggerContext: QChatTriggerContext
75
+ #contextCommandsProvider: ContextCommandsProvider
73
76
#customizationArn?: string
74
77
#telemetryService: TelemetryService
75
78
#amazonQServiceManager?: AmazonQTokenServiceManager
@@ -86,11 +89,17 @@ export class AgenticChatController implements ChatHandlers {
86
89
this . #telemetryController = new ChatTelemetryController ( features , telemetryService )
87
90
this . #telemetryService = telemetryService
88
91
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 )
89
97
}
90
98
91
99
dispose ( ) {
92
100
this . #chatSessionManagementService. dispose ( )
93
101
this . #telemetryController. dispose ( )
102
+ this . #contextCommandsProvider?. dispose ( )
94
103
}
95
104
96
105
async onChatPrompt ( params : ChatParams , token : CancellationToken ) : Promise < ChatResult | ResponseError < ChatResult > > {
@@ -134,6 +143,7 @@ export class AgenticChatController implements ChatHandlers {
134
143
this . #customizationArn,
135
144
profileArn
136
145
)
146
+ await this . #contextCommandsProvider. addAdditionalContext ( triggerContext )
137
147
138
148
metric . recordStart ( )
139
149
response = await session . sendMessage ( requestInput )
@@ -386,13 +396,20 @@ export class AgenticChatController implements ChatHandlers {
386
396
return success
387
397
}
388
398
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
+
389
404
onFollowUpClicked ( ) { }
390
405
391
406
onInfoLinkClick ( ) { }
392
407
393
408
onLinkClick ( ) { }
394
409
395
- onReady ( ) { }
410
+ onReady ( ) {
411
+ void this . #contextCommandsProvider?. processContextCommandUpdate ( )
412
+ }
396
413
397
414
onSendFeedback ( { tabId, feedbackPayload } : FeedbackParams ) {
398
415
this . #features. telemetry . emitMetric ( {
0 commit comments