on main help sign in
fix(ui): subscribe to `app.LSPEvent` instead of `workspace.LSPEvent` (#2565)
85445d7Chris Chen
internal/ui/model/lsp.go+3−3
@@ -7,16 +7,16 @@ import (
7 "strings"
7 "strings"
8
8
9 "charm.land/lipgloss/v2"
9 "charm.land/lipgloss/v2"
10+ "github.com/charmbracelet/crush/internal/app"
10 "github.com/charmbracelet/crush/internal/lsp"
11 "github.com/charmbracelet/crush/internal/lsp"
11 "github.com/charmbracelet/crush/internal/ui/common"
12 "github.com/charmbracelet/crush/internal/ui/common"
12 "github.com/charmbracelet/crush/internal/ui/styles"
13 "github.com/charmbracelet/crush/internal/ui/styles"
13− "github.com/charmbracelet/crush/internal/workspace"
14 "github.com/charmbracelet/x/powernap/pkg/lsp/protocol"
14 "github.com/charmbracelet/x/powernap/pkg/lsp/protocol"
15)
15)
16
16
17// LSPInfo wraps LSP client information with diagnostic counts by severity.
17// LSPInfo wraps LSP client information with diagnostic counts by severity.
18type LSPInfo struct {
18type LSPInfo struct {
19− workspace.LSPClientInfo
19+ app.LSPClientInfo
20 Diagnostics map[protocol.DiagnosticSeverity]int
20 Diagnostics map[protocol.DiagnosticSeverity]int
21}
21}
22
22
@@ -25,7 +25,7 @@ type LSPInfo struct {
25func (m *UI) lspInfo(width, maxItems int, isSection bool) string {
25func (m *UI) lspInfo(width, maxItems int, isSection bool) string {
26 t := m.com.Styles
26 t := m.com.Styles
27
27
28− states := slices.SortedFunc(maps.Values(m.lspStates), func(a, b workspace.LSPClientInfo) int {
28+ states := slices.SortedFunc(maps.Values(m.lspStates), func(a, b app.LSPClientInfo) int {
29 return strings.Compare(a.Name, b.Name)
29 return strings.Compare(a.Name, b.Name)
30 })
30 })
31
31
internal/ui/model/ui.go+5−4
@@ -28,6 +28,7 @@ import (
28 "github.com/charmbracelet/crush/internal/agent/notify"
28 "github.com/charmbracelet/crush/internal/agent/notify"
29 agenttools "github.com/charmbracelet/crush/internal/agent/tools"
29 agenttools "github.com/charmbracelet/crush/internal/agent/tools"
30 "github.com/charmbracelet/crush/internal/agent/tools/mcp"
30 "github.com/charmbracelet/crush/internal/agent/tools/mcp"
31+ "github.com/charmbracelet/crush/internal/app"
31 "github.com/charmbracelet/crush/internal/commands"
32 "github.com/charmbracelet/crush/internal/commands"
32 "github.com/charmbracelet/crush/internal/config"
33 "github.com/charmbracelet/crush/internal/config"
33 "github.com/charmbracelet/crush/internal/fsext"
34 "github.com/charmbracelet/crush/internal/fsext"
@@ -213,7 +214,7 @@ type UI struct {
213 }
214 }
214
215
215 // lsp
216 // lsp
216− lspStates map[string]workspace.LSPClientInfo
217+ lspStates map[string]app.LSPClientInfo
217
218
218 // mcp
219 // mcp
219 mcpStates map[string]mcp.ClientInfo
220 mcpStates map[string]mcp.ClientInfo
@@ -315,7 +316,7 @@ func New(com *common.Common, initialSessionID string, continueLast bool) *UI {
315 completions: comp,
316 completions: comp,
316 attachments: attachments,
317 attachments: attachments,
317 todoSpinner: todoSpinner,
318 todoSpinner: todoSpinner,
318− lspStates: make(map[string]workspace.LSPClientInfo),
319+ lspStates: make(map[string]app.LSPClientInfo),
319 mcpStates: make(map[string]mcp.ClientInfo),
320 mcpStates: make(map[string]mcp.ClientInfo),
320 notifyBackend: notification.NoopBackend{},
321 notifyBackend: notification.NoopBackend{},
321 notifyWindowFocused: true,
322 notifyWindowFocused: true,
@@ -615,8 +616,8 @@ func (m *UI) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
615 m.renderPills()
616 m.renderPills()
616 case pubsub.Event[history.File]:
617 case pubsub.Event[history.File]:
617 cmds = append(cmds, m.handleFileEvent(msg.Payload))
618 cmds = append(cmds, m.handleFileEvent(msg.Payload))
618− case pubsub.Event[workspace.LSPEvent]:
619+ case pubsub.Event[app.LSPEvent]:
619− m.lspStates = m.com.Workspace.LSPGetStates()
620+ m.lspStates = app.GetLSPStates()
620 case pubsub.Event[mcp.Event]:
621 case pubsub.Event[mcp.Event]:
621 switch msg.Payload.Type {
622 switch msg.Payload.Type {
622 case mcp.EventStateChanged:
623 case mcp.EventStateChanged: