From e65b649993188acc8540706160679a25d21bf353 Mon Sep 17 00:00:00 2001 From: Claw Date: Tue, 3 Feb 2026 21:24:30 +0000 Subject: [PATCH] fix(discord): ensure autoThread replies route to existing threads Fixes #8278 When autoThread is enabled and a thread already exists (user continues conversation in thread), replies were sometimes routing to the root channel instead of the thread. This happened because the reply delivery plan only explicitly set the thread target when a NEW thread was created (createdThreadId), but not when the message was in an existing thread. The fix adds a fallback case: when threadChannel is set (we're in an existing thread) but no new thread was created, explicitly route to the thread's channel ID. This ensures all thread replies go to the correct destination. --- src/discord/monitor/threading.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/discord/monitor/threading.ts b/src/discord/monitor/threading.ts index 470962aaf8f..045ae190a10 100644 --- a/src/discord/monitor/threading.ts +++ b/src/discord/monitor/threading.ts @@ -390,10 +390,18 @@ export function resolveDiscordReplyDeliveryPlan(params: { const originalReplyTarget = params.replyTarget; let deliverTarget = originalReplyTarget; let replyTarget = originalReplyTarget; + + // When a new thread was created, route to the new thread if (params.createdThreadId) { deliverTarget = `channel:${params.createdThreadId}`; replyTarget = deliverTarget; } + // When in an existing thread (not newly created), ensure we route to the thread + // This fixes #8278: autoThread replies sometimes going to root channel + else if (params.threadChannel?.id) { + deliverTarget = `channel:${params.threadChannel.id}`; + replyTarget = deliverTarget; + } const allowReference = deliverTarget === originalReplyTarget; const replyReference = createReplyReferencePlanner({ replyToMode: allowReference ? params.replyToMode : "off",