mattermost-mobile/app/actions/websocket
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
..
burn_on_read.test.ts Bor create post (#9393) 2026-02-09 17:00:54 +05:30
burn_on_read.ts Bor create post (#9393) 2026-02-09 17:00:54 +05:30
category.test.ts Add tests to remaining actions/websocket files (#8495) 2025-01-21 08:42:09 -05:00
category.ts Add tests to remaining actions/websocket files (#8495) 2025-01-21 08:42:09 -05:00
channel.test.ts Add autotranslations (#9324) 2026-02-10 17:50:39 +01:00
channel.ts Add autotranslations (#9324) 2026-02-10 17:50:39 +01:00
event.test.ts Bor create post (#9393) 2026-02-09 17:00:54 +05:30
event.ts Add two-phase tool call approval for agents in channels (#9506) 2026-02-19 11:20:25 -05:00
files.ts feat: support fillewillbedownloaded and sendtoastmessage pluginapi (#9416) 2026-02-16 17:10:25 +01:00
group.test.ts Add tests to index, group and users websocket actions (#8486) 2025-01-17 14:25:12 -05:00
group.ts Move config to its own database table (#6744) 2022-11-11 21:20:42 +04:00
index.test.ts Burn On Read Posts (#9307) 2025-12-11 09:42:16 +05:30
index.ts [MM-66591] Channel Summaries with Agents (#9405) 2026-02-13 07:00:43 -05:00
integrations.test.ts Add tests to remaining actions/websocket files (#8495) 2025-01-21 08:42:09 -05:00
integrations.ts Gekidou Android share extension (#6803) 2022-11-30 23:18:56 +02:00
posts.test.ts Typescript support and view component for permalink with user and message (#9052) 2025-09-10 17:12:16 +05:30
posts.ts [MM-67563] Change websocket format for translation update events (#9515) 2026-02-18 16:16:13 +01:00
preferences.test.ts Add tests to remaining actions/websocket files (#8495) 2025-01-21 08:42:09 -05:00
preferences.ts Various fixes (#7161) 2023-02-24 13:02:05 +02:00
reactions.test.ts Add tests to remaining actions/websocket files (#8495) 2025-01-21 08:42:09 -05:00
reactions.ts Refactor errors around the app (#7306) 2023-05-03 13:08:55 +02:00
roles.test.ts Add model mocks to TestHelper (#8715) 2025-03-28 09:40:08 +01:00
roles.ts Refactor errors around the app (#7306) 2023-05-03 13:08:55 +02:00
scheduled_post.test.ts Feature schedule posts (#8509) 2025-04-14 22:08:59 +05:30
scheduled_post.ts Feature schedule posts (#8509) 2025-04-14 22:08:59 +05:30
system.test.ts Add tests to remaining actions/websocket files (#8495) 2025-01-21 08:42:09 -05:00
system.ts Refactor errors around the app (#7306) 2023-05-03 13:08:55 +02:00
teams.test.ts Add model mocks to TestHelper (#8715) 2025-03-28 09:40:08 +01:00
teams.ts Refactor errors around the app (#7306) 2023-05-03 13:08:55 +02:00
threads.test.ts Add tests to remaining actions/websocket files (#8495) 2025-01-21 08:42:09 -05:00
threads.ts Refactor errors around the app (#7306) 2023-05-03 13:08:55 +02:00
users.test.ts [MM-62565] Custom Profile attributes websocket changes (#8758) 2025-05-27 16:24:40 +02:00
users.ts Add autotranslations (#9324) 2026-02-10 17:50:39 +01:00