@@ -37,6 +37,10 @@ const (
39// Commands represents a dialog that shows available commands.
39// Commands represents a dialog that shows available commands.
40+type dockerMCPAvailabilityCheckedMsg struct {
40type Commands struct {
44type Commands struct {
41 com *common.Common
45 com *common.Common
42 keyMap struct {
46 keyMap struct {
@@ -66,6 +70,9 @@ type Commands struct {
67 customCommands []commands.CustomCommand
71 customCommands []commands.CustomCommand
68 mcpPrompts []commands.MCPPrompt
72 mcpPrompts []commands.MCPPrompt
74+ dockerMCPAvailable *bool
75+ dockerMCPCheckInFlight bool
71var _ Dialog = (*Commands)(nil)
78var _ Dialog = (*Commands)(nil)
@@ -126,6 +133,10 @@ func NewCommands(com *common.Common, sessionID string, hasSession, hasTodos, has
126 closeKey.SetHelp("esc", "cancel")
133 closeKey.SetHelp("esc", "cancel")
127 c.keyMap.Close = closeKey
134 c.keyMap.Close = closeKey
136+ if available, known := config.DockerMCPAvailabilityCached(); known {
137+ c.dockerMCPAvailable = &available
129 // Set initial commands
140 // Set initial commands
130 c.setCommandItems(c.selected)
141 c.setCommandItems(c.selected)
@@ -145,6 +156,13 @@ func (c *Commands) ID() string {
145// HandleMsg implements [Dialog].
156// HandleMsg implements [Dialog].
146func (c *Commands) HandleMsg(msg tea.Msg) Action {
157func (c *Commands) HandleMsg(msg tea.Msg) Action {
147 switch msg := msg.(type) {
158 switch msg := msg.(type) {
159+ case dockerMCPAvailabilityCheckedMsg:
160+ c.dockerMCPAvailable = &msg.available
161+ c.dockerMCPCheckInFlight = false
162+ if c.selected == SystemCommands {
163+ c.setCommandItems(c.selected)
148 case spinner.TickMsg:
166 case spinner.TickMsg:
149 if c.loading {
167 if c.loading {
150 var cmd tea.Cmd
168 var cmd tea.Cmd
@@ -207,6 +225,20 @@ func (c *Commands) HandleMsg(msg tea.Msg) Action {
207 return nil
225 return nil
228+func checkDockerMCPAvailabilityCmd() tea.Cmd {
229+ return func() tea.Msg {
230+ return dockerMCPAvailabilityCheckedMsg{available: config.RefreshDockerMCPAvailability()}
234+func (c *Commands) InitialCmd() tea.Cmd {
235+ if c.dockerMCPAvailable != nil || c.dockerMCPCheckInFlight {
238+ c.dockerMCPCheckInFlight = true
239+ return checkDockerMCPAvailabilityCmd()
210// Cursor returns the cursor position relative to the dialog.
242// Cursor returns the cursor position relative to the dialog.
211func (c *Commands) Cursor() *tea.Cursor {
243func (c *Commands) Cursor() *tea.Cursor {
212 return InputCursor(c.com.Styles, c.input.Cursor())
244 return InputCursor(c.com.Styles, c.input.Cursor())
@@ -446,8 +478,8 @@ func (c *Commands) defaultCommands() []*CommandItem {
446 commands = append(commands, NewCommandItem(c.com.Styles, "open_external_editor", "Open External Editor", "ctrl+o", ActionExternalEditor{}))
478 commands = append(commands, NewCommandItem(c.com.Styles, "open_external_editor", "Open External Editor", "ctrl+o", ActionExternalEditor{}))
449− // Add Docker MCP command if available and not already enabled
481+ // Add Docker MCP command if available and not already enabled.
450− if config.IsDockerMCPAvailable() && !cfg.IsDockerMCPEnabled() {
482+ if !cfg.IsDockerMCPEnabled() && c.dockerMCPAvailable != nil && *c.dockerMCPAvailable {
451 commands = append(commands, NewCommandItem(c.com.Styles, "enable_docker_mcp", "Enable Docker MCP Catalog", "", ActionEnableDockerMCP{}))
483 commands = append(commands, NewCommandItem(c.com.Styles, "enable_docker_mcp", "Enable Docker MCP Catalog", "", ActionEnableDockerMCP{}))