openclaw - ✅(Solved) Fix Mattermost plugin drops post_edited events — @mentions added via edit do not trigger agent wake [1 pull requests, 1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#71930Fetched 2026-04-27 05:37:16
View on GitHub
Comments
0
Participants
1
Timeline
1
Reactions
0
Participants
Timeline (top)
cross-referenced ×1

The Mattermost WebSocket plugin subscribes to posted events only. post_edited events are discarded before mention detection runs, so an @mention added by editing a message never wakes the tagged agent. The drop is silent — no error, no log entry.

Error Message

The Mattermost WebSocket plugin subscribes to posted events only. post_edited events are discarded before mention detection runs, so an @mention added by editing a message never wakes the tagged agent. The drop is silent — no error, no log entry.

Root Cause

Two hard guards in channel.runtime-Ci-PEA8h.js reject any non-posted event:

Line 590 — parsePostedPayload():

function parsePostedPayload(payload) {
  if (payload.event !== "posted") return null;
  // ...
}

Line 723 — WebSocket message handler:

if (payload.event !== "posted") return;
const parsed = parsePostedPayload(payload);

post_edited events from Mattermost'''s WebSocket API hit both guards and return early. Mention detection, wake-up, and session routing are never reached.

Fix Action

Workaround

Until fixed: @mentions must be included in the original posted message. If a tag is missed, send a fresh follow-up — do not edit the original.

PR fix notes

PR #72513: fix(mattermost): handle post_edited websocket events (#71930)

Description (problem / solution / changelog)

Closes #71930.

Problem

In a Mattermost channel where the bot is already running, adding an @mention by editing an existing message never wakes the agent. The mention is simply ignored.

Root cause

The Mattermost WebSocket dispatcher at extensions/mattermost/src/mattermost/monitor-websocket.ts filters events by literal string match on event === "posted":

if (data.event === "posted") {
  // ... parse data.post, dispatch to onPosted
}
// any other event silently dropped

post_edited carries the full updated post body in data.post (same shape as posted — verified against the Mattermost server WebSocket event schema), but it never reaches the dispatcher branch. The agent has no way to learn that the message it ignored a moment ago now contains an @mention directed at it.

Reproducer

  1. Configure OpenClaw on Mattermost with a bot user @openclawbot in some channel.
  2. From a different account, post a message without mention: hello world.
  3. Edit that message to add the mention: hello world @openclawbot.
  4. Observe: bot does not react. Logs show posted events but no trace of the edit.

Fix

Route post_edited through the same parsePostedPayloadonPosted path as posted. Mattermost's post_edited payload carries the full updated post body in data.post (same shape as posted), so no new parsing is required.

Implementation:

// New seam: events that carry data.post and should be re-evaluated.
const POST_BEARING_EVENTS = new Set(["posted", "post_edited"]);

if (POST_BEARING_EVENTS.has(data.event)) {
  if (data.event === "post_edited") {
    log.debug(`mattermost: re-evaluating edited post ${postId} (post_edited)`);
  }
  // ... existing parse + dispatch path, unchanged
}

A debug log breadcrumb is emitted on the edit path so dropped vs. handled edits are diffable in logs (satisfies the issue's "at minimum, emit a warning log" ask).

Why not filter bot-self edits at the WS layer?

The bot-self loop concern (an assistant editing its own past replies) is already mitigated downstream:

  • extensions/mattermost/src/mattermost/monitor.ts:1201 drops events where senderId === botUserId.
  • The post debouncer keys on post.id, so an edit of an in-flight post replaces rather than double-fires.

The WebSocket layer is the wrong seam for that filter. The right move here is to stop dropping the event.

Verification

pnpm vitest run extensions/mattermost/src/mattermost/monitor-websocket.test.ts
# 12 passed (8 original + 4 new)

pnpm vitest run extensions/mattermost
# 363 passed across 37 mattermost test files, no regressions

pnpm check
# 0 errors, 0 warnings; all policy guards green

Tests added (4 new)

  1. post_edited dispatch — event with full post body in data.post reaches onPosted; debug log re-evaluating edited post ... is emitted (regression for #71930).
  2. posted backward-compat — still dispatches; no edit-log breadcrumb emitted on the non-edit path.
  3. Bot-self post_edited — still forwarded at the WebSocket layer; downstream monitor.ts is responsible for filtering.
  4. Malformed post_edited (missing data.post) — silently dropped, no crash, no error log.

Risk notes

  • parsePostedPayload's name now slightly understates what it handles (it accepts both posted and post_edited). Did NOT rename to avoid cascading API churn (it's a public export). The POST_BEARING_EVENTS Set + comment block above documents the intent.
  • post_deleted is NOT added — it carries a different payload shape (post_id only, no full body) and is out of scope for this PR.
  • Diff: +18 lines in monitor-websocket.ts, +178 lines in tests.

Changed files

  • extensions/mattermost/src/mattermost/monitor-websocket.test.ts (modified, +174/-0)
  • extensions/mattermost/src/mattermost/monitor-websocket.ts (modified, +16/-2)

Code Example

function parsePostedPayload(payload) {
  if (payload.event !== "posted") return null;
  // ...
}

---

if (payload.event !== "posted") return;
const parsed = parsePostedPayload(payload);
RAW_BUFFERClick to expand / collapse

Summary

The Mattermost WebSocket plugin subscribes to posted events only. post_edited events are discarded before mention detection runs, so an @mention added by editing a message never wakes the tagged agent. The drop is silent — no error, no log entry.

Reproduction (confirmed 2026-04-25)

  1. Post a message in a Mattermost channel with no @mention → agent correctly does not wake
  2. Edit that message to add @agentname → agent does not wake (bug)
  3. Post a fresh follow-up with @agentname in the original send → agent wakes correctly

Root Cause

Two hard guards in channel.runtime-Ci-PEA8h.js reject any non-posted event:

Line 590 — parsePostedPayload():

function parsePostedPayload(payload) {
  if (payload.event !== "posted") return null;
  // ...
}

Line 723 — WebSocket message handler:

if (payload.event !== "posted") return;
const parsed = parsePostedPayload(payload);

post_edited events from Mattermost'''s WebSocket API hit both guards and return early. Mention detection, wake-up, and session routing are never reached.

Expected Behavior

When a message is edited to add an @mention, OpenClaw should evaluate the updated message body and fire the same mention/wake flow as if the @mention had been in the original post. Or at minimum, emit a warning log when a post_edited event contains an @mention that would have triggered wake.

Actual Behavior

The post_edited event is silently dropped. The agent is never woken.

OpenClaw Version

2026.4.20

Workaround

Until fixed: @mentions must be included in the original posted message. If a tag is missed, send a fresh follow-up — do not edit the original.

Notes

This also affects any future use of Mattermost'''s edit-to-correct-mention UX pattern. Given that OpenClaw'''s own agents edit messages in-flight (e.g., "let me check memory" → edited to final tagged response), there is a real risk of agents tagging each other via edit and silently losing the wake event.

The fix likely involves adding a post_edited branch to the WebSocket handler that re-parses the updated post body and feeds it through the existing mention gate logic. Deduplication (don'''t re-wake for a non-mention edit) would be the main complexity.

extent analysis

TL;DR

The fix likely involves modifying the WebSocket handler to handle post_edited events and re-parse the updated post body for mention detection.

Guidance

  • Identify the lines of code responsible for dropping post_edited events (e.g., parsePostedPayload() and the WebSocket message handler) and consider adding a branch for post_edited events.
  • Replicate the mention detection logic for post_edited events to ensure that edited messages with new @mentions trigger the wake-up flow.
  • Implement deduplication to prevent re-waking for non-mention edits.
  • Test the changes with the provided reproduction steps to verify the fix.

Example

if (payload.event === "posted" || payload.event === "post_edited") {
  const parsed = parsePostedPayload(payload);
  // existing mention detection and wake-up logic
}

Notes

The provided workaround (including @mentions in the original post or sending a fresh follow-up) can be used until a fix is implemented. The fix may require additional complexity to handle deduplication and prevent unnecessary wake-ups.

Recommendation

Apply a workaround until the fix is implemented, as the current behavior may cause silent drops of post_edited events with @mentions.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING