fix: honor slack reply threading

This commit is contained in:
Mauro Bolis
2026-01-09 14:59:36 +01:00
committed by Peter Steinberger
parent 014a4d51a6
commit 96149d1f71
7 changed files with 145 additions and 9 deletions

View File

@@ -260,7 +260,9 @@ export async function runReplyAgent(params: {
followupRun.run.config,
replyToChannel,
);
const applyReplyToMode = createReplyToModeFilter(replyToMode);
const applyReplyToMode = createReplyToModeFilter(replyToMode, {
allowTagsWhenOff: replyToChannel === "slack",
});
const cfg = followupRun.run.config;
if (shouldSteer && isStreaming) {

View File

@@ -10,7 +10,7 @@ export function applyReplyTagsToPayload(
currentMessageId?: string,
): ReplyPayload {
if (typeof payload.text !== "string") return payload;
const { cleaned, replyToId } = extractReplyToTag(
const { cleaned, replyToId, hasTag } = extractReplyToTag(
payload.text,
currentMessageId,
);
@@ -18,6 +18,7 @@ export function applyReplyTagsToPayload(
...payload,
text: cleaned ? cleaned : undefined,
replyToId: replyToId ?? payload.replyToId,
replyToTag: hasTag || payload.replyToTag,
};
}

View File

@@ -40,6 +40,13 @@ describe("createReplyToModeFilter", () => {
expect(filter({ text: "hi", replyToId: "1" }).replyToId).toBeUndefined();
});
it("keeps replyToId when mode is off and reply tags are allowed", () => {
const filter = createReplyToModeFilter("off", { allowTagsWhenOff: true });
expect(
filter({ text: "hi", replyToId: "1", replyToTag: true }).replyToId,
).toBe("1");
});
it("keeps replyToId when mode is all", () => {
const filter = createReplyToModeFilter("all");
expect(filter({ text: "hi", replyToId: "1" }).replyToId).toBe("1");

View File

@@ -19,11 +19,15 @@ export function resolveReplyToMode(
}
}
export function createReplyToModeFilter(mode: ReplyToMode) {
export function createReplyToModeFilter(
mode: ReplyToMode,
opts: { allowTagsWhenOff?: boolean } = {},
) {
let hasThreaded = false;
return (payload: ReplyPayload): ReplyPayload => {
if (!payload.replyToId) return payload;
if (mode === "off") {
if (opts.allowTagsWhenOff && payload.replyToTag) return payload;
return { ...payload, replyToId: undefined };
}
if (mode === "all") return payload;