feat(discord): follow threads after first mention#1276
Open
Hitesh-Sisara wants to merge 1 commit into
Open
Conversation
Once the bot is @mentioned in a Discord thread, it responds to all subsequent messages in that thread without requiring further mentions. This matches the behavior of Hermes and other Discord bots where you mention once to activate, then the bot follows the entire thread. Implementation: - Track mentioned thread IDs in a map (capped at 5000 entries) - On each group message, check if channelID is a tracked thread - If yes, skip mention requirement and process the message - If mentioned in a new thread, add it to the tracked set
mrgoonie
requested changes
Jun 24, 2026
mrgoonie
left a comment
Contributor
There was a problem hiding this comment.
Thanks for the contribution. I reviewed this against current dev and the feature direction is reasonable, but this implementation is not safe to merge yet.
Summary: the PR adds in-memory tracking so a Discord thread keeps responding after the first bot mention. The changed files are small (internal/channels/discord/discord.go, handler.go), and I found no duplicate PR/issue for this exact feature.
Mandatory gates:
- Duplicate / prior implementation: clear. Search only found this PR plus unrelated channel work; git history only found prior thread backfill work.
- Project standards: docs found (
CLAUDE.md,AGENTS.md). This is gateway/channel-only; UI/API/CLI parity is N/A. - Strategic necessity: clear UX value for Discord thread conversations.
Important blocker:
- The remembered-thread bypass is checked after
checkGroupPolicy(ctx, senderID, channelID, mentioned), butcheckGroupPolicystill receivesmentioned=falsefor follow-up thread messages. ForPolicyNeedsPairing, it immediately returns false whenRequireMention()is true andmentionedis false. That means this feature only works for already-allowed groups and still cannot activate pairing/setup replies or policy flow for remembered threads. Worse, the new bypass and the policy gate now disagree on whether the bot was addressed. The thread-follow decision needs to be computed before policy evaluation and passed consistently into policy gating, or explicitly scoped so remembered threads are only honored after the group is already allowed.
Suggested follow-ups:
- Add regression coverage for: first mention in thread records the thread; second unmentioned message in the same thread reaches the bus when group policy allows it; unrelated regular channel still requires mention; and
PolicyNeedsPairingbehavior is intentionally defined. - Consider avoiding repeated Discord API lookups by deriving/cache-checking thread status once per message instead of calling
isThreadChanneltwice.
Verdict: Request changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Once the bot is @mentioned in a Discord thread, it responds to all subsequent messages in that thread without requiring further mentions.
Motivation
Current behavior requires @mentioning the bot on every single message in groups/threads. This is tedious for ongoing conversations. Users expect to mention once to activate, then the bot follows the entire thread (like Hermes and other Discord bots).
Changes
internal/channels/discord/discord.go: AddedmentionedThreadsmap + mutex to Channel structinternal/channels/discord/handler.go: Modified mention gating logic to check thread membershipHow it works
mentionedThreadsisThreadChannelcheck), not regular channelsTesting