Skip to content

fix(mattermost): honor replyToMode off for threaded messages#52543

Merged
steipete merged 17 commits intoopenclaw:mainfrom
RichardCao:fix/issue-52350-mattermost-replyto-off
Mar 23, 2026
Merged

fix(mattermost): honor replyToMode off for threaded messages#52543
steipete merged 17 commits intoopenclaw:mainfrom
RichardCao:fix/issue-52350-mattermost-replyto-off

Conversation

@RichardCao
Copy link
Copy Markdown
Contributor

Summary

  • respect replyToMode: "off" before reusing the incoming Mattermost root_id
  • keep existing threaded reply behavior unchanged for replyToMode: "first" and "all"
  • add regression coverage for threaded inbound messages when replies should be forced to top-level delivery

Testing

  • pnpm test -- extensions/mattermost/src/mattermost/monitor.test.ts

Fixes #52350

@openclaw-barnacle openclaw-barnacle Bot added channel: mattermost Channel integration: mattermost size: XS labels Mar 23, 2026
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Mar 23, 2026

Greptile Summary

This PR fixes a bug where incoming Mattermost messages that already belong to a thread (i.e., carry a non-empty root_id / threadRootId) would always be replied to inside that thread, ignoring the replyToMode: "off" configuration. The fix is a single targeted guard added to resolveMattermostEffectiveReplyToId in monitor.ts, and is accompanied by two new regression tests.

Changes:

  • monitor.ts line 178: the early return threadRootId path is now short-circuited when replyToMode === "off", letting the function fall through to its existing bottom path which correctly returns undefined for that mode.
  • All existing code paths for replyToMode: "first" and replyToMode: "all" are completely unchanged.
  • Two new unit tests in monitor.test.ts verify both the low-level resolveMattermostEffectiveReplyToId and the higher-level resolveMattermostThreadSessionContext behave correctly for the fixed case.

No issues found. The logic is minimal, correct, and the test coverage matches the bugfix.

Confidence Score: 5/5

  • Safe to merge — one-line targeted fix with direct regression coverage and no side-effects on existing modes.
  • The change is minimal (a single boolean guard on an existing condition), leaves the "first" and "all" paths entirely untouched, and is validated by two new tests that precisely cover the previously broken scenario. No other callers of this function are affected.
  • No files require special attention.

Reviews (1): Last reviewed commit: "fix(mattermost): honor replyToMode off f..." | Re-trigger Greptile

Copy link
Copy Markdown

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

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: bb3f032ab3

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines +178 to 179
if (threadRootId && params.replyToMode !== "off") {
return threadRootId;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve inbound thread identity when replyToMode is off

Suppressing threadRootId here changes more than outbound delivery: resolveMattermostThreadSessionContext() uses the same value to build the inbound SessionKey, ParentSessionKey, ReplyToId, and MessageThreadId later in extensions/mattermost/src/mattermost/monitor.ts:1319-1337. For messages that arrive inside an existing Mattermost thread with replyToMode: "off", those fields now become top-level channel values, so separate threads collapse into one session and thread-aware flows that read ctx.MessageThreadId (for example src/auto-reply/reply/commands-core.ts:75 and src/auto-reply/reply/session.ts:413-520) can no longer target the originating thread.

Useful? React with 👍 / 👎.

@steipete steipete merged commit aaba1ae into openclaw:main Mar 23, 2026
25 of 41 checks passed
@steipete
Copy link
Copy Markdown
Contributor

Landed via temp rebase onto main.

  • Gate: pnpm check && pnpm build && pnpm test
  • Land commit: da2d347
  • Merge commit: aaba1ae

Thanks @RichardCao!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: mattermost Channel integration: mattermost size: XS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: replyToMode "off" ignored when incoming message has root_id — causes Invalid RootId delivery failures

3 participants