This commit is contained in:
Lalit Singh 2026-01-30 16:43:18 +01:00 committed by GitHub
commit 4101a88833
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 19 additions and 3 deletions

View File

@ -74,7 +74,7 @@ describe("resolveDiscordReplyDeliveryPlan", () => {
expect(plan.replyReference.use()).toBeUndefined();
});
it("always uses existingId when inside a thread", () => {
it("respects replyToMode off when inside a thread", () => {
const plan = resolveDiscordReplyDeliveryPlan({
replyTarget: "channel:thread",
replyToMode: "off",
@ -82,6 +82,17 @@ describe("resolveDiscordReplyDeliveryPlan", () => {
threadChannel: { id: "thread" },
createdThreadId: null,
});
expect(plan.replyReference.use()).toBeUndefined();
});
it("uses message reference when inside a thread with replyToMode first", () => {
const plan = resolveDiscordReplyDeliveryPlan({
replyTarget: "channel:thread",
replyToMode: "first",
messageId: "m1",
threadChannel: { id: "thread" },
createdThreadId: null,
});
expect(plan.replyReference.use()).toBe("m1");
});
});

View File

@ -304,9 +304,14 @@ export function resolveDiscordReplyDeliveryPlan(params: {
replyTarget = deliverTarget;
}
const allowReference = deliverTarget === originalReplyTarget;
const effectiveReplyToMode = allowReference ? params.replyToMode : "off";
// Don't pass existingId when replyToMode is "off" - this prevents
// unwanted reply references in threads when the user has disabled them
const existingId =
params.threadChannel && effectiveReplyToMode !== "off" ? params.messageId : undefined;
const replyReference = createReplyReferencePlanner({
replyToMode: allowReference ? params.replyToMode : "off",
existingId: params.threadChannel ? params.messageId : undefined,
replyToMode: effectiveReplyToMode,
existingId,
startId: params.messageId,
allowReference,
});