| 1 | package main |
| 2 | |
| 3 | import "errors" |
| 4 | |
| 5 | var ( |
| 6 | errNoActiveTab = errors.New("no active tab") |
| 7 | errMCPPromptUnsupported = errors.New("this runtime cannot answer MCP prompts") |
| 8 | ) |
| 9 | |
| 10 | // AnswerMCPInteraction resolves a pending MCP elicitation for one tab: the |
| 11 | // user's action (accept/decline/cancel) plus, for form accepts, the submitted |
| 12 | // values. Routes through AnswerMCPInteractionChecked so the decision is |
| 13 | // durable before the blocked MCP call resumes. |
| 14 | func (a *App) AnswerMCPInteractionForTab(tabID, id, action string, content map[string]any) error { |
| 15 | _, ctrl := a.tabAndCtrlByID(tabID) |
| 16 | if ctrl == nil { |
| 17 | return errNoActiveTab |
| 18 | } |
| 19 | resolver, ok := ctrl.(interface { |
| 20 | AnswerMCPInteractionChecked(id, action string, content map[string]any) error |
| 21 | }) |
| 22 | if !ok { |
| 23 | return errMCPPromptUnsupported |
| 24 | } |
| 25 | return resolver.AnswerMCPInteractionChecked(id, action, content) |
| 26 | } |
| 27 |