Skip to content

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

Closed
rockcent wants to merge 1 commit intoopenclaw:mainfrom
rockcent:fix/issue-59758-mattermost-dm-thread
Closed

fix(mattermost): prioritize threadRootId over kind===direct for DM thread replies [fixes #59758]#59791
rockcent wants to merge 1 commit intoopenclaw:mainfrom
rockcent:fix/issue-59758-mattermost-dm-thread

Conversation

@rockcent
Copy link
Copy Markdown
Contributor

@rockcent rockcent commented Apr 2, 2026

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.

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

greptile-apps Bot commented Apr 2, 2026

Greptile Summary

This PR adds a clarifying comment and a new test case to resolveMattermostEffectiveReplyToId, documenting that threadRootId is intentionally evaluated before the kind === "direct" guard. The code logic ordering was already correct; the commit solidifies the invariant with an explicit regression test covering the DM-thread reply scenario.

Confidence Score: 5/5

  • Safe to merge — minimal change (comment + test), no logic altered, test accurately describes the intended behavior.
  • Only three comment lines and one test case were added; the underlying logic ordering was already correct before this PR. The new test correctly asserts that a direct message with a non-empty threadRootId returns threadRootId, and the existing test suite continues to cover all other branches. No P0/P1 findings.
  • No files require special attention.

Reviews (1): Last reviewed commit: "fix(mattermost): prioritize threadRootId..." | Re-trigger Greptile

@steipete
Copy link
Copy Markdown
Contributor

Closing this as implemented after Codex review.

Current main already implements the behavior this PR proposes. The Mattermost reply-target logic returns threadRootId before the direct-message guard, and the downstream thread-session helper preserves that reply target for threaded follow-ups. The PR discussion also states the submitted diff only adds a comment and regression test because the logic ordering was already correct.

What I checked:

  • Current reply-target logic already matches the PR: resolveMattermostEffectiveReplyToId returns threadRootId before checking params.kind === "direct", which is the exact precedence this PR claims to add. (extensions/mattermost/src/mattermost/monitor.ts:342, ec3dbd22a4de)
  • Thread session handling preserves the effective thread reply target: resolveMattermostThreadSessionContext feeds the effective reply id into resolveThreadSessionKeys, so when a DM has a threadRootId, follow-ups stay attached to that thread instead of falling back to the linear DM session. (extensions/mattermost/src/mattermost/monitor.ts:366, ec3dbd22a4de)
  • Existing tests already cover the same precedence shape: Current tests already assert that an existing thread root wins over a new top-level reply target, and that threaded follow-ups keep the existing root in session context. The missing piece from this PR is only a more specific DM-thread regression case. (extensions/mattermost/src/mattermost/monitor.test.ts:435, ec3dbd22a4de)
  • PR discussion says the code path was already correct: The Greptile review on this PR states the logic ordering was already correct and that the submitted change only adds a clarifying comment plus a regression test for the DM-thread case. (606291f52b1d)
  • The latest shipped release already contains the same implementation: Release commit a9797214338ba31c52c796adbb75afb16e0684a9 contains the same resolveMattermostEffectiveReplyToId ordering now present on main, so this behavior is not waiting on this PR to ship. (extensions/mattermost/src/mattermost/monitor.ts:342, a9797214338b)

So I’m closing this as already implemented rather than keeping a duplicate issue open.

Review notes: reviewed against ec3dbd22a4de; fix evidence: commit a9797214338b.

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.

Mattermost DM replies go to new Thread instead of main channel

2 participants