Skip to content

Commit b7e8494

Browse files
committed
fix: should check if partialResultToken is empty for EDITS trigger on acceptance
1 parent 2eb0891 commit b7e8494

File tree

2 files changed

+15
-14
lines changed

2 files changed

+15
-14
lines changed

packages/amazonq/src/app/inline/recommendationService.ts

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -114,22 +114,23 @@ export class RecommendationService {
114114
)
115115

116116
const isInlineEdit = result.items.some((item) => item.isInlineEdit)
117-
if (!isInlineEdit) {
118-
// If the suggestion is COMPLETIONS and there are more results to fetch, handle them in the background
119-
getLogger().info(
120-
'Suggestion type is COMPLETIONS. Start fetching for more items if partialResultToken exists.'
121-
)
122-
if (result.partialResultToken) {
117+
118+
if (result.partialResultToken) {
119+
if (!isInlineEdit) {
120+
// If the suggestion is COMPLETIONS and there are more results to fetch, handle them in the background
121+
getLogger().info(
122+
'Suggestion type is COMPLETIONS. Start fetching for more items if partialResultToken exists.'
123+
)
123124
this.processRemainingRequests(languageClient, request, result, token).catch((error) => {
124125
languageClient.warn(`Error when getting suggestions: ${error}`)
125126
})
127+
} else {
128+
// Skip fetching for more items if the suggesion is EDITS. If it is EDITS suggestion, only fetching for more
129+
// suggestions when the user start to accept a suggesion.
130+
// Save editsStreakPartialResultToken for the next EDITS suggestion trigger if user accepts.
131+
getLogger().info('Suggestion type is EDITS. Skip fetching for more items.')
132+
this.sessionManager.updateActiveEditsStreakToken(result.partialResultToken)
126133
}
127-
} else {
128-
// Skip fetching for more items if the suggesion is EDITS. If it is EDITS suggestion, only fetching for more
129-
// suggestions when the user start to accept a suggesion.
130-
// Save editsStreakPartialResultToken for the next EDITS suggestion trigger if user accepts.
131-
getLogger().info('Suggestion type is EDITS. Skip fetching for more items.')
132-
this.sessionManager.updateActiveEditsStreakToken(result.partialResultToken)
133134
}
134135
} catch (error: any) {
135136
getLogger().error('Error getting recommendations: %O', error)

packages/amazonq/src/app/inline/sessionManager.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ export class SessionManager {
7777
this._acceptedSuggestionCount += 1
7878
}
7979

80-
public updateActiveEditsStreakToken(partialResultToken?: number | string) {
81-
if (!this.activeSession || !partialResultToken) {
80+
public updateActiveEditsStreakToken(partialResultToken: number | string) {
81+
if (!this.activeSession) {
8282
return
8383
}
8484
this.activeSession.editsStreakPartialResultToken = partialResultToken

0 commit comments

Comments
 (0)