mattermost-mobile/app
Nick Misasi 9e0735c00d
Add two-phase tool call approval for agents in channels (#9506)
* Add two-phase tool call approval for agents in channels

Implements the mobile counterpart to the webapp's multiplayer tool calling
feature. When a bot is @mentioned in a channel, tool call arguments and
results are redacted from other members. Only the invoker can approve/reject
tool execution (Phase 1) and decide whether to share results with the
channel (Phase 2).

See mattermost/mattermost-plugin-agents#491 for the server/webapp changes.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* Add tests for channel tool calling utilities and remote actions

Tests for isToolCallRedacted, isPendingToolResult, getToolApprovalStage,
mergeToolCalls utility functions and fetchToolCallPrivate,
fetchToolResultPrivate, submitToolResult remote actions.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* Add e2e tests and testIDs for agent tool calls in channels

Adds detox e2e tests covering tool call card rendering, approval buttons,
result approval phase, and multi-tool-call scenarios. Adds testID props
to ToolApprovalSet and ToolCard components to support the e2e tests.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* Address PR review feedback for two-phase tool call approval

- Fix mergeToolCalls to preserve public-only tools instead of dropping them
- Fix stale closure race in handleToolDecision with functional setState
- Add forceLogoutIfNecessary to tool_private and tool_result remote actions
- Show snackbar on submit failure using existing error types
- Reset isDM in catch block to prevent stale state
- Sync animation shared values when isCollapsed changes externally
- Clear private data on streaming-to-persisted transition
- Wrap action buttons with usePreventDoubleTap
- Use toolCalls reference instead of toolCalls.length in effect dependency
- Fix grammar in warning callout ("its" -> "their")
- Change fontWeight from number to string per RN conventions

Co-authored-by: Cursor <cursoragent@cursor.com>

* Address PR review feedback: withObservables HOC, memoization, typography

- Refactor AgentPost to use withObservables HOC for channel observation
  instead of useEffect+subscribe, providing isDM as a prop
- Memoize undecidedCount in ToolApprovalSet and move before early return
- Replace manual font styles with typography() utility in ToolCard

Co-authored-by: Cursor <cursoragent@cursor.com>

---------

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-19 11:20:25 -05:00
..
actions Add two-phase tool call approval for agents in channels (#9506) 2026-02-19 11:20:25 -05:00
client Add autotranslations (#9324) 2026-02-10 17:50:39 +01:00
components Enable exhaustive deps in the repo (#9508) 2026-02-18 11:56:16 +01:00
constants Add two-phase tool call approval for agents in channels (#9506) 2026-02-19 11:20:25 -05:00
context Enable exhaustive deps in the repo (#9508) 2026-02-18 11:56:16 +01:00
database [MM-67507] Fix threads not being refetch when switching translations (#9512) 2026-02-17 16:07:10 +01:00
helpers Remove tand prevent double tap (#9078) 2025-08-25 12:03:01 +02:00
hooks Enable exhaustive deps in the repo (#9508) 2026-02-18 11:56:16 +01:00
i18n Add autotranslations (#9324) 2026-02-10 17:50:39 +01:00
init fix: prevent removal of pre-auth secret on logout (#9411) 2026-01-27 15:52:37 +01:00
managers [MM-67507] Fix threads not being refetch when switching translations (#9512) 2026-02-17 16:07:10 +01:00
products Add two-phase tool call approval for agents in channels (#9506) 2026-02-19 11:20:25 -05:00
queries [MM-67253] Add support for DMs and GMs for autotranslations (#9505) 2026-02-16 16:32:02 +01:00
screens Reduce channel banner height to 26px (#9520) 2026-02-18 13:43:01 -05:00
store feat: support fillewillbedownloaded and sendtoastmessage pluginapi (#9416) 2026-02-16 17:10:25 +01:00
utils feat: support fillewillbedownloaded and sendtoastmessage pluginapi (#9416) 2026-02-16 17:10:25 +01:00