#2300: fix(mattermost): ensure replies create threads in channels
channel: mattermost
Cluster:
Mattermost Threading Enhancements
This PR ensures that Clawdbot starts a new thread when replying to a message in a Mattermost channel, instead of sending a top-level message.
- Fallback to `post.id` as `threadRootId` if `post.root_id` is missing. Posts in a channel don't have a `root_id` until there are actual answers in a thread.
- Excludes DMs to maintain standard direct messaging behavior (unthreaded unless already in a thread).
AI assisted during development. Reviewed and tested by actual humans.
<!-- greptile_comment -->
<h2>Greptile Overview</h2>
<h3>Greptile Summary</h3>
This PR adjusts Mattermost inbound handling so that for channel/group posts without a `root_id`, the bot treats the post’s own `id` as the thread root (while leaving DMs unchanged). This ensures replies are sent as threaded replies in channels/groups rather than as top-level posts, by flowing the derived `threadRootId` through session key derivation, typing indicators, and `sendMessageMattermost(..., { replyToId })`.
<h3>Confidence Score: 4/5</h3>
- This PR appears safe to merge and is unlikely to introduce regressions beyond threading behavior.
- The change is a one-line adjustment to `threadRootId` derivation scoped to non-DM messages, and the resulting value is already used consistently across reply/typing/session plumbing. I did not find additional call sites that would conflict with using `post.id` as a synthetic thread root for channel/group messages lacking `root_id`. Confidence is slightly reduced because Mattermost thread semantics can vary by server/version and the debounce key still uses `root_id` only.
- extensions/mattermost/src/mattermost/monitor.ts
<!-- greptile_other_comments_section -->
<sub>(2/5) Greptile learns from your feedback when you react with thumbs up/down!</sub>
<!-- /greptile_comment -->
Most Similar PRs
#19274: feat(mattermost): enable threaded replies in channels
by rockinyp · 2026-02-17
87.8%
#16570: feat(mattermost): add replyToMode threading support
by FBartos · 2026-02-14
83.3%
#10587: fix(extensions/mattermost): pass requireMention override from chatm...
by baku4 · 2026-02-06
76.4%
#19213: Telegram: preserve DM topic thread in direct replies
by Kemalau · 2026-02-17
75.8%
#7940: fix(googlechat): add messageReplyOption for proper thread replies
by sapko7a · 2026-02-03
75.5%
#14443: fix(telegram): skip General topic thread ID for all chat types (#14...
by lailoo · 2026-02-12
74.4%
#7261: fix(telegram): preserve DM topic thread id for outbound media
by ViffyGwaanl · 2026-02-02
74.4%
#3368: fix: sessions navigation, DM thread display, and DM thread delivery...
by Lukavyi · 2026-01-28
74.0%
#6192: Telegram: fix DM Topics thread routing
by ViffyGwaanl · 2026-02-01
73.6%
#10081: fix(mattermost): pass requireMentionOverride to core resolver
by manchmod · 2026-02-06
72.8%