Skip to content

fix: Mattermost and Feishu render agent callback buttons, Mattermost taps arrive once - #201973

Merged
obviyus merged 1 commit into
mainfrom
fix-mattermost-feishu-agent-controls
Nov 20, 2026
Merged

obviyus merged 1 commit into
mainfrom
fix-mattermost-feishu-agent-controls

Conversation

@obviyus

@obviyus obviyus commented Nov 19, 2026

Copy link
Copy Markdown
Collaborator

Problem

Follow-up to #201764 (core marks agent-authored controls) for two channels:

  • Mattermost and Feishu drop typed callback buttons. A message action button with action: { type: "callback", value } is never rendered (Mattermost leaves it out; Feishu shows only the label), so the agent's choice can't be tapped. Only legacy { label, value } buttons render.
  • Mattermost delivers every button click twice. The interaction handler enqueues a Mattermost button click: action="…" system event into the session and then also dispatches the click as an inbound message, so the agent sees the same tap twice.

Root cause

  • extensions/mattermost/src/normalize.ts (resolveMattermostPresentation): any button with an action that is not an ask_user question returns [].
  • extensions/feishu/src/presentation-card.ts (resolveFeishuCommandButtonValue): any action other than command returns undefined, so the button degrades to a markdown label.
  • extensions/mattermost/src/mattermost/interactions.ts: after the post update, the handler both calls core.system.enqueueSystemEvent(…) (resolving the session through a separate resolveSessionKey callback) and dispatchButtonClick(…), which runs the normal inbound path.

