Skip to content

fix(discord): ensure autoThread replies route to existing threads#8302

Merged
thewilloftheshadow merged 2 commits intoopenclaw:mainfrom
gavinbmoore:fix/8278-discord-autothread-routing
Feb 13, 2026
Merged

fix(discord): ensure autoThread replies route to existing threads#8302
thewilloftheshadow merged 2 commits intoopenclaw:mainfrom
gavinbmoore:fix/8278-discord-autothread-routing

Conversation

@gavinbmoore
Copy link

@gavinbmoore gavinbmoore commented Feb 3, 2026

Summary

Fixes #8278

When autoThread: true is configured for a Discord channel, replies were sometimes routing to the root channel instead of the thread after the thread was created.

Root Cause

The resolveDiscordReplyDeliveryPlan function was only setting the explicit thread delivery target when a NEW thread was created (when createdThreadId is truthy). For subsequent messages in an existing thread (where threadChannel is set but createdThreadId is null), the delivery target fell back to the originalReplyTarget which relied on message.channelId.

While message.channelId should be the thread ID for thread messages, there could be edge cases where this doesn't resolve correctly, or where the reply target resolution differs.

Fix

Added explicit handling for existing threads: when threadChannel is set (we're in an existing thread) but no new thread was created, explicitly route to channel:${threadChannel.id}. This ensures all replies in a thread context go to the thread, not the root channel.

// 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
else if (params.threadChannel?.id) {
  deliverTarget = `channel:${params.threadChannel.id}`;
  replyTarget = deliverTarget;
}

Testing

  • All existing threading tests pass (7 tests)
  • Typecheck passes

Greptile Overview

Greptile Summary

This PR updates resolveDiscordReplyDeliveryPlan to explicitly set deliverTarget/replyTarget to the current thread’s channel ID not only when a new thread is created (createdThreadId), but also when threadChannel indicates the message is already in an existing thread. This prevents autoThread: true follow-up replies from occasionally falling back to the root channel via the original replyTarget.

Change is localized to src/discord/monitor/threading.ts and keeps existing reply-reference behavior by disabling references when the delivery target is rewritten away from the original reply target.

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk; it’s a small, well-scoped routing fix.
  • The change only affects how reply/delivery targets are chosen in one function, adds a straightforward missing branch for existing threads, and preserves prior behavior for non-thread contexts. No new dependencies or API changes are introduced.
  • No files require special attention

Context used:

  • Context from dashboard - CLAUDE.md (source)
  • Context from dashboard - AGENTS.md (source)

Claw and others added 2 commits February 13, 2026 13:02
Fixes openclaw#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.
@thewilloftheshadow thewilloftheshadow force-pushed the fix/8278-discord-autothread-routing branch from ea1af82 to a31b7b1 Compare February 13, 2026 19:04
@thewilloftheshadow thewilloftheshadow merged commit 7193952 into openclaw:main Feb 13, 2026
@thewilloftheshadow
Copy link
Member

Landed via temp rebase onto main.\n\n- Gate: pnpm lint && pnpm build (tests skipped per request)\n- Land commit: 7193952\n- Merge commit: 7193952\n\nThanks @gavinbmoore!

zhangyang-crazy-one pushed a commit to zhangyang-crazy-one/openclaw that referenced this pull request Feb 13, 2026
Hansen1018 pushed a commit to Hansen1018/openclaw that referenced this pull request Feb 14, 2026
GwonHyeok pushed a commit to learners-superpumped/openclaw that referenced this pull request Feb 15, 2026
cloud-neutral pushed a commit to cloud-neutral-toolkit/openclawbot.svc.plus that referenced this pull request Feb 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: discord Channel integration: discord size: XS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Discord] autoThread replies sometimes route to root channel instead of thread

2 participants

Comments