mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-11 07:24:32 +00:00
fix(slack): honor replyToModeByChatType when ThreadLabel exists (#26251)
* fix(slack): honor direct replyToMode when thread label exists ThreadLabel is a session/conversation label, not a reliable indicator of an actual Slack thread reply. Using it to force replyToMode="all" overrides replyToModeByChatType.direct="off" in DMs. Switch to MessageThreadId which indicates a real thread target is available, preserving expected behavior: thread replies stay threaded, normal DMs respect the configured mode. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * Slack: add changelog for threading tool context fix --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com> Co-authored-by: Tak Hoffman <781889+Takhoffman@users.noreply.github.com>
This commit is contained in:
@@ -86,20 +86,64 @@ describe("buildSlackThreadingToolContext", () => {
|
||||
expect(result.replyToMode).toBe("all");
|
||||
});
|
||||
|
||||
it("uses all mode when ThreadLabel is present", () => {
|
||||
it("uses all mode when MessageThreadId is present", () => {
|
||||
const cfg = {
|
||||
channels: {
|
||||
slack: { replyToMode: "off" },
|
||||
slack: {
|
||||
replyToMode: "all",
|
||||
replyToModeByChatType: { direct: "off" },
|
||||
},
|
||||
},
|
||||
} as OpenClawConfig;
|
||||
const result = buildSlackThreadingToolContext({
|
||||
cfg,
|
||||
accountId: null,
|
||||
context: { ChatType: "channel", ThreadLabel: "some-thread" },
|
||||
context: {
|
||||
ChatType: "direct",
|
||||
ThreadLabel: "thread-label",
|
||||
MessageThreadId: "1771999998.834199",
|
||||
},
|
||||
});
|
||||
expect(result.replyToMode).toBe("all");
|
||||
});
|
||||
|
||||
it("does not force all mode from ThreadLabel alone", () => {
|
||||
const cfg = {
|
||||
channels: {
|
||||
slack: {
|
||||
replyToMode: "all",
|
||||
replyToModeByChatType: { direct: "off" },
|
||||
},
|
||||
},
|
||||
} as OpenClawConfig;
|
||||
const result = buildSlackThreadingToolContext({
|
||||
cfg,
|
||||
accountId: null,
|
||||
context: {
|
||||
ChatType: "direct",
|
||||
ThreadLabel: "label-without-real-thread",
|
||||
},
|
||||
});
|
||||
expect(result.replyToMode).toBe("off");
|
||||
});
|
||||
|
||||
it("keeps configured channel behavior when not in a thread", () => {
|
||||
const cfg = {
|
||||
channels: {
|
||||
slack: {
|
||||
replyToMode: "off",
|
||||
replyToModeByChatType: { channel: "first" },
|
||||
},
|
||||
},
|
||||
} as OpenClawConfig;
|
||||
const result = buildSlackThreadingToolContext({
|
||||
cfg,
|
||||
accountId: null,
|
||||
context: { ChatType: "channel", ThreadLabel: "label-only" },
|
||||
});
|
||||
expect(result.replyToMode).toBe("first");
|
||||
});
|
||||
|
||||
it("defaults to off when no replyToMode is configured", () => {
|
||||
const result = buildSlackThreadingToolContext({
|
||||
cfg: emptyCfg,
|
||||
|
||||
@@ -16,7 +16,8 @@ export function buildSlackThreadingToolContext(params: {
|
||||
accountId: params.accountId,
|
||||
});
|
||||
const configuredReplyToMode = resolveSlackReplyToMode(account, params.context.ChatType);
|
||||
const effectiveReplyToMode = params.context.ThreadLabel ? "all" : configuredReplyToMode;
|
||||
const hasExplicitThreadTarget = params.context.MessageThreadId != null;
|
||||
const effectiveReplyToMode = hasExplicitThreadTarget ? "all" : configuredReplyToMode;
|
||||
const threadId = params.context.MessageThreadId ?? params.context.ReplyToId;
|
||||
return {
|
||||
currentChannelId: params.context.To?.startsWith("channel:")
|
||||
|
||||
Reference in New Issue
Block a user