Solution

  • Mattermost and Feishu render a typed callback button when a message action marked it for the agent (agentControlText(value) is defined). The existing tap paths already decode the mark (fix: agent-authored message buttons reach the agent on every channel #201764): Mattermost through the signed callback_data context, Feishu through the quick envelope. Unmarked typed callbacks (plugin-owned, no handler on these channels) stay label-only, as before.
  • Mattermost delivers a click once, through dispatchButtonClick (the inbound path with the sender's identity and session plan). The system-event block and the resolveSessionKey callback that only served it are deleted.

What was deleted

  • Mattermost's duplicate system-event delivery and its resolveSessionKey option (−44 lines).

Accepted edges

  • The agent no longer gets the Mattermost button click: action="…" by … in channel … system-event line; it gets the click once as an inbound message (callback_data: <value> for agent buttons, [Button click: user @… selected "…"] for legacy ones).
  • Mattermost and Feishu value sizes stay as they are (Feishu 1024 bytes; Mattermost has no cap, a separate decision).

Tests (red on base, green on head)

Test Base Head
mattermost/normalize.question.test.ts: marked typed callback renders with callback_data: ::pick:a; unmarked typed callback does not ✗ (no button) ✓
mattermost/interactions.test.ts: a click calls dispatchButtonClick exactly once and enqueues no system event ✗ (system event enqueued) ✓
feishu/presentation-card.test.ts: marked typed callback renders a callback button with q: ::pick:a; unmarked stays - Plugin ✗ (label only) ✓

The tap side (mark → callback_data: <value>) is covered by the #201764 handler tests for both channels.

Gates: Mattermost and Feishu extension suites (slash-http.boundary.test.ts excluded: it fails identically on main), pnpm tsgo:extensions, pnpm check:test-types, assertion-safety, mock-export, max-lines, line-cap and test-line ratchets, oxlint and oxfmt.

E2E

Not run. There is no Mattermost or Feishu live harness (no E2E skill and no QA Lab live transport for either).

Size

  • Production: +8 / −45 (net −37).
  • Tests: +38.

…taps arrive once

Mattermost and Feishu dropped typed callback buttons, so a `message` action's
`action: { type: "callback" }` button never appeared. Both now render the ones a
message action marked for the agent (unmarked typed callbacks still stay
label-only). Mattermost also delivered every click twice, once as a system event
and once as the inbound message; the system-event path is removed.

Co-authored-by: obviyus <[email protected]>
@clawsweeper

clawsweeper Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added channel: mattermost Channel integration: mattermost channel: feishu Channel integration: feishu size: S labels Nov 19, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 19, 2026
@clawsweeper

clawsweeper Bot commented Nov 19, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR renders agent-owned callback buttons on Mattermost and Feishu and removes Mattermost’s duplicate system-event delivery.

Example: An agent sends an Alpha button with callback value pick:a.

  • Before: Mattermost omits the typed button, and Feishu renders only its label.
  • After: Both render a clickable control whose existing handler delivers callback_data: pick:a to the agent.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The focused runtime repair appears correct, with one nonblocking documentation defect; required real-channel behavior proof is absent.
Proof confidence 🧂 unranked krab (1/6) Real behavior proof is not required for maintainer- or bot-authored pull requests.
Patch quality 🐚 platinum hermit (4/6) 1 actionable review finding remain.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Agent-offered callback choices cannot be tapped on Mattermost or Feishu, and Mattermost adds two representations of an accepted generic tap to the agent’s input.
Reason: The maintainer-authored direction restores supported callback semantics and removes redundant delivery while retaining unsupported-action fallbacks.

Merge readiness

✅ Ready for maintainer review

Keep open: this maintainer-authored PR repairs callback rendering and duplicate Mattermost delivery still present on main; no blocking code defect was found.

Priority: P2
Reviewed head: 5f2faff0e0bba72859aab7df214d1cb32048c6b8

Before merge

None.

Findings

  • [P3] Update the Mattermost guide for supported typed callbacks — extensions/mattermost/src/normalize.ts:94-95

Tests

  • Missing end-to-end proof: Author: provide redacted before/after screenshots and send→tap→agent logs through a running Gateway on Mattermost and Feishu, showing the callback value and one Mattermost inbound delivery; remove IPs, keys, phone numbers, and non-public endpoints.
Agent review details

How this fits together

Core marks agent-authored callback values; channel renderers encode them into native buttons, and existing interaction handlers authorize taps and route their decoded values into the conversation.

flowchart LR
A[Agent message action] --> B[Core callback marker]
B --> C[Channel presentation renderer]
C --> D[Native button]
D --> E[Authorized tap handler]
E --> F[Conversation inbound dispatch]
F --> G[Agent reply]
Loading

Technical review

Best possible solution:

Keep the shared callback marker, encode supported buttons through the existing channel envelopes, and retain only Mattermost’s inbound click dispatch.

Do we have a high-confidence way to reproduce the issue?

Current-main source directly establishes both rendering rejections and Mattermost’s two delivery calls; the PR reports red-on-base regressions, but this review executed no target code.

Is this the best way to solve the issue?

The runtime change is the smallest complete repair using existing owners: two renderer conditions admit supported marked callbacks, and deleting the second delivery path removes duplication without adding state or APIs.

Full review comments:

  • [P3] Update the Mattermost guide for supported typed callbacks — extensions/mattermost/src/normalize.ts:94-95
    This condition now renders agent-marked typed callbacks, but the channel guide still says every callback action remains text (docs/channels/mattermost.md:451-453), and troubleshooting still requires a legacy value field at line 667. Readers checking whether the documented typed shape works receive incorrect guidance. Describe the agent-owned callback exception and retain the distinction for unsupported actions.
    Confidence: 0.99

Overall correctness: patch is correct
Overall confidence: 0.94

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against b8cd64b14968.

Provenance checked

  • Typed presentation rendering keeps the original intent (d641126: Channels render typed actions only when their interaction paths preserve the declared semantics.)
  • Mattermost question-action exception changes intended behavior with a stated reason (5a6d061: Question buttons use Gateway-owned option indices; other typed actions remained prose because generic clicks could not preserve their action semantics.)
  • Mattermost duplicate system-event delivery changes intended behavior with a stated reason (136ca87: Initial interactive-button support recorded a system event and dispatched an immediate agent response; subsequent session and event-plan refactors retained both.)

Testing

Proof path: unit tests only.

Security

None.

Evidence

What I checked:

Likely related people:

  • Ayaan Zaidi: Raw commit cd2ae19 adds extensions/mattermost/src/mattermost/monitor-interactions.ts:171 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: cd2ae19272a3; files: extensions/mattermost/src/mattermost/monitor-interactions.ts)
  • Peter Steinberger: Raw commit 4301ca9 adds extensions/mattermost/src/mattermost/monitor-interactions.ts:83 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 4301ca983168; files: extensions/mattermost/src/mattermost/monitor-interactions.ts)
  • Eden: Raw commit 5a6d061 adds extensions/mattermost/src/normalize.ts:75 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 5a6d0619ab11; files: extensions/mattermost/src/normalize.ts)

PR surface

Source -37, Tests +38. Total +1 across 7 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 4 8 45 -37
Tests 3 54 16 +38
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 7 62 61 +1

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Labels

Label changes:

  • add P2: Repairs interactive-button workflows on two channels while ordinary messaging remains available.
  • add rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • P2: Repairs interactive-button workflows on two channels while ordinary messaging remains available.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed November 19, 2026, 1:19 PM ET / 18:19 UTC.

