@@ -97,6 +97,10 @@ type (
97 mcpPromptsLoadedMsg struct {
97 mcpPromptsLoadedMsg struct {
98 Prompts []commands.MCPPrompt
98 Prompts []commands.MCPPrompt
100+ // mcpStateChangedMsg is sent when there is a change in MCP client states.
101+ mcpStateChangedMsg struct {
102+ states map[string]mcp.ClientInfo
100 // sendMessageMsg is sent to send a message.
104 // sendMessageMsg is sent to send a message.
101 // currently only used for mcp prompts.
105 // currently only used for mcp prompts.
102 sendMessageMsg struct {
106 sendMessageMsg struct {
@@ -429,6 +433,9 @@ func (m *UI) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
430 commands.SetCustomCommands(m.customCommands)
434 commands.SetCustomCommands(m.customCommands)
437+ case mcpStateChangedMsg:
438+ m.mcpStates = msg.states
432 case mcpPromptsLoadedMsg:
439 case mcpPromptsLoadedMsg:
433 m.mcpPrompts = msg.Prompts
440 m.mcpPrompts = msg.Prompts
434 dia := m.dialog.Dialog(dialog.CommandsID)
441 dia := m.dialog.Dialog(dialog.CommandsID)
@@ -3149,16 +3156,15 @@ func (m *UI) runMCPPrompt(clientID, promptID string, arguments map[string]string
3151func (m *UI) handleStateChanged() tea.Cmd {
3158func (m *UI) handleStateChanged() tea.Cmd {
3152− slog.Warn("handleStateChanged")
3153 return func() tea.Msg {
3159 return func() tea.Msg {
3154 m.com.App.UpdateAgentModel(context.Background())
3160 m.com.App.UpdateAgentModel(context.Background())
3161+ return mcpStateChangedMsg{
3155− m.mcpStates = mcp.GetStates()
3162+ states: mcp.GetStates(),
3160func handleMCPPromptsEvent(name string) tea.Cmd {
3167func handleMCPPromptsEvent(name string) tea.Cmd {
3161− slog.Warn("handleMCPPromptsEvent")
3162 return func() tea.Msg {
3168 return func() tea.Msg {
3163 mcp.RefreshPrompts(context.Background(), name)
3169 mcp.RefreshPrompts(context.Background(), name)
3164 return nil
3170 return nil
@@ -3166,7 +3172,6 @@ func handleMCPPromptsEvent(name string) tea.Cmd {
3168func handleMCPToolsEvent(cfg *config.Config, name string) tea.Cmd {
3174func handleMCPToolsEvent(cfg *config.Config, name string) tea.Cmd {
3169− slog.Warn("handleMCPToolsEvent")
3170 return func() tea.Msg {
3175 return func() tea.Msg {
3171 mcp.RefreshTools(
3176 mcp.RefreshTools(
3172 context.Background(),
3177 context.Background(),
@@ -3178,7 +3183,6 @@ func handleMCPToolsEvent(cfg *config.Config, name string) tea.Cmd {
3180func handleMCPResourcesEvent(name string) tea.Cmd {
3185func handleMCPResourcesEvent(name string) tea.Cmd {
3181− slog.Warn("handleMCPResourcesEvent")
3182 return func() tea.Msg {
3186 return func() tea.Msg {
3183 mcp.RefreshResources(context.Background(), name)
3187 mcp.RefreshResources(context.Background(), name)
3184 return nil
3188 return nil