← Back to PRs

#6003: feat(slack): auto-follow threads where bot was mentioned in root message

by SWYZZWH open 2026-02-01 05:57 View on GitHub →
channel: slack
## Summary Closes #6005 Closes #6002 When a user mentions the bot in a Slack channel message, the bot now automatically follows the resulting thread — subsequent replies no longer require re-mentioning the bot. ## Changes - **New:** `src/slack/monitor/thread-mention-cache.ts` — Bounded LRU cache (max 1000 entries, 1h TTL) that tracks `channelId:threadTs` pairs where the bot was explicitly mentioned in the root message - **Modified:** `src/slack/monitor/message-handler/prepare.ts` — Records mentions for root-level messages; checks cache during thread reply processing to set `implicitMention = true` - **New:** `src/slack/monitor/thread-mention-cache.test.ts` — Unit tests for the cache - **Modified:** `src/channels/mention-gating.test.ts` — Added test case for implicit mention (thread auto-follow scenario) ## How it works 1. When a channel message explicitly mentions the bot and is NOT a thread reply, record `{channelId, messageTs}` in the cache 2. When processing a thread reply, look up `{channelId, threadTs}` in the cache 3. If found (and not expired), treat the reply as an implicit mention → bypasses `requireMention` gating ## Testing - 10 tests pass (6 mention-gating + 4 thread-mention-cache) - TypeScript compiles clean (`tsc --noEmit`) - Lint clean (`oxlint`) - Format clean (`oxfmt`) ## AI Disclosure - [x] AI-assisted (built with Claude) - [x] Fully tested - [x] I understand what the code does

Most Similar PRs