openclaw - ✅(Solved) Fix Mattermost DM replies go to new Thread instead of main channel [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#59758Fetched 2026-04-08 02:40:55
View on GitHub
Comments
0
Participants
1
Timeline
1
Reactions
0
Participants
Timeline (top)
cross-referenced ×1

Root Cause

Root Cause: The threadRootId check should be prioritized before kind === "direct" check. Currently for DM Thread messages, threadRootId is set but the logic causes replies to go to a new Thread.

Fix Action

Fixed

PR fix notes

PR #59791: fix(mattermost): prioritize threadRootId over kind===direct for DM thread replies [fixes #59758]

Description (problem / solution / changelog)

Fixes #59758

What

In Mattermost, when a DM opens a thread and the user replies within that thread, the reply was incorrectly going to a new thread instead of staying in the existing thread.

How

The resolveMattermostEffectiveReplyToId function now checks threadRootId first, before falling through to kind===direct logic. A DM Thread message should reply to the thread — only fall through to direct-message logic when there is no threadRootId.

Added a test case that verifies a direct message with a threadRootId correctly returns the threadRootId.

Changed files

  • extensions/mattermost/src/mattermost/monitor.test.ts (modified, +13/-0)
  • extensions/mattermost/src/mattermost/monitor.ts (modified, +3/-0)
RAW_BUFFERClick to expand / collapse

Problem

When receiving a DM in Mattermost, bot replies go to a new Thread instead of the main DM channel.

Expected Behavior

  • DM main list message → reply should appear in main DM list
  • DM Thread message → reply should appear in that Thread

Current Behavior

All DM replies go to a new Thread, breaking the conversation flow.

Environment

  • OpenClaw with Mattermost plugin

Technical Details

The issue is in the resolveMattermostReplyRootId and resolveMattermostEffectiveReplyToId functions in auth-profiles-*.js.

Root Cause: The threadRootId check should be prioritized before kind === "direct" check. Currently for DM Thread messages, threadRootId is set but the logic causes replies to go to a new Thread.

Suggested Fix: Adjust the check order in both functions - threadRootId should be checked first, then kind === "direct" applies only when threadRootId is empty.

extent analysis

TL;DR

Adjust the check order in resolveMattermostReplyRootId and resolveMattermostEffectiveReplyToId functions to prioritize threadRootId over kind === "direct".

Guidance

  • Review the resolveMattermostReplyRootId and resolveMattermostEffectiveReplyToId functions in auth-profiles-*.js to understand the current logic flow.
  • Modify the condition checks to ensure threadRootId is checked before kind === "direct", allowing DM replies to be correctly routed to the main DM channel or the existing thread.
  • Verify the fix by testing DM replies in both the main DM channel and within threads, ensuring replies appear in the expected location.
  • Consider adding logging or debugging statements to monitor the threadRootId and kind values during the reply process to help identify any further issues.

Example

// Example adjustment in resolveMattermostReplyRootId function
if (threadRootId) {
  // Use threadRootId to determine reply location
} else if (kind === "direct") {
  // Handle direct messages without a threadRootId
}

Notes

This fix assumes that the threadRootId is correctly set for DM thread messages and that the issue is solely due to the check order in the mentioned functions.

Recommendation

Apply the suggested workaround by adjusting the check order in the resolveMattermostReplyRootId and resolveMattermostEffectiveReplyToId functions, as this directly addresses the identified root cause of the issue.

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

openclaw - ✅(Solved) Fix Mattermost DM replies go to new Thread instead of main channel [1 pull requests, 1 participants]