@@ -44,6 +44,9 @@ import { isStringArray } from 'vs/base/common/types';
4444import { IRemoteExplorerService , HelpInformation } from 'vs/workbench/services/remote/common/remoteExplorerService' ;
4545import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService' ;
4646import { startsWith } from 'vs/base/common/strings' ;
47+ import { TunnelPanelDescriptor , TunnelViewModel } from 'vs/workbench/contrib/remote/browser/tunnelView' ;
48+ import { IAddedViewDescriptorRef } from 'vs/workbench/browser/parts/views/views' ;
49+ import { ViewletPane } from 'vs/workbench/browser/parts/views/paneViewlet' ;
4750
4851class HelpModel {
4952 items : IHelpItem [ ] | undefined ;
@@ -263,6 +266,7 @@ class HelpAction extends Action {
263266
264267export class RemoteViewlet extends FilterViewContainerViewlet {
265268 private actions : IAction [ ] | undefined ;
269+ private tunnelPanelDescriptor : TunnelPanelDescriptor | undefined ;
266270
267271 constructor (
268272 @IWorkbenchLayoutService layoutService : IWorkbenchLayoutService ,
@@ -274,7 +278,8 @@ export class RemoteViewlet extends FilterViewContainerViewlet {
274278 @IThemeService themeService : IThemeService ,
275279 @IContextMenuService contextMenuService : IContextMenuService ,
276280 @IExtensionService extensionService : IExtensionService ,
277- @IRemoteExplorerService remoteExplorerService : IRemoteExplorerService
281+ @IRemoteExplorerService private readonly remoteExplorerService : IRemoteExplorerService ,
282+ @IWorkbenchEnvironmentService private readonly environmentService : IWorkbenchEnvironmentService ,
278283 ) {
279284 super ( VIEWLET_ID , remoteExplorerService . onDidChangeTargetType , configurationService , layoutService , telemetryService , storageService , instantiationService , themeService , contextMenuService , extensionService , contextService ) ;
280285 }
@@ -308,6 +313,17 @@ export class RemoteViewlet extends FilterViewContainerViewlet {
308313 const title = nls . localize ( 'remote.explorer' , "Remote Explorer" ) ;
309314 return title ;
310315 }
316+
317+ onDidAddViews ( added : IAddedViewDescriptorRef [ ] ) : ViewletPane [ ] {
318+ // Call to super MUST be first, since registering the additional view will cause this to be called again.
319+ const panels : ViewletPane [ ] = super . onDidAddViews ( added ) ;
320+ if ( this . environmentService . configuration . remoteAuthority && ! this . tunnelPanelDescriptor && this . configurationService . getValue < boolean > ( 'remote.forwardedPortsView.visible' ) ) {
321+ this . tunnelPanelDescriptor = new TunnelPanelDescriptor ( new TunnelViewModel ( this . remoteExplorerService ) , this . environmentService ) ;
322+ const viewsRegistry = Registry . as < IViewsRegistry > ( Extensions . ViewsRegistry ) ;
323+ viewsRegistry . registerViews ( [ this . tunnelPanelDescriptor ! ] , VIEW_CONTAINER ) ;
324+ }
325+ return panels ;
326+ }
311327}
312328
313329Registry . as < ViewletRegistry > ( ViewletExtensions . Viewlets ) . registerViewlet ( ViewletDescriptor . create (
0 commit comments