@@ -37,7 +37,7 @@ import { IWebview, IWebviewService } from '../../webview/browser/webview.js';
37
37
import { IEditorGroup } from '../../../services/editor/common/editorGroupsService.js' ;
38
38
import { IExtensionService } from '../../../services/extensions/common/extensions.js' ;
39
39
import { IHoverService } from '../../../../platform/hover/browser/hover.js' ;
40
- import { IMcpServerEditorOptions , IWorkbenchMcpServer , McpServerContainers } from '../common/mcpTypes.js' ;
40
+ import { IMcpServerEditorOptions , IMcpWorkbenchService , IWorkbenchMcpServer , McpServerContainers } from '../common/mcpTypes.js' ;
41
41
import { InstallCountWidget , McpServerIconWidget , McpServerWidget , onClick , PublisherWidget , RatingsWidget } from './mcpServerWidgets.js' ;
42
42
import { DropDownAction , InstallAction , InstallingLabelAction , ManageMcpServerAction , UninstallAction } from './mcpServerActions.js' ;
43
43
import { McpServerEditorInput } from './mcpServerEditorInput.js' ;
@@ -73,19 +73,34 @@ class NavBar extends Disposable {
73
73
this . actionbar = this . _register ( new ActionBar ( element ) ) ;
74
74
}
75
75
76
- push ( id : string , label : string , tooltip : string ) : void {
76
+ push ( id : string , label : string , tooltip : string , index ?: number ) : void {
77
77
const action = new Action ( id , label , undefined , true , ( ) => this . update ( id , true ) ) ;
78
78
79
79
action . tooltip = tooltip ;
80
80
81
- this . actions . push ( action ) ;
82
- this . actionbar . push ( action ) ;
81
+ if ( typeof index === 'number' ) {
82
+ this . actions . splice ( index , 0 , action ) ;
83
+ } else {
84
+ this . actions . push ( action ) ;
85
+ }
86
+ this . actionbar . push ( action , { index } ) ;
83
87
84
88
if ( this . actions . length === 1 ) {
85
89
this . update ( id ) ;
86
90
}
87
91
}
88
92
93
+ remove ( id : string ) : void {
94
+ const index = this . actions . findIndex ( action => action . id === id ) ;
95
+ if ( index !== - 1 ) {
96
+ this . actions . splice ( index , 1 ) ;
97
+ this . actionbar . pull ( index ) ;
98
+ if ( this . _currentId === id ) {
99
+ this . switch ( this . actions [ 0 ] ?. id ) ;
100
+ }
101
+ }
102
+ }
103
+
89
104
clear ( ) : void {
90
105
this . actions = dispose ( this . actions ) ;
91
106
this . actionbar . clear ( ) ;
@@ -100,6 +115,10 @@ class NavBar extends Disposable {
100
115
return false ;
101
116
}
102
117
118
+ has ( id : string ) : boolean {
119
+ return this . actions . some ( action => action . id === id ) ;
120
+ }
121
+
103
122
private update ( id : string , focus ?: boolean ) : void {
104
123
this . _currentId = id ;
105
124
this . _onChange . fire ( { id, focus : ! ! focus } ) ;
@@ -165,6 +184,7 @@ export class McpServerEditor extends EditorPane {
165
184
@IWebviewService private readonly webviewService : IWebviewService ,
166
185
@ILanguageService private readonly languageService : ILanguageService ,
167
186
@IContextKeyService private readonly contextKeyService : IContextKeyService ,
187
+ @IMcpWorkbenchService private readonly mcpWorkbenchService : IMcpWorkbenchService ,
168
188
@IHoverService private readonly hoverService : IHoverService ,
169
189
) {
170
190
super ( McpServerEditor . ID , group , telemetryService , themeService , storageService ) ;
@@ -341,6 +361,17 @@ export class McpServerEditor extends EditorPane {
341
361
template . navbar . push ( McpServerEditorTab . Manifest , localize ( 'manifest' , "Manifest" ) , localize ( 'manifesttooltip' , "Server manifest details" ) ) ;
342
362
}
343
363
364
+ this . transientDisposables . add ( this . mcpWorkbenchService . onChange ( e => {
365
+ if ( e === extension ) {
366
+ if ( e . config && ! template . navbar . has ( McpServerEditorTab . Configuration ) ) {
367
+ template . navbar . push ( McpServerEditorTab . Configuration , localize ( 'configuration' , "Configuration" ) , localize ( 'configurationtooltip' , "Server configuration details" ) , extension . readmeUrl ? 1 : 0 ) ;
368
+ }
369
+ if ( ! e . config && template . navbar . has ( McpServerEditorTab . Configuration ) ) {
370
+ template . navbar . remove ( McpServerEditorTab . Configuration ) ;
371
+ }
372
+ }
373
+ } ) ) ;
374
+
344
375
if ( ( < IMcpServerEditorOptions | undefined > this . options ) ?. tab ) {
345
376
template . navbar . switch ( ( < IMcpServerEditorOptions > this . options ) . tab ! ) ;
346
377
}
0 commit comments