@@ -639,7 +639,9 @@ export class Remote {
639
639
} ) ,
640
640
) ;
641
641
642
- this . createAgentMetadataStatusBar ( agent , workspaceRestClient , disposables ) ;
642
+ disposables . push (
643
+ ...this . createAgentMetadataStatusBar ( agent , workspaceRestClient ) ,
644
+ ) ;
643
645
644
646
this . storage . writeToCoderOutputChannel ( "Remote setup complete" ) ;
645
647
@@ -990,40 +992,35 @@ export class Remote {
990
992
private createAgentMetadataStatusBar (
991
993
agent : WorkspaceAgent ,
992
994
restClient : Api ,
993
- disposables : vscode . Disposable [ ] ,
994
- ) : void {
995
+ ) : vscode . Disposable [ ] {
995
996
const statusBarItem = vscode . window . createStatusBarItem (
996
997
"agentMetadata" ,
997
998
vscode . StatusBarAlignment . Left ,
998
999
) ;
999
- disposables . push ( statusBarItem ) ;
1000
1000
1001
1001
const agentWatcher = createAgentMetadataWatcher ( agent . id , restClient ) ;
1002
- disposables . push ( agentWatcher ) ;
1003
1002
1004
- agentWatcher . onChange (
1005
- ( ) => {
1006
- if ( agentWatcher . error ) {
1007
- this . storage . writeToCoderOutputChannel (
1008
- formatMetadataError ( agentWatcher . error ) ,
1009
- ) ;
1010
- statusBarItem . hide ( ) ;
1011
- return ;
1012
- }
1003
+ const onChangeDisposable = agentWatcher . onChange ( ( ) => {
1004
+ if ( agentWatcher . error ) {
1005
+ this . storage . writeToCoderOutputChannel (
1006
+ formatMetadataError ( agentWatcher . error ) ,
1007
+ ) ;
1008
+ statusBarItem . hide ( ) ;
1009
+ return ;
1010
+ }
1013
1011
1014
- if ( agentWatcher . metadata && agentWatcher . metadata . length > 0 ) {
1015
- statusBarItem . text = getEventValue ( agentWatcher . metadata [ 0 ] ) ;
1016
- statusBarItem . tooltip = agentWatcher . metadata
1017
- . map ( ( metadata ) => formatEventLabel ( metadata ) )
1018
- . join ( "\n" ) ;
1019
- statusBarItem . show ( ) ;
1020
- } else {
1021
- statusBarItem . hide ( ) ;
1022
- }
1023
- } ,
1024
- undefined ,
1025
- disposables ,
1026
- ) ;
1012
+ if ( agentWatcher . metadata && agentWatcher . metadata . length > 0 ) {
1013
+ statusBarItem . text = getEventValue ( agentWatcher . metadata [ 0 ] ) ;
1014
+ statusBarItem . tooltip = agentWatcher . metadata
1015
+ . map ( ( metadata ) => formatEventLabel ( metadata ) )
1016
+ . join ( "\n" ) ;
1017
+ statusBarItem . show ( ) ;
1018
+ } else {
1019
+ statusBarItem . hide ( ) ;
1020
+ }
1021
+ } ) ;
1022
+
1023
+ return [ statusBarItem , agentWatcher , onChangeDisposable ] ;
1027
1024
}
1028
1025
1029
1026
// closeRemote ends the current remote session.
0 commit comments