@@ -674,6 +674,7 @@ export class TerminalProviderChannel implements IServerChannel<RemoteAgentConnec
674
674
case '$getCwd' : return this . getTerminalCwd ( ...args as [ number ] ) ;
675
675
case '$sendCommandResult' : return this . sendCommandResultToTerminalProcess ( ...args as [ number , number , boolean , any ] ) ;
676
676
case '$orphanQuestionReply' : return this . orphanQuestionReply ( ...args as [ number ] ) ;
677
+ case '$listProcesses' : return this . listProcesses ( ) ;
677
678
case '$setTerminalLayoutInfo' : return this . setTerminalLayoutInfo ( args ) ;
678
679
case '$getTerminalLayoutInfo' : return this . getTerminalLayoutInfo ( args ) ;
679
680
}
@@ -866,6 +867,20 @@ export class TerminalProviderChannel implements IServerChannel<RemoteAgentConnec
866
867
throw new Error ( 'not implemented' ) ;
867
868
}
868
869
870
+ private async listProcesses ( ) : Promise < IProcessDetails [ ] > {
871
+ // TODO: args.isInitialization. Maybe this is to have slightly different
872
+ // behavior when first listing terminals but I don't know what you'd want to
873
+ // do differently. Maybe it's to reset the terminal dispose timeouts or
874
+ // something like that, but why not do it each time you list?
875
+ const terminals = await Promise . all ( Array . from ( this . terminals ) . map ( async ( [ id , terminal ] ) => {
876
+ return terminal . description ( id ) ;
877
+ } ) ) ;
878
+
879
+ // Only returned orphaned terminals so we don't end up attaching to
880
+ // terminals already attached elsewhere.
881
+ return terminals . filter ( ( t ) => t . isOrphan ) ;
882
+ }
883
+
869
884
public async setTerminalLayoutInfo ( args : ISetTerminalLayoutInfoArgs ) : Promise < void > {
870
885
this . layouts . set ( args . workspaceId , args ) ;
871
886
}
0 commit comments