@@ -33,7 +33,7 @@ import { IDialogService } from '../../../../platform/dialogs/common/dialogs.js';
3333import { ReconnectionWaitEvent , PersistentConnectionEventType } from '../../../../platform/remote/common/remoteAgentConnection.js' ;
3434import Severity from '../../../../base/common/severity.js' ;
3535import { ReloadWindowAction } from '../../../browser/actions/windowActions.js' ;
36- import { Disposable , IDisposable } from '../../../../base/common/lifecycle.js' ;
36+ import { Disposable , IDisposable , MutableDisposable } from '../../../../base/common/lifecycle.js' ;
3737import { SwitchRemoteViewItem } from './explorerViewItems.js' ;
3838import { isStringArray } from '../../../../base/common/types.js' ;
3939import { HelpInformation , IRemoteExplorerService } from '../../../services/remote/common/remoteExplorerService.js' ;
@@ -120,7 +120,7 @@ interface IHelpItem {
120120 handleClick ( ) : Promise < void > ;
121121}
122122
123- class HelpModel {
123+ class HelpModel extends Disposable {
124124 items : IHelpItem [ ] | undefined ;
125125
126126 constructor (
@@ -133,8 +133,10 @@ class HelpModel {
133133 private workspaceContextService : IWorkspaceContextService ,
134134 private walkthroughsService : IWalkthroughsService
135135 ) {
136+ super ( ) ;
137+
136138 this . updateItems ( ) ;
137- viewModel . onDidChangeHelpInformation ( ( ) => this . updateItems ( ) ) ;
139+ this . _register ( viewModel . onDidChangeHelpInformation ( ( ) => this . updateItems ( ) ) ) ;
138140 }
139141
140142 private createHelpItemValue ( info : HelpInformation , infoKey : Exclude < keyof HelpInformation , 'extensionDescription' | 'remoteName' | 'virtualWorkspace' > ) {
@@ -491,7 +493,7 @@ class HelpPanel extends ViewPane {
491493 }
492494 ) ;
493495
494- const model = new HelpModel ( this . viewModel , this . openerService , this . quickInputService , this . commandService , this . remoteExplorerService , this . environmentService , this . workspaceContextService , this . walkthroughsService ) ;
496+ const model = this . _register ( new HelpModel ( this . viewModel , this . openerService , this . quickInputService , this . commandService , this . remoteExplorerService , this . environmentService , this . workspaceContextService , this . walkthroughsService ) ) ;
495497
496498 this . tree . setInput ( model ) ;
497499
@@ -545,9 +547,9 @@ class RemoteViewPaneContainer extends FilterViewPaneContainer implements IViewMo
545547 super ( VIEWLET_ID , remoteExplorerService . onDidChangeTargetType , configurationService , layoutService , telemetryService , storageService , instantiationService , themeService , contextMenuService , extensionService , contextService , viewDescriptorService , logService ) ;
546548 this . addConstantViewDescriptors ( [ this . helpPanelDescriptor ] ) ;
547549 this . _register ( this . remoteSwitcher = this . instantiationService . createInstance ( SwitchRemoteViewItem ) ) ;
548- this . remoteExplorerService . onDidChangeHelpInformation ( extensions => {
550+ this . _register ( this . remoteExplorerService . onDidChangeHelpInformation ( extensions => {
549551 this . _setHelpInformation ( extensions ) ;
550- } ) ;
552+ } ) ) ;
551553
552554 this . _setHelpInformation ( this . remoteExplorerService . helpInformation ) ;
553555 const viewsRegistry = Registry . as < IViewsRegistry > ( Extensions . ViewsRegistry ) ;
@@ -804,7 +806,7 @@ export class RemoteAgentConnectionStatusListener extends Disposable implements I
804806
805807 let visibleProgress : VisibleProgress | null = null ;
806808 let reconnectWaitEvent : ReconnectionWaitEvent | null = null ;
807- let disposableListener : IDisposable | null = null ;
809+ const disposableListener = this . _register ( new MutableDisposable ( ) ) ;
808810
809811 function showProgress ( location : ProgressLocation . Dialog | ProgressLocation . Notification | null , buttons : { label : string ; callback : ( ) => void } [ ] , initialReport : string | null = null ) : VisibleProgress {
810812 if ( visibleProgress ) {
@@ -886,13 +888,10 @@ export class RemoteAgentConnectionStatusListener extends Disposable implements I
886888 // ReconnectionWait -> ReconnectionRunning
887889 // ReconnectionRunning -> ConnectionGain, ReconnectionPermanentFailure
888890
889- connection . onDidStateChange ( ( e ) => {
891+ this . _register ( connection . onDidStateChange ( ( e ) => {
890892 visibleProgress ?. stopTimer ( ) ;
893+ disposableListener . clear ( ) ;
891894
892- if ( disposableListener ) {
893- disposableListener . dispose ( ) ;
894- disposableListener = null ;
895- }
896895 switch ( e . type ) {
897896 case PersistentConnectionEventType . ConnectionLost :
898897 reconnectionToken = e . reconnectionToken ;
@@ -961,7 +960,7 @@ export class RemoteAgentConnectionStatusListener extends Disposable implements I
961960 visibleProgress . report ( nls . localize ( 'reconnectionRunning' , "Disconnected. Attempting to reconnect..." ) ) ;
962961
963962 // Register to listen for quick input is opened
964- disposableListener = quickInputService . onShow ( ( ) => {
963+ disposableListener . value = quickInputService . onShow ( ( ) => {
965964 // Need to move from dialog if being shown and user needs to type in a prompt
966965 if ( visibleProgress && visibleProgress . location === ProgressLocation . Dialog ) {
967966 visibleProgress = showProgress ( ProgressLocation . Notification , [ reloadButton ] , visibleProgress . lastReport ) ;
@@ -1048,7 +1047,7 @@ export class RemoteAgentConnectionStatusListener extends Disposable implements I
10481047 hideProgress ( ) ;
10491048 break ;
10501049 }
1051- } ) ;
1050+ } ) ) ;
10521051 }
10531052 }
10541053}
0 commit comments