Skip to content

Commit aaba1ae

Browse files
createsteipete
authored andcommitted
fix(mattermost): honor replyToMode off for threaded messages
1 parent 55e0c63 commit aaba1ae

2 files changed

Lines changed: 28 additions & 1 deletion

File tree

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

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,17 @@ describe("resolveMattermostEffectiveReplyToId", () => {
169169
).toBe("thread-root-456");
170170
});
171171

172+
it("suppresses existing thread roots when replyToMode is off", () => {
173+
expect(
174+
resolveMattermostEffectiveReplyToId({
175+
kind: "channel",
176+
postId: "post-123",
177+
replyToMode: "off",
178+
threadRootId: "thread-root-456",
179+
}),
180+
).toBeUndefined();
181+
});
182+
172183
it("starts a thread for top-level channel messages when replyToMode is all", () => {
173184
expect(
174185
resolveMattermostEffectiveReplyToId({
@@ -232,6 +243,22 @@ describe("resolveMattermostThreadSessionContext", () => {
232243
});
233244
});
234245

246+
it("keeps threaded messages top-level when replyToMode is off", () => {
247+
expect(
248+
resolveMattermostThreadSessionContext({
249+
baseSessionKey: "agent:main:mattermost:default:chan-1",
250+
kind: "group",
251+
postId: "post-123",
252+
replyToMode: "off",
253+
threadRootId: "root-456",
254+
}),
255+
).toEqual({
256+
effectiveReplyToId: undefined,
257+
sessionKey: "agent:main:mattermost:default:chan-1",
258+
parentSessionKey: undefined,
259+
});
260+
});
261+
235262
it("keeps direct-message sessions linear", () => {
236263
expect(
237264
resolveMattermostThreadSessionContext({

extensions/mattermost/src/mattermost/monitor.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ export function resolveMattermostEffectiveReplyToId(params: {
175175
threadRootId?: string | null;
176176
}): string | undefined {
177177
const threadRootId = params.threadRootId?.trim();
178-
if (threadRootId) {
178+
if (threadRootId && params.replyToMode !== "off") {
179179
return threadRootId;
180180
}
181181
if (params.kind === "direct") {

0 commit comments

Comments
 (0)