Skip to content

matrix: add exec approval reaction shortcuts - #60931

Merged
gumadeiras merged 5 commits into
mainfrom
codex/matrix-approval-reactions
Apr 5, 2026
Merged

gumadeiras merged 5 commits into
mainfrom
codex/matrix-approval-reactions

Conversation

@gumadeiras

Copy link
Copy Markdown
Member

Summary

  • Problem: Matrix exec approvals only had text /approve commands; no Matrix-native click/tap affordance.
  • Why it matters: Matrix clients here do not expose the buttons UI used by other approval surfaces, so approvals were slower and easier to mistype.
  • What changed: Matrix approval prompts now seed emoji reaction shortcuts, reaction events resolve approvals, and docs/tests cover the flow.
  • What did NOT change (scope boundary): No cross-channel approval transport changes, no Telegram/core approval plumbing cleanup in this PR.

Change Type (select all)

  • Bug fix
  • Feature
  • Refactor required for the fix
  • Docs
  • Security hardening
  • Chore/infra

Scope (select all touched areas)

  • Gateway / orchestration
  • Skills / tool execution
  • Auth / tokens
  • Memory / storage
  • Integrations
  • API / contracts
  • UI / DX
  • CI/CD / infra

Linked Issue/PR

  • Closes #
  • Related #
  • This PR fixes a bug or regression

Root Cause (if applicable)

  • Root cause: Matrix approval handling relied on text commands only, and the first reaction-event implementation accidentally gated approval reactions behind generic reaction notification settings.
  • Missing detection / guardrail: No regression test covered approval reactions with reactionNotifications: "off".
  • Contributing context (if known): Matrix does not have the same buttons UI path available here, so the native affordance had to be channel-specific.

Regression Test Plan (if applicable)

  • Coverage level that should have caught this:
    • Unit test
    • Seam / integration test
    • End-to-end test
    • Existing coverage already sufficient
  • Target test or file: extensions/matrix/src/approval-reactions.test.ts, extensions/matrix/src/exec-approvals-handler.test.ts, extensions/matrix/src/matrix/monitor/reaction-events.test.ts
  • Scenario the test should lock in: approval prompts advertise the correct emoji set, seed matching reactions, and still resolve approvals when generic reaction notifications are off.
  • Why this is the smallest reliable guardrail: the bug lives in Matrix-only prompt rendering and reaction routing.
  • Existing test that already covers this (if any): None
  • If no new test is added, why not: N/A

User-visible / Behavior Changes

  • Matrix approval prompts now include ✅ allow once, ❌ deny, and ♾️ allow always when available.
  • Reacting on the approval message resolves the approval without typing /approve ....

Diagram (if applicable)

Before:
[approval prompt] -> [copy or type /approve command] -> [approval resolved]

After:
[approval prompt] -> [react with emoji] -> [approval resolved]

Security Impact (required)

  • New permissions/capabilities? No
  • Secrets/tokens handling changed? No
  • New/changed network calls? No
  • Command/tool execution surface changed? No
  • Data access scope changed? No
  • If any Yes, explain risk + mitigation:

Repro + Verification

Environment

  • OS: macOS
  • Runtime/container: local Node/pnpm dev env
  • Model/provider: N/A
  • Integration/channel (if any): Matrix
  • Relevant config (redacted): channels.matrix.execApprovals.enabled=true with Matrix approvers configured

Steps

  1. Request host exec from a Matrix conversation that routes to Matrix-native approvals.
  2. Open the pending approval message in Matrix.
  3. React with ✅, ❌, or ♾️ (when allowed).

Expected

  • Approval resolves from the reaction; ordinary non-approval reactions still stay ordinary.

Actual

  • Fixed by this PR.

Evidence

  • Failing test/log before + passing after
  • Trace/log snippets
  • Screenshot/recording
  • Perf numbers (if relevant)

