@@ -666,6 +666,40 @@ export class CopilotRemoteAgentManager extends Disposable {
666666 return this . _stateModel . getCounts ( ) ;
667667 }
668668
669+ public async provideNewChatSessionItem ( options : { prompt ?: string ; history : ReadonlyArray < vscode . ChatRequestTurn | vscode . ChatResponseTurn > ; metadata ?: any ; } , _token : vscode . CancellationToken ) : Promise < ChatSessionWithPR > {
670+ const { prompt } = options ;
671+ if ( ! prompt ) {
672+ throw new Error ( `Prompt is expected to provide a new chat session item` ) ;
673+ }
674+ const result = await this . invokeRemoteAgent (
675+ prompt ,
676+ prompt ,
677+ false ,
678+ ) ;
679+ if ( result . state !== 'success' ) {
680+ Logger . error ( `Failed to provide new chat session item: ${ result . error } ` , CopilotRemoteAgentManager . ID ) ;
681+ throw new Error ( `Failed to provide new chat session item: ${ result . error } ` ) ;
682+ }
683+
684+ const { number } = result ;
685+
686+ const session = await this . findPullRequestById ( number , true ) ;
687+ if ( ! session ) {
688+ throw new Error ( `Failed to find session for pull request: ${ number } ` ) ;
689+ }
690+ const timeline = await session . getCopilotTimelineEvents ( session ) ;
691+ const status = copilotEventToStatus ( mostRecentCopilotEvent ( timeline ) ) ;
692+ const tooltip = await issueMarkdown ( session , this . context , this . repositoriesManager ) ;
693+ return {
694+ id : `${ session . number } ` ,
695+ label : session . title || `Session ${ session . number } ` ,
696+ iconPath : this . getIconForSession ( status ) ,
697+ description : `${ dateFromNow ( session . createdAt ) } ` ,
698+ pullRequest : session ,
699+ tooltip,
700+ } ;
701+ }
702+
669703 public async provideChatSessions ( token : vscode . CancellationToken ) : Promise < ChatSessionWithPR [ ] > {
670704 try {
671705 const capi = await this . copilotApi ;
@@ -700,8 +734,6 @@ export class CopilotRemoteAgentManager extends Disposable {
700734 return [ ] ;
701735 }
702736
703-
704-
705737 public async provideChatSessionContent ( id : string , token : vscode . CancellationToken ) : Promise < vscode . ChatSession > {
706738 try {
707739 const capi = await this . copilotApi ;
0 commit comments