fix(mattermost): prevent DM replies from threading via resolveMattermostReplyRootId#60115
fix(mattermost): prevent DM replies from threading via resolveMattermostReplyRootId#60115jwchmodx wants to merge 1 commit intoopenclaw:mainfrom
Conversation
…ostReplyRootId Direct messages in Mattermost were creating threads even with replyToMode=off because resolveMattermostReplyRootId would fall back to payload.replyToId regardless of chat kind. When a downstream payload carried a replyToId (e.g. from block-streaming delivery), this bypassed the earlier DM threading guard and set root_id on the outbound post, making DM replies appear as threads instead of in the channel body. Fix: pass kind through all three delivery call sites and hard-return undefined inside resolveMattermostReplyRootId for kind="direct", mirroring the resolveMattermostEffectiveReplyToId guard that already existed for session-key resolution. Fixes openclaw#59981
Greptile SummaryThis PR fixes a threading bug in the Mattermost extension where DM bot replies were incorrectly sent with a non-empty Confidence Score: 5/5Safe to merge — minimal, focused fix with regression tests covering both DM threading scenarios. All three delivery call sites correctly pass No files require special attention. Reviews (1): Last reviewed commit: "fix(mattermost): prevent DM replies from..." | Re-trigger Greptile |
Problem
Mattermost DM auto-replies were sent with a non-empty
root_id, creating threads in the DM channel despite the documentation stating that direct messages ignorereplyToModeand stay non-threaded.The bug was in
resolveMattermostReplyRootId: it would fall back topayload.replyToIdregardless of chat kind. Even thoughresolveMattermostEffectiveReplyToIdalready correctly returnsundefinedfor DMs (guarding session-key resolution), the delivery path could still reintroduce a thread root when a downstream payload carried areplyToId— for example, during block-streaming delivery where each block carries the inbound post ID asreplyToId.This caused all DM bot replies to appear as threads, making the main channel body appear empty to users.
Fixes #59981
Fix
Add
kind: ChatTypetoresolveMattermostReplyRootIdand hard-returnundefinedwhenkind === "direct", mirroring the guard that already existed inresolveMattermostEffectiveReplyToId.Update all three delivery call sites to pass
kind:Tests
Added two regression tests to
resolveMattermostReplyRootId:replyToId→undefined(was: returnsreplyToId, causing threading)threadRootIdandreplyToId→undefinedAll 22 Mattermost monitor tests pass.