@@ -11,7 +11,7 @@ import { COPILOT_ACCOUNTS, IComment } from '../common/comment';
1111import Logger from '../common/logger' ;
1212import { PR_SETTINGS_NAMESPACE , WEBVIEW_REFRESH_INTERVAL } from '../common/settingKeys' ;
1313import { ITelemetry } from '../common/telemetry' ;
14- import { CommentEvent , EventType , TimelineEvent } from '../common/timelineEvent' ;
14+ import { CommentEvent , EventType , ReviewStateValue , TimelineEvent } from '../common/timelineEvent' ;
1515import { asPromise , formatError } from '../common/utils' ;
1616import { getNonce , IRequestMessage , WebviewBase } from '../common/webview' ;
1717import { FolderRepositoryManager } from './folderRepositoryManager' ;
@@ -191,7 +191,7 @@ export class IssueOverviewPanel<TItem extends IssueModel = IssueModel> extends W
191191 return isInCodespaces ( ) ;
192192 }
193193
194- protected getInitializeContext ( currentUser : IAccount , issue : IssueModel , coAuthors : IAccount [ ] , timelineEvents : TimelineEvent [ ] , repositoryAccess : RepoAccessAndMergeMethods , viewerCanEdit : boolean , assignableUsers : IAccount [ ] ) : Issue {
194+ protected getInitializeContext ( currentUser : IAccount , issue : IssueModel , timelineEvents : TimelineEvent [ ] , repositoryAccess : RepoAccessAndMergeMethods , viewerCanEdit : boolean , assignableUsers : IAccount [ ] ) : Issue {
195195 const hasWritePermission = repositoryAccess ! . hasWritePermission ;
196196 const canEdit = hasWritePermission || viewerCanEdit ;
197197 const context : Issue = {
@@ -217,7 +217,7 @@ export class IssueOverviewPanel<TItem extends IssueModel = IssueModel> extends W
217217 isDarkTheme : vscode . window . activeColorTheme . kind === vscode . ColorThemeKind . Dark ,
218218 canAssignCopilot : assignableUsers . find ( user => COPILOT_ACCOUNTS [ user . login ] ) !== undefined ,
219219 reactions : issue . item . reactions ,
220- isAuthor : [ issue . author , ... coAuthors ] . find ( user => user . login === currentUser . login ) !== undefined ,
220+ isAuthor : issue . author . login === currentUser . login ,
221221 } ;
222222
223223 return context ;
@@ -257,7 +257,7 @@ export class IssueOverviewPanel<TItem extends IssueModel = IssueModel> extends W
257257 Logger . debug ( 'pr.initialize' , IssueOverviewPanel . ID ) ;
258258 this . _postMessage ( {
259259 command : 'pr.initialize' ,
260- pullrequest : this . getInitializeContext ( currentUser , issue , [ ] , timelineEvents , repositoryAccess , viewerCanEdit , assignableUsers [ this . _item . remote . remoteName ] ?? [ ] ) ,
260+ pullrequest : this . getInitializeContext ( currentUser , issue , timelineEvents , repositoryAccess , viewerCanEdit , assignableUsers [ this . _item . remote . remoteName ] ?? [ ] ) ,
261261 } ) ;
262262
263263 } catch ( e ) {
@@ -335,8 +335,34 @@ export class IssueOverviewPanel<TItem extends IssueModel = IssueModel> extends W
335335 }
336336 }
337337
338- protected submitReviewMessage ( message : IRequestMessage < string > ) {
339- return this . createComment ( message ) ;
338+ protected async submitReviewMessage ( message : IRequestMessage < string > ) {
339+ const comment = await this . _item . createIssueComment ( message . args ) ;
340+ const commentedEvent : CommentEvent = {
341+ ...comment ,
342+ event : EventType . Commented
343+ } ;
344+ const allEvents = await this . _item . githubRepository . getIssueTimelineEvents ( this . _item ) ;
345+ const reply : SubmitReviewReply = {
346+ events : allEvents ,
347+ reviewedEvent : commentedEvent ,
348+ } ;
349+ this . tryScheduleCopilotRefresh ( comment . body ) ;
350+ return this . _replyMessage ( message , reply ) ;
351+ }
352+
353+ protected async tryScheduleCopilotRefresh ( commentBody : string , reviewType ?: ReviewStateValue ) {
354+ if ( ! COPILOT_ACCOUNTS [ this . _item . author . login ] ) {
355+ return ;
356+ }
357+
358+ if ( ! commentBody . includes ( '@copilot' ) && ! commentBody . includes ( '@Copilot' ) && reviewType !== 'CHANGES_REQUESTED' ) {
359+ return ;
360+ }
361+
362+ await new Promise ( resolve => setTimeout ( resolve , 1000 ) ) ;
363+ if ( ! this . _isDisposed ) {
364+ this . refreshPanel ( ) ;
365+ }
340366 }
341367
342368 private async addLabels ( message : IRequestMessage < void > ) : Promise < void > {
@@ -603,21 +629,6 @@ export class IssueOverviewPanel<TItem extends IssueModel = IssueModel> extends W
603629 this . _replyMessage ( message , result ) ;
604630 }
605631
606- private createComment ( message : IRequestMessage < string > ) {
607- return this . _item . createIssueComment ( message . args ) . then ( async ( comment ) => {
608- const commentedEvent : CommentEvent = {
609- ...comment ,
610- event : EventType . Commented
611- } ;
612- const allEvents = await this . _item . githubRepository . getIssueTimelineEvents ( this . _item ) ;
613- const reply : SubmitReviewReply = {
614- events : allEvents ,
615- reviewedEvent : commentedEvent ,
616- } ;
617- return this . _replyMessage ( message , reply ) ;
618- } ) ;
619- }
620-
621632 protected set _currentPanel ( panel : IssueOverviewPanel | undefined ) {
622633 IssueOverviewPanel . currentPanel = panel ;
623634 }
0 commit comments