on main help sign in
Merge pull request #109 from charmbracelet/stable-sorting

fix: shifting LSPs and MCPs in sidebar

commit7226a6159b5340ded8cc25221cb40dd02b9bc8b1 authorKujtim Hoxha <kujtimii.h@gmail.com> dateTue 8 Jul 2025, 14:22 (1 year ago) parentcd0b9980e76c64
3 files changed+24−16
internal/config/config.go+6−5 internal/llm/agent/mcp-tools.go+4 internal/tui/components/chat/sidebar/sidebar.go+14−11
internal/config/config.go+6−5
@@ -86,11 +86,12 @@ const (
8686)
8787
8888type MCPConfig struct {
89− Command string `json:"command,omitempty" `
90− Env []string `json:"env,omitempty"`
91− Args []string `json:"args,omitempty"`
92− Type MCPType `json:"type"`
93− URL string `json:"url,omitempty"`
89+ Command string `json:"command,omitempty" `
90+ Env []string `json:"env,omitempty"`
91+ Args []string `json:"args,omitempty"`
92+ Type MCPType `json:"type"`
93+ URL string `json:"url,omitempty"`
94+ Disabled bool `json:"disabled,omitempty"`
9495
9596 // TODO: maybe make it possible to get the value from the env
9697 Headers map[string]string `json:"headers,omitempty"`
internal/llm/agent/mcp-tools.go+4
@@ -188,6 +188,10 @@ func GetMcpTools(ctx context.Context, permissions permission.Service, cfg *confi
188188 return mcpTools
189189 }
190190 for name, m := range cfg.MCP {
191+ if m.Disabled {
192+ slog.Debug("skipping disabled mcp", "name", name)
193+ continue
194+ }
191195 switch m.Type {
192196 case config.MCPStdio:
193197 c, err := client.NewStdioMCPClient(
internal/tui/components/chat/sidebar/sidebar.go+14−11
@@ -332,7 +332,7 @@ func (m *sidebarCmp) lspBlock() string {
332332
333333 lspList := []string{section, ""}
334334
335− lsp := config.Get().LSP
335+ lsp := config.Get().LSP.Sorted()
336336 if len(lsp) == 0 {
337337 return lipgloss.JoinVertical(
338338 lipgloss.Left,
@@ -342,9 +342,9 @@ func (m *sidebarCmp) lspBlock() string {
342342 )
343343 }
344344
345− for n, l := range lsp {
345+ for _, l := range lsp {
346346 iconColor := t.Success
347− if l.Disabled {
347+ if l.LSP.Disabled {
348348 iconColor = t.FgMuted
349349 }
350350 lspErrs := map[protocol.DiagnosticSeverity]int{
@@ -353,7 +353,7 @@ func (m *sidebarCmp) lspBlock() string {
353353 protocol.SeverityHint: 0,
354354 protocol.SeverityInformation: 0,
355355 }
356− if client, ok := m.lspClients[n]; ok {
356+ if client, ok := m.lspClients[l.Name]; ok {
357357 for _, diagnostics := range client.GetDiagnostics() {
358358 for _, diagnostic := range diagnostics {
359359 if severity, ok := lspErrs[diagnostic.Severity]; ok {
@@ -381,8 +381,8 @@ func (m *sidebarCmp) lspBlock() string {
381381 core.Status(
382382 core.StatusOpts{
383383 IconColor: iconColor,
384− Title: n,
385− Description: l.Command,
384+ Title: l.Name,
385+ Description: l.LSP.Command,
386386 ExtraContent: strings.Join(errs, " "),
387387 },
388388 m.width,
@@ -406,8 +406,8 @@ func (m *sidebarCmp) mcpBlock() string {
406406
407407 mcpList := []string{section, ""}
408408
409− mcp := config.Get().MCP
410− if len(mcp) == 0 {
409+ mcps := config.Get().MCP.Sorted()
410+ if len(mcps) == 0 {
411411 return lipgloss.JoinVertical(
412412 lipgloss.Left,
413413 section,
@@ -416,14 +416,17 @@ func (m *sidebarCmp) mcpBlock() string {
416416 )
417417 }
418418
419− for n, l := range mcp {
419+ for _, l := range mcps {
420420 iconColor := t.Success
421+ if l.MCP.Disabled {
422+ iconColor = t.FgMuted
423+ }
421424 mcpList = append(mcpList,
422425 core.Status(
423426 core.StatusOpts{
424427 IconColor: iconColor,
425− Title: n,
426− Description: l.Command,
428+ Title: l.Name,
429+ Description: l.MCP.Command,
427430 },
428431 m.width,
429432 ),