Skip to content

Commit 606291f

Browse files
author
OpenClaw Contributor Bot
committed
fix(mattermost): prioritize threadRootId over kind===direct for DM thread replies
1 parent 8d81e76 commit 606291f

2 files changed

Lines changed: 16 additions & 0 deletions

File tree

extensions/mattermost/src/mattermost/monitor.test.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,19 @@ describe("resolveMattermostEffectiveReplyToId", () => {
210210
}),
211211
).toBeUndefined();
212212
});
213+
214+
it("uses threadRootId for DM Thread messages (prioritize thread over kind===direct)", () => {
215+
// When a DM opens a thread, threadRootId should take precedence so replies go
216+
// to the existing thread instead of creating a new one.
217+
expect(
218+
resolveMattermostEffectiveReplyToId({
219+
kind: "direct",
220+
postId: "post-123",
221+
replyToMode: "all",
222+
threadRootId: "root-456",
223+
}),
224+
).toBe("root-456");
225+
});
213226
});
214227

215228
describe("resolveMattermostThreadSessionContext", () => {

extensions/mattermost/src/mattermost/monitor.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,9 @@ export function resolveMattermostEffectiveReplyToId(params: {
175175
threadRootId?: string | null;
176176
}): string | undefined {
177177
const threadRootId = params.threadRootId?.trim();
178+
// Check threadRootId first — a DM Thread message should reply to the thread,
179+
// not go to a new thread. Only fall through to kind===direct logic when there
180+
// is no threadRootId.
178181
if (threadRootId && params.replyToMode !== "off") {
179182
return threadRootId;
180183
}

0 commit comments

Comments
 (0)