Human Verification (required)

  • Verified scenarios: build passes; Matrix approval prompt text/reaction mapping reviewed; reaction-resolution path reviewed after rebase.
  • Edge cases checked: approval reactions still resolve when reactionNotifications is off; allow-always omitted when effective ask mode disallows it.
  • What you did not verify: reliable local Vitest completion for the touched Matrix test files in this environment; targeted runs timed out locally even after the code path review.

Review Conversations

  • I replied to or resolved every bot review conversation I addressed in this PR.
  • I left unresolved only the conversations that still need reviewer or maintainer judgment.

Compatibility / Migration

  • Backward compatible? Yes
  • Config/env changes? No
  • Migration needed? No
  • If yes, exact upgrade steps:

Risks and Mitigations

  • Risk: Matrix clients that normalize or skin emoji differently could behave differently than expected.
    • Mitigation: resolution is keyed off exact reaction values seeded by the bot prompt, and text /approve commands remain as fallback.

Copilot AI review requested due to automatic review settings April 4, 2026 15:50
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation channel: matrix Channel integration: matrix size: L maintainer Maintainer-authored PR labels Apr 4, 2026
@greptile-apps

greptile-apps Bot commented Apr 4, 2026 •

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR adds Matrix-native emoji reaction shortcuts (✅, ❌, ♾️) to exec approval prompts: the approval message now includes a hint line and the bot seeds the matching reactions so approvers can tap to resolve without typing /approve. The core logic — emoji-to-decision mapping, reaction seeding via Promise.allSettled, and the critical fix placing the approval-reaction check before the reactionNotifications gate — is correct and well-tested, including the regression case where reactionNotifications: "off" previously suppressed approval reactions.

Two minor docs cleanups are worth addressing: the new ## Exec approvals teaser block in docs/channels/matrix.md was inserted in the middle of the ## Bundled plugin section (misplacing the install code blocks under the wrong heading), and the existing line "Matrix uses text approval prompts today" on line 686 is now stale since reactions are also supported.

Confidence Score: 5/5

Safe to merge; all remaining findings are P2 docs style issues that do not affect runtime behavior.

The implementation logic is sound, the regression test (approval reactions still fire when reactionNotifications is off) directly covers the stated bug, and the code changes are well-scoped to the Matrix extension. Only P2 documentation structure issues remain.

docs/channels/matrix.md — section ordering and one stale sentence at line 686.

Comments Outside Diff (2)

  1. docs/channels/matrix.md, line 22-44 (link)

    P2 Misplaced section breaks the Bundled plugin install instructions

    The new ## Exec approvals section (lines 22–30) was inserted in the middle of the ## Bundled plugin section. As a result, the Install from npm: block and the "Install from a local checkout:" block (lines 33–44) are rendered under the ## Exec approvals heading instead of ## Bundled plugin, which is confusing for readers.

    The install content starting at Install from npm: belongs to the interrupted ## Bundled plugin section. The ## Exec approvals teaser should be placed after the install instructions end (after line 44), or the reactions callout should be folded into the existing ## Exec approvals section at line 668 instead of adding a second one.

    Prompt To Fix With AI
    This is a comment left during a code review.
    Path: docs/channels/matrix.md
    Line: 22-44
    
    Comment:
    **Misplaced section breaks the Bundled plugin install instructions**
    
    The new `## Exec approvals` section (lines 22–30) was inserted in the middle of the `## Bundled plugin` section. As a result, the `Install from npm:` block and the "Install from a local checkout:" block (lines 33–44) are rendered under the `## Exec approvals` heading instead of `## Bundled plugin`, which is confusing for readers.
    
    The install content starting at `Install from npm:` belongs to the interrupted `## Bundled plugin` section. The `## Exec approvals` teaser should be placed after the install instructions end (after line 44), or the reactions callout should be folded into the existing `## Exec approvals` section at line 668 instead of adding a second one.
    
    How can I resolve this? If you propose a fix, please make it concise.
  2. docs/channels/matrix.md, line 686 (link)

    P2 Stale text — reaction shortcuts are now supported

    "Matrix uses text approval prompts today" is no longer accurate now that emoji reaction shortcuts are also seeded on the approval message. This sentence should be updated to mention both the text commands and the new reaction shortcuts.

    Prompt To Fix With AI
    This is a comment left during a code review.
    Path: docs/channels/matrix.md
    Line: 686
    
    Comment:
    **Stale text — reaction shortcuts are now supported**
    
    "Matrix uses text approval prompts today" is no longer accurate now that emoji reaction shortcuts are also seeded on the approval message. This sentence should be updated to mention both the text commands and the new reaction shortcuts.
    
    
    
    How can I resolve this? If you propose a fix, please make it concise.