@obviyus
obviyus merged commit 66fc4d8 into main Nov 20, 2026
118 checks passed
@obviyus
obviyus deleted the fix-mattermost-feishu-agent-controls branch November 20, 2026 03:07
@obviyus

obviyus commented Nov 20, 2026

Copy link
Copy Markdown
Collaborator Author

Landed as 66fc4d8. Mattermost and Feishu now show the callback buttons the agent sends, and a tap reaches the agent as callback_data: <value> through the core owner from #201764. Mattermost no longer delivers each click twice. Proof: handler tests red on base and green on head, a clean local review, and green CI. Neither channel had a live end-to-end run because no Mattermost or Feishu harness exists; the maintainer accepted that gap.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 20, 2026
…taps arrive once (openclaw#201973)

## Problem

Follow-up to openclaw#201764 (core marks agent-authored controls) for two channels:

- **Mattermost and Feishu drop typed callback buttons.** A `message` action button with `action: { type: "callback", value }` is never rendered (Mattermost leaves it out; Feishu shows only the label), so the agent's choice can't be tapped. Only legacy `{ label, value }` buttons render.
- **Mattermost delivers every button click twice.** The interaction handler enqueues a `Mattermost button click: action="…"` system event into the session and then also dispatches the click as an inbound message, so the agent sees the same tap twice.

## Root cause

- `extensions/mattermost/src/normalize.ts` (`resolveMattermostPresentation`): any button with an `action` that is not an `ask_user` question returns `[]`.
- `extensions/feishu/src/presentation-card.ts` (`resolveFeishuCommandButtonValue`): any `action` other than `command` returns `undefined`, so the button degrades to a markdown label.
- `extensions/mattermost/src/mattermost/interactions.ts`: after the post update, the handler both calls `core.system.enqueueSystemEvent(…)` (resolving the session through a separate `resolveSessionKey` callback) and `dispatchButtonClick(…)`, which runs the normal inbound path.

## Solution

- Mattermost and Feishu render a typed callback button when a message action marked it for the agent (`agentControlText(value)` is defined). The existing tap paths already decode the mark (openclaw#201764): Mattermost through the signed `callback_data` context, Feishu through the quick envelope. Unmarked typed callbacks (plugin-owned, no handler on these channels) stay label-only, as before.
- Mattermost delivers a click once, through `dispatchButtonClick` (the inbound path with the sender's identity and session plan). The system-event block and the `resolveSessionKey` callback that only served it are deleted.

## What was deleted

- Mattermost's duplicate system-event delivery and its `resolveSessionKey` option (−44 lines).

## Accepted edges

- The agent no longer gets the `Mattermost button click: action="…" by … in channel …` system-event line; it gets the click once as an inbound message (`callback_data: <value>` for agent buttons, `[Button click: user @… selected "…"]` for legacy ones).
- Mattermost and Feishu value sizes stay as they are (Feishu 1024 bytes; Mattermost has no cap, a separate decision).

## Tests (red on base, green on head)

| Test | Base | Head |
|---|---|---|
| `mattermost/normalize.question.test.ts`: marked typed callback renders with `callback_data: ::pick:a`; unmarked typed callback does not | ✗ (no button) | ✓ |
| `mattermost/interactions.test.ts`: a click calls `dispatchButtonClick` exactly once and enqueues no system event | ✗ (system event enqueued) | ✓ |
| `feishu/presentation-card.test.ts`: marked typed callback renders a callback button with `q: ::pick:a`; unmarked stays `- Plugin` | ✗ (label only) | ✓ |

The tap side (mark → `callback_data: <value>`) is covered by the openclaw#201764 handler tests for both channels.

Gates: Mattermost and Feishu extension suites (`slash-http.boundary.test.ts` excluded: it fails identically on main), `pnpm tsgo:extensions`, `pnpm check:test-types`, assertion-safety, mock-export, max-lines, line-cap and test-line ratchets, oxlint and oxfmt.

## E2E

Not run. There is no Mattermost or Feishu live harness (no E2E skill and no QA Lab live transport for either).

## Size

- Production: +8 / −45 (net **−37**).
- Tests: +38.

Co-authored-by: Ayaan Zaidi <[email protected]>
tideclaw-bot pushed a commit that referenced this pull request Nov 23, 2026
…taps arrive once (#201973)

## Problem

Follow-up to #201764 (core marks agent-authored controls) for two channels:

- **Mattermost and Feishu drop typed callback buttons.** A `message` action button with `action: { type: "callback", value }` is never rendered (Mattermost leaves it out; Feishu shows only the label), so the agent's choice can't be tapped. Only legacy `{ label, value }` buttons render.
- **Mattermost delivers every button click twice.** The interaction handler enqueues a `Mattermost button click: action="…"` system event into the session and then also dispatches the click as an inbound message, so the agent sees the same tap twice.

## Root cause

- `extensions/mattermost/src/normalize.ts` (`resolveMattermostPresentation`): any button with an `action` that is not an `ask_user` question returns `[]`.
- `extensions/feishu/src/presentation-card.ts` (`resolveFeishuCommandButtonValue`): any `action` other than `command` returns `undefined`, so the button degrades to a markdown label.
- `extensions/mattermost/src/mattermost/interactions.ts`: after the post update, the handler both calls `core.system.enqueueSystemEvent(…)` (resolving the session through a separate `resolveSessionKey` callback) and `dispatchButtonClick(…)`, which runs the normal inbound path.

## Solution

- Mattermost and Feishu render a typed callback button when a message action marked it for the agent (`agentControlText(value)` is defined). The existing tap paths already decode the mark (#201764): Mattermost through the signed `callback_data` context, Feishu through the quick envelope. Unmarked typed callbacks (plugin-owned, no handler on these channels) stay label-only, as before.
- Mattermost delivers a click once, through `dispatchButtonClick` (the inbound path with the sender's identity and session plan). The system-event block and the `resolveSessionKey` callback that only served it are deleted.

## What was deleted

- Mattermost's duplicate system-event delivery and its `resolveSessionKey` option (−44 lines).

## Accepted edges

- The agent no longer gets the `Mattermost button click: action="…" by … in channel …` system-event line; it gets the click once as an inbound message (`callback_data: <value>` for agent buttons, `[Button click: user @… selected "…"]` for legacy ones).
- Mattermost and Feishu value sizes stay as they are (Feishu 1024 bytes; Mattermost has no cap, a separate decision).

## Tests (red on base, green on head)

| Test | Base | Head |
|---|---|---|
| `mattermost/normalize.question.test.ts`: marked typed callback renders with `callback_data: ::pick:a`; unmarked typed callback does not | ✗ (no button) | ✓ |
| `mattermost/interactions.test.ts`: a click calls `dispatchButtonClick` exactly once and enqueues no system event | ✗ (system event enqueued) | ✓ |
| `feishu/presentation-card.test.ts`: marked typed callback renders a callback button with `q: ::pick:a`; unmarked stays `- Plugin` | ✗ (label only) | ✓ |

The tap side (mark → `callback_data: <value>`) is covered by the #201764 handler tests for both channels.

Gates: Mattermost and Feishu extension suites (`slash-http.boundary.test.ts` excluded: it fails identically on main), `pnpm tsgo:extensions`, `pnpm check:test-types`, assertion-safety, mock-export, max-lines, line-cap and test-line ratchets, oxlint and oxfmt.

## E2E

Not run. There is no Mattermost or Feishu live harness (no E2E skill and no QA Lab live transport for either).

## Size

- Production: +8 / −45 (net **−37**).
- Tests: +38.

Co-authored-by: Ayaan Zaidi <[email protected]>
(cherry picked from commit 66fc4d8)
Co-authored-by: RomneyDa <[email protected]>
(cherry picked from commit 580696656a79f3b8ec9e7831e6e50726f0ca29cf)
(cherry picked from commit 2478713e7e82e228f4ea292448fd17799faa0654)
maplel pushed a commit to maplel/openclaw that referenced this pull request Nov 24, 2026
Adapt only the duplicate-delivery repair from 66fc4d8 (openclaw#201973). Remove the parallel system-event path and its unused session resolver; preserve normal authenticated inbound dispatch and question/model-picker controls. Exclude typed callback rendering and its missing prerequisite.

Proof: original production 1 failed/20 passed; repaired owner, question and model-picker suites 36/36 passed. Format, staged diff, test-line and mock-export ratchets pass. Scoped typed lint remains blocked by physically external declaration inputs; no dependency reconciliation or guard bypass.

Co-authored-by: RomneyDa <[email protected]>
(cherry picked from commit e962cfdd8e3bac91c5237bbcac41f56164590761)
(cherry picked from commit 00cf098df2a917fa5187acb5bb6ded75476d04d6)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: feishu Channel integration: feishu channel: mattermost Channel integration: mattermost P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant