fix(mattermost): honor replyToMode off for threaded messages

This commit is contained in:
create 2026-03-23 01:01:20 +08:00 committed by Peter Steinberger
parent 55e0c6380a
commit aaba1ae653
2 changed files with 28 additions and 1 deletions

View File

@ -169,6 +169,17 @@ describe("resolveMattermostEffectiveReplyToId", () => {
).toBe("thread-root-456");
});
it("suppresses existing thread roots when replyToMode is off", () => {
expect(
resolveMattermostEffectiveReplyToId({
kind: "channel",
postId: "post-123",
replyToMode: "off",
threadRootId: "thread-root-456",
}),
).toBeUndefined();
});
it("starts a thread for top-level channel messages when replyToMode is all", () => {
expect(
resolveMattermostEffectiveReplyToId({
@ -232,6 +243,22 @@ describe("resolveMattermostThreadSessionContext", () => {
});
});
it("keeps threaded messages top-level when replyToMode is off", () => {
expect(
resolveMattermostThreadSessionContext({
baseSessionKey: "agent:main:mattermost:default:chan-1",
kind: "group",
postId: "post-123",
replyToMode: "off",
threadRootId: "root-456",
}),
).toEqual({
effectiveReplyToId: undefined,
sessionKey: "agent:main:mattermost:default:chan-1",
parentSessionKey: undefined,
});
});
it("keeps direct-message sessions linear", () => {
expect(
resolveMattermostThreadSessionContext({

View File

@ -175,7 +175,7 @@ export function resolveMattermostEffectiveReplyToId(params: {
threadRootId?: string | null;
}): string | undefined {
const threadRootId = params.threadRootId?.trim();
if (threadRootId) {
if (threadRootId && params.replyToMode !== "off") {
return threadRootId;
}
if (params.kind === "direct") {