@@ -8,6 +8,8 @@ import { ExtensionMessage } from '../commands'
8
8
import { TabType , TabsStorage } from '../storages/tabsStorage'
9
9
import { CodeReference } from './amazonqCommonsConnector'
10
10
import { FollowUpGenerator } from '../followUps/generator'
11
+ import { getActions } from '../diffTree/actions'
12
+ import { DiffTreeFileInfo } from '../diffTree/types'
11
13
12
14
interface ChatPayload {
13
15
chatMessage : string
@@ -21,6 +23,8 @@ export interface ConnectorProps {
21
23
sendFeedback ?: ( tabId : string , feedbackPayload : FeedbackPayload ) => void | undefined
22
24
onError : ( tabID : string , message : string , title : string ) => void
23
25
onWarning : ( tabID : string , message : string , title : string ) => void
26
+ onFileComponentUpdate : ( tabID : string , filePaths : DiffTreeFileInfo [ ] , deletedFiles : DiffTreeFileInfo [ ] ) => void
27
+ onFileActionClick : ( tabID : string , messageId : string , filePath : string , actionName : string ) => void
24
28
onUpdatePlaceholder : ( tabID : string , newPlaceholder : string ) => void
25
29
onChatInputEnabled : ( tabID : string , enabled : boolean ) => void
26
30
onUpdateAuthentication : ( featureDevEnabled : boolean , authenticatingTabIDs : string [ ] ) => void
@@ -32,6 +36,7 @@ export class Connector {
32
36
private readonly sendMessageToExtension
33
37
private readonly onError
34
38
private readonly onWarning
39
+ private readonly onFileComponentUpdate
35
40
private readonly onChatAnswerReceived
36
41
private readonly onAsyncEventProgress
37
42
private readonly updatePlaceholder
@@ -44,6 +49,7 @@ export class Connector {
44
49
this . sendMessageToExtension = props . sendMessageToExtension
45
50
this . onChatAnswerReceived = props . onChatAnswerReceived
46
51
this . onWarning = props . onWarning
52
+ this . onFileComponentUpdate = props . onFileComponentUpdate
47
53
this . onError = props . onError
48
54
this . onAsyncEventProgress = props . onAsyncEventProgress
49
55
this . updatePlaceholder = props . onUpdatePlaceholder
@@ -92,6 +98,16 @@ export class Connector {
92
98
tabType : 'featuredev' ,
93
99
} )
94
100
}
101
+ onFileActionClick = ( tabID : string , messageId : string , filePath : string , actionName : string ) : void => {
102
+ this . sendMessageToExtension ( {
103
+ command : 'file-click' ,
104
+ tabID,
105
+ messageId,
106
+ filePath,
107
+ actionName,
108
+ tabType : 'featuredev' ,
109
+ } )
110
+ }
95
111
96
112
followUpClicked = ( tabID : string , followUp : ChatItemAction ) : void => {
97
113
this . sendMessageToExtension ( {
@@ -137,6 +153,7 @@ export class Connector {
137
153
138
154
private processCodeResultMessage = async ( messageData : any ) : Promise < void > => {
139
155
if ( this . onChatAnswerReceived !== undefined ) {
156
+ const actions = getActions ( [ ...messageData . filePaths , ...messageData . deletedFiles ] )
140
157
const answer : ChatItem = {
141
158
type : ChatItemType . CODE_RESULT ,
142
159
relatedContent : undefined ,
@@ -146,8 +163,9 @@ export class Connector {
146
163
// TODO get the backend to store a message id in addition to conversationID
147
164
messageId : messageData . messageID ?? messageData . triggerID ?? messageData . conversationID ,
148
165
fileList : {
149
- filePaths : messageData . filePaths ,
150
- deletedFiles : messageData . deletedFiles ,
166
+ filePaths : messageData . filePaths . map ( ( f : DiffTreeFileInfo ) => f . zipFilePath ) ,
167
+ deletedFiles : messageData . deletedFiles . map ( ( f : DiffTreeFileInfo ) => f . zipFilePath ) ,
168
+ actions,
151
169
} ,
152
170
body : '' ,
153
171
}
@@ -178,6 +196,10 @@ export class Connector {
178
196
}
179
197
180
198
handleMessageReceive = async ( messageData : any ) : Promise < void > => {
199
+ if ( messageData . type === 'updateFileComponent' ) {
200
+ this . onFileComponentUpdate ( messageData . tabID , messageData . filePaths , messageData . deletedFiles )
201
+ return
202
+ }
181
203
if ( messageData . type === 'errorMessage' ) {
182
204
this . onError ( messageData . tabID , messageData . message , messageData . title )
183
205
return
0 commit comments