@@ -35,6 +35,8 @@ export interface GetAllRecommendationsOptions {
3535}
3636
3737export class RecommendationService {
38+ private logger = getLogger ( )
39+
3840 constructor (
3941 private readonly sessionManager : SessionManager ,
4042 private cursorUpdateRecorder ?: ICursorUpdateRecorder
@@ -117,7 +119,7 @@ export class RecommendationService {
117119 }
118120
119121 // Handle first request
120- getLogger ( ) . info ( 'Sending inline completion request: %O' , {
122+ this . logger . info ( 'Sending inline completion request: %O' , {
121123 method : inlineCompletionWithReferencesRequestType . method ,
122124 request : {
123125 textDocument : request . textDocument ,
@@ -174,7 +176,7 @@ export class RecommendationService {
174176 }
175177 }
176178
177- getLogger ( ) . info ( 'Received inline completion response from LSP: %O' , {
179+ this . logger . info ( 'Received inline completion response from LSP: %O' , {
178180 sessionId : result . sessionId ,
179181 latency : Date . now ( ) - t0 ,
180182 itemCount : result . items ?. length || 0 ,
@@ -190,12 +192,14 @@ export class RecommendationService {
190192
191193 if ( result . items . length > 0 && result . items [ 0 ] . isInlineEdit === false ) {
192194 if ( isTriggerByDeletion ) {
195+ this . logger . info ( `Suggestions were discarded; reason: triggerByDeletion` )
193196 return [ ]
194197 }
195198 // Completion will not be rendered if an edit suggestion has been active for longer than 1 second
196199 if ( EditSuggestionState . isEditSuggestionDisplayingOverOneSecond ( ) ) {
197200 const session = this . sessionManager . getActiveSession ( )
198201 if ( ! session ) {
202+ this . logger . error ( `Suggestions were discarded; reason: undefined conflicting session` )
199203 return [ ]
200204 }
201205 const params : LogInlineCompletionSessionResultsParams = {
@@ -213,14 +217,14 @@ export class RecommendationService {
213217 }
214218 languageClient . sendNotification ( 'aws/logInlineCompletionSessionResults' , params )
215219 this . sessionManager . clear ( )
216- getLogger ( ) . info (
217- 'Completion discarded due to active edit suggestion displayed longer than 1 second'
220+ this . logger . info (
221+ 'Suggetions were discarded; reason: active edit suggestion displayed longer than 1 second'
218222 )
219223 return [ ]
220224 } else if ( EditSuggestionState . isEditSuggestionActive ( ) ) {
221225 // discard the current edit suggestion if its display time is less than 1 sec
222226 await commands . executeCommand ( 'aws.amazonq.inline.rejectEdit' , true )
223- getLogger ( ) . info ( 'Discarding active edit suggestion displaying less than 1 second' )
227+ this . logger . info ( 'Discarding active edit suggestion displaying less than 1 second' )
224228 }
225229 }
226230
@@ -244,24 +248,25 @@ export class RecommendationService {
244248
245249 // TODO: question, is it possible that the first request returns empty suggestion but has non-empty next token?
246250 if ( result . partialResultToken ) {
251+ let logstr = `found non null next token; `
247252 if ( ! isInlineEdit ) {
248253 // If the suggestion is COMPLETIONS and there are more results to fetch, handle them in the background
249- getLogger ( ) . info (
250- 'Suggestion type is COMPLETIONS. Start fetching for more items if partialResultToken exists.'
251- )
254+ logstr += 'Suggestion type is COMPLETIONS. Start pulling more items'
252255 this . processRemainingRequests ( languageClient , request , result , token ) . catch ( ( error ) => {
253256 languageClient . warn ( `Error when getting suggestions: ${ error } ` )
254257 } )
255258 } else {
256259 // Skip fetching for more items if the suggesion is EDITS. If it is EDITS suggestion, only fetching for more
257260 // suggestions when the user start to accept a suggesion.
258261 // Save editsStreakPartialResultToken for the next EDITS suggestion trigger if user accepts.
259- getLogger ( ) . info ( 'Suggestion type is EDITS. Skip fetching for more items.' )
262+ logstr += 'Suggestion type is EDITS. Skip pulling more items'
260263 this . sessionManager . updateActiveEditsStreakToken ( result . partialResultToken )
261264 }
265+
266+ this . logger . info ( logstr )
262267 }
263268 } catch ( error : any ) {
264- getLogger ( ) . error ( 'Error getting recommendations: %O' , error )
269+ this . logger . error ( 'Error getting recommendations: %O' , error )
265270 // bearer token expired
266271 if ( error . data && error . data . awsErrorCode === 'E_AMAZON_Q_CONNECTION_EXPIRED' ) {
267272 // ref: https://github.com/aws/aws-toolkit-vscode/blob/amazonq/v1.74.0/packages/core/src/codewhisperer/service/inlineCompletionService.ts#L104
0 commit comments