← Back to PRs

#2300: fix(mattermost): ensure replies create threads in channels

by blizzy78 open 2026-01-26 17:20 View on GitHub →
channel: mattermost
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