Prompt To Fix All With AI
This is a comment left during a code review.
Path: docs/channels/matrix.md
Line: 22-44

Comment:
**Misplaced section breaks the Bundled plugin install instructions**

The new `## Exec approvals` section (lines 22–30) was inserted in the middle of the `## Bundled plugin` section. As a result, the `Install from npm:` block and the "Install from a local checkout:" block (lines 33–44) are rendered under the `## Exec approvals` heading instead of `## Bundled plugin`, which is confusing for readers.

The install content starting at `Install from npm:` belongs to the interrupted `## Bundled plugin` section. The `## Exec approvals` teaser should be placed after the install instructions end (after line 44), or the reactions callout should be folded into the existing `## Exec approvals` section at line 668 instead of adding a second one.

How can I resolve this? If you propose a fix, please make it concise.

---

This is a comment left during a code review.
Path: docs/channels/matrix.md
Line: 686

Comment:
**Stale text — reaction shortcuts are now supported**

"Matrix uses text approval prompts today" is no longer accurate now that emoji reaction shortcuts are also seeded on the approval message. This sentence should be updated to mention both the text commands and the new reaction shortcuts.

```suggestion
Matrix approval prompts include both text commands (`/approve <id> allow-once`, `/approve <id> allow-always`, `/approve <id> deny`) and emoji reaction shortcuts (`✅` allow once, `♾️` allow always when available, `❌` deny). Reacting with the seeded emoji on the prompt message resolves the approval without typing a command.
```

How can I resolve this? If you propose a fix, please make it concise.

Reviews (1): Last reviewed commit: "matrix: add exec approval reaction short..." | Re-trigger Greptile

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds Matrix-native emoji reaction shortcuts for exec approvals so approvers can tap/click reactions (✅/❌/♾️) instead of typing /approve ..., and routes inbound reaction events to resolve approvals even when generic reaction notifications are disabled.

Changes:

  • Seed approval prompt messages with a “React here …” hint and add the corresponding emoji reactions on send.
  • Handle inbound Matrix reactions by detecting approval reactions and resolving the underlying exec approval via the gateway.
  • Add unit tests + docs covering the Matrix approval reaction flow and the reactionNotifications: "off" regression.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
extensions/matrix/src/matrix/monitor/reaction-events.ts Adds approval-reaction detection/resolution before generic reaction notification routing.
extensions/matrix/src/matrix/monitor/reaction-events.test.ts New tests asserting approval reactions resolve and bypass generic reaction events (including notifications off).
extensions/matrix/src/exec-approvals-handler.ts Appends reaction hint to pending approval text and seeds allowed decision reactions on the pending message.
extensions/matrix/src/exec-approvals-handler.test.ts Verifies reaction hint text and that expected reactions are seeded (including allow-always omission).
extensions/matrix/src/exec-approval-resolver.ts New helper to resolve exec approvals via the gateway approvals client (plus not-found detection).
extensions/matrix/src/exec-approval-resolver.test.ts Tests gateway submission and structured “approval not found” error recognition.
extensions/matrix/src/approval-reactions.ts New helper to build reaction hints/bindings and parse approval prompt text to resolve a reaction to a decision.
extensions/matrix/src/approval-reactions.test.ts Tests binding order, hint formatting, and reaction-to-decision resolution.
docs/tools/exec-approvals.md Documents that native chat clients can provide channel-specific approval affordances (Matrix reactions).
docs/channels/matrix.md Documents Matrix exec approval reaction shortcuts and fallback /approve commands.
Comments suppressed due to low confidence (1)

extensions/matrix/src/matrix/monitor/reaction-events.ts:129

  • With reactionNotifications: "off", this handler still calls client.getEvent(...) for every inbound reaction before returning, even though ordinary reactions will ultimately be dropped. This can add avoidable homeserver traffic. Consider resolving notificationMode earlier and short-circuiting before getEvent when notifications are off and the reaction key cannot be an approval shortcut (e.g., not one of the approval emojis).
  const reaction = extractMatrixReactionAnnotation(params.event.content);
  if (!reaction?.eventId) {
    return;
  }
  if (params.senderId === params.selfUserId) {
    return;
  }

  const targetEvent = await params.client.getEvent(params.roomId, reaction.eventId).catch((err) => {
    params.logVerboseMessage(
      `matrix: failed resolving reaction target room=${params.roomId} id=${reaction.eventId}: ${String(err)}`,
    );
    return null;

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b0d038a33b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@gumadeiras gumadeiras self-assigned this Apr 4, 2026
@gumadeiras
gumadeiras force-pushed the codex/matrix-approval-reactions branch from 8d92561 to 3398394 Compare April 4, 2026 16:27

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3398394f5d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@gumadeiras
gumadeiras force-pushed the codex/matrix-approval-reactions branch 2 times, most recently from aa376fa to bbbd409 Compare April 5, 2026 14:27
@gumadeiras
gumadeiras force-pushed the codex/matrix-approval-reactions branch from bbbd409 to a34e824 Compare April 5, 2026 14:30
@gumadeiras
gumadeiras merged commit 0aaf753 into main Apr 5, 2026
9 checks passed
@gumadeiras
gumadeiras deleted the codex/matrix-approval-reactions branch April 5, 2026 14:30
@gumadeiras

Copy link
Copy Markdown
Member Author

Merged via squash.

Thanks @gumadeiras!

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a34e8248b0

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

lovewanwan pushed a commit to lovewanwan/openclaw that referenced this pull request Apr 28, 2026
Merged via squash.

Prepared head SHA: a34e824
Co-authored-by: gumadeiras <[email protected]>
Co-authored-by: gumadeiras <[email protected]>
Reviewed-by: @gumadeiras
ogt-redknie pushed a commit to ogt-redknie/OPENX that referenced this pull request May 2, 2026
Merged via squash.

Prepared head SHA: a34e824
Co-authored-by: gumadeiras <[email protected]>
Co-authored-by: gumadeiras <[email protected]>
Reviewed-by: @gumadeiras
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request May 24, 2026
Merged via squash.

Prepared head SHA: a34e824
Co-authored-by: gumadeiras <[email protected]>
Co-authored-by: gumadeiras <[email protected]>
Reviewed-by: @gumadeiras
vixco pushed a commit to vixco/openclaw that referenced this pull request Aug 16, 2026
Merged via squash.

Prepared head SHA: a34e824
Co-authored-by: gumadeiras <[email protected]>
Co-authored-by: gumadeiras <[email protected]>
Reviewed-by: @gumadeiras
globalcaos pushed a commit to globalcaos/tinkerclaw that referenced this pull request Sep 29, 2026
Merged via squash.

Prepared head SHA: a34e824
Co-authored-by: gumadeiras <[email protected]>
Co-authored-by: gumadeiras <[email protected]>
Reviewed-by: @gumadeiras
lhfer pushed a commit to lhfer/openclaw that referenced this pull request Oct 11, 2026
Merged via squash.

Prepared head SHA: a34e824
Co-authored-by: gumadeiras <[email protected]>
Co-authored-by: gumadeiras <[email protected]>
Reviewed-by: @gumadeiras
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: matrix Channel integration: matrix docs Improvements or additions to documentation maintainer Maintainer-authored PR size: XL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants