Pass ChangeInfo into the suggestion Api It is useful to know more about the change than just the changeId. The plugin can request the information about the change using rest-api, but that seems unnecessary, given that change info is already fetched and known at that point. (In practice it would probably retrieve the cached rest api response, but that relies on plugin using exact same url and requires developers to know about the caching behaviour in core in the first place). Google-Bug-Id: b/312228673 Release-Notes: skip Change-Id: Idac4fe60f6c6243ef018ee2fd2c1186ddeeabc3c
diff --git a/polygerrit-ui/app/elements/shared/gr-comment/gr-comment.ts b/polygerrit-ui/app/elements/shared/gr-comment/gr-comment.ts index 7c893f2..ca74529 100644 --- a/polygerrit-ui/app/elements/shared/gr-comment/gr-comment.ts +++ b/polygerrit-ui/app/elements/shared/gr-comment/gr-comment.ts
@@ -63,7 +63,7 @@ import {Subject} from 'rxjs'; import {debounceTime} from 'rxjs/operators'; import {changeModelToken} from '../../../models/change/change-model'; -import {isBase64FileContent} from '../../../api/rest-api'; +import {ChangeInfo, isBase64FileContent} from '../../../api/rest-api'; import {createDiffUrl} from '../../../models/views/change'; import {userModelToken} from '../../../models/user/user-model'; import {modalStyles} from '../../../styles/gr-modal-styles'; @@ -1094,10 +1094,12 @@ private async generateSuggestEdit() { const suggestionsProvider = this.suggestionsProvider; + const changeInfo = this.getChangeModel().getChange(); if ( !suggestionsProvider || !this.showGeneratedSuggestion() || !this.changeNum || + !changeInfo || !this.comment || !this.comment.patch_set || !this.comment.path || @@ -1112,6 +1114,7 @@ const suggestionResponse = await suggestionsProvider.suggestCode({ prompt: this.messageText, changeNumber: this.changeNum, + changeInfo: changeInfo as ChangeInfo, patchsetNumber: this.comment?.patch_set, filePath: this.comment.path, range: this.comment.range,