@@ -95,6 +95,8 @@ export class TerminalService implements ITerminalService {
9595 return this . _detachedXterms ;
9696 }
9797
98+ private _reconnectedTerminalGroups : Promise < ITerminalGroup [ ] > | undefined ;
99+
98100 private _reconnectedTerminals : Map < string , ITerminalInstance [ ] > = new Map ( ) ;
99101 getReconnectedTerminals ( reconnectionOwner : string ) : ITerminalInstance [ ] | undefined {
100102 return this . _reconnectedTerminals . get ( reconnectionOwner ) ;
@@ -292,6 +294,13 @@ export class TerminalService implements ITerminalService {
292294 reconnectedPromise . then ( async ( ) => {
293295 this . _setConnected ( ) ;
294296 mark ( 'code/terminal/didReconnect' ) ;
297+ mark ( 'code/terminal/willReplay' ) ;
298+ const instances = await this . _reconnectedTerminalGroups ?. then ( groups => groups . map ( e => e . terminalInstances ) . flat ( ) ) ?? [ ] ;
299+ await Promise . all ( instances . map ( e => new Promise < void > ( r => Event . once ( e . onProcessReplayComplete ) ( ( ) => {
300+ mark ( `code/terminal/replay/${ e . shellLaunchConfig . attachPersistentProcess ?. id } ` ) ;
301+ r ( ) ;
302+ } ) ) ) ) ;
303+ mark ( 'code/terminal/didReplay' ) ;
295304 for ( const backend of this . _terminalInstanceService . getRegisteredBackends ( ) ) {
296305 mark ( 'code/terminal/willGetPerformanceMarks' ) ;
297306 this . _timerService . setPerformanceMarks ( backend . remoteAuthority === undefined ? 'localPtyHost' : 'remotePtyHost' , await backend . getPerformanceMarks ( ) ) ;
@@ -450,25 +459,25 @@ export class TerminalService implements ITerminalService {
450459 mark ( 'code/terminal/didGetTerminalLayoutInfo' ) ;
451460 if ( layoutInfo && layoutInfo . tabs . length > 0 ) {
452461 mark ( 'code/terminal/willRecreateTerminalGroups' ) ;
453- this . _restoredGroupCount = await this . _recreateTerminalGroups ( layoutInfo ) ;
462+ this . _reconnectedTerminalGroups = this . _recreateTerminalGroups ( layoutInfo ) ;
454463 mark ( 'code/terminal/didRecreateTerminalGroups' ) ;
455464 }
456465 // now that terminals have been restored,
457466 // attach listeners to update local state when terminals are changed
458467 this . _attachProcessLayoutListeners ( ) ;
459468 }
460469
461- private async _recreateTerminalGroups ( layoutInfo ?: ITerminalsLayoutInfo ) : Promise < number > {
470+ private _recreateTerminalGroups ( layoutInfo ?: ITerminalsLayoutInfo ) : Promise < ITerminalGroup [ ] > {
471+ const groupPromises : Promise < ITerminalGroup | undefined > [ ] = [ ] ;
462472 let reconnectCounter = 0 ;
463473 let activeGroup : Promise < ITerminalGroup | undefined > | undefined ;
464474 if ( layoutInfo ) {
465- const tabPromises : Promise < ITerminalGroup | undefined > [ ] = [ ] ;
466475 for ( const tabLayout of layoutInfo . tabs ) {
467476 const terminalLayouts = tabLayout . terminals . filter ( t => t . terminal && t . terminal . isOrphan ) ;
468477 if ( terminalLayouts . length ) {
469478 reconnectCounter += terminalLayouts . length ;
470479 const promise = this . _recreateTerminalGroup ( tabLayout , terminalLayouts ) ;
471- tabPromises . push ( promise ) ;
480+ groupPromises . push ( promise ) ;
472481 if ( tabLayout . isActive ) {
473482 activeGroup = promise ;
474483 }
@@ -482,7 +491,7 @@ export class TerminalService implements ITerminalService {
482491 activeGroup ?. then ( group => this . _terminalGroupService . activeGroup = group ) ;
483492 }
484493 }
485- return reconnectCounter ;
494+ return Promise . all ( groupPromises ) . then ( result => result . filter ( e => ! ! e ) as ITerminalGroup [ ] ) ;
486495 }
487496
488497 private async _recreateTerminalGroup ( tabLayout : IRawTerminalTabLayoutInfo < IPtyHostAttachTarget | null > , terminalLayouts : IRawTerminalInstanceLayoutInfo < IPtyHostAttachTarget | null > [ ] ) : Promise < ITerminalGroup | undefined > {
@@ -502,7 +511,6 @@ export class TerminalService implements ITerminalService {
502511 } ) ;
503512 group = lastInstance . then ( instance => this . _terminalGroupService . getGroupForInstance ( instance ) ) ;
504513 } else {
505- // TODO: Make parentInstance a promise?
506514 // add split terminals to this group
507515 lastInstance = this . createTerminal ( {
508516 config : { attachPersistentProcess } ,
0 commit comments