feat(discord): add per-user auto-thread exclusion via DISCORD_NO_THREAD_USERS - #22373
feat(discord): add per-user auto-thread exclusion via DISCORD_NO_THREAD_USERS#22373VatsalyaB wants to merge 1 commit into
Conversation
Add two new configuration options for Discord auto-threading: - _discord_auto_thread_enabled(): reads from config.extra.auto_thread first (config.yaml), then DISCORD_AUTO_THREAD env var, defaulting to True. Uses the same pattern as _discord_require_mention(). - _discord_no_thread_users(): returns a set of Discord user IDs whose @mentions skip thread creation. Reads from config.extra.no_thread_users (config.yaml list) or DISCORD_NO_THREAD_USERS env var (comma-separated). - Auto-thread decision logic checks per-user exclusion list before creating a thread, alongside existing per-channel (no_thread_channels) and global (auto_thread) controls. Precedence: no_thread_users > no_thread_channels > auto_thread global toggle. - Config bridging: both auto_thread and no_thread_users bridged from config.yaml platforms section into platform extra (config.py) and env vars for adapter consumption. - Tests: 6 new tests covering per-user exclusion, CSV parsing, channel precedence, config bridging for auto_thread and no_thread_users.
|
Thanks for the focused Discord routing control. The per-user exclusion is still needed: current main creates threads after checking only channel/free-response exclusions at Problems
Suggested changes
Automated hermes-sweeper review. |
GottZ
left a comment
There was a problem hiding this comment.
This was generated by AI during triage.
Summary
Two PRs address related Discord auto-thread exclusions but target different causes: #4611 adds per-channel exclusions, while #22373 adds the still-missing per-user exclusion and also changes mention handling. The channel-level behavior from #4611 is already implemented on main; the reusable part of #22373 must be ported to the current plugin architecture.
Related pull requests
- #4611 [closed]
related— (+51/-0) — close as already implemented on main: the closed PR added a per-channel auto-thread exclusion, but the contributor review identifies the equivalentdiscord.no_thread_channelsimplementation atgateway/config.pylines 652–657 andgateway/platforms/discord.pylines 3251–3256, introduced by commitf6d4b6a3198b35e2ee340c617b2f3193a9ab727b. It remains relevant as the superseded channel-level counterpart to #22373. - #22373
related— (+211/-5) — keep open with a salvage path: consistent with the MAINTAINER-BOT keep_open review, the diff contains a distinct per-user author-ID exclusion that current main still lacks, but it modifies obsoletegateway/paths and mixes that feature with role-mention handling. Salvage the per-user check by porting it toplugins/platforms/discord/adapter.py:6221-6227, extending the YAML bridge nearplugins/platforms/discord/adapter.py:8229, and adding current-path tests plus the config and documentation coverage identified in the review.
Suggested consolidation
Keep #22373 open with a salvage path limited to the per-user no-thread control: rebase or port that logic onto the live plugin paths, expose it through the established discord: YAML surface, add current-path tests and documentation, and split out the unrelated role-mention changes if they remain necessary. #4611 should remain closed because its channel-level behavior is already present on main via commit f6d4b6a3198b35e2ee340c617b2f3193a9ab727b; the two PRs are related controls, not duplicates.
Cross-PR triage: Reviewed 2 pull requests and 0 issues in this complex. Each diff was read against this issue; Assessment working set: 19 kB of PR diffs, 4 kB of issue/PR text, <1 kB of discussion (1 comments), 0 verify verdicts. verdicts reflect diff content, not PR titles. Part of an automated triage batch.
Summary
Adds the ability to exclude specific Discord users from auto-thread creation on @mention. This is useful for users who prefer the bot to respond directly in the channel instead of spawning a new thread every time.
Changes
New helper methods (gateway/platforms/discord.py)
_discord_auto_thread_enabled()— reads fromconfig.extra.auto_threadfirst (config.yaml), thenDISCORD_AUTO_THREADenv var, defaulting toTrue. Follows the same pattern as_discord_require_mention()._discord_no_thread_users()— returns a set of Discord user IDs whose @mentions skip thread creation. Reads fromconfig.extra.no_thread_users(YAML list) orDISCORD_NO_THREAD_USERSenv var (comma-separated).Modified auto-thread logic
The auto-thread decision block now checks three conditions before creating a thread (in precedence order):
no_thread_users→ skipno_thread_channels→ skip (unchanged)auto_threadisfalse→ skip (unchanged, now uses structured method)Config bridging (gateway/config.py)
Both
auto_threadandno_thread_usersare bridged fromconfig.yaml'splatforms.discord.extrasection into the platform extra dict and env vars, following existing patterns likefree_response_channelsandno_thread_channels.Tests
6 new tests covering:
test_no_thread_user_skips_auto_thread)test_non_no_thread_user_still_auto_threads)test_no_thread_users_csv_parsing)test_no_thread_user_still_takes_channel_precedence)no_thread_users(test_config_bridges_no_thread_users)auto_thread(test_config_bridges_auto_thread)All 41 tests pass (35 existing + 6 new).
Configuration
Via env var
Via config.yaml
Related