[PR #13252] fix(slack): handle app_mention events so thread @mentions are delivered to agents #14581

Closed
opened 2026-02-16 18:19:22 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/13252

State: closed
Merged: No


Summary

  • Add app.event('app_mention') handler so @mention messages in threads are processed by the agent
  • Extract shared processMessage() function to eliminate code duplication between message and app_mention handlers
  • Add timestamp-based deduplication to prevent double-processing when Slack sends both message and app_mention events for the same @mention

Problem

When a user @mentions the bot in a Slack thread (e.g. @SupportEngineer, please create a PR with a code fix), Slack sends an app_mention event. The bot only had an app.message() handler registered and completely ignored app_mention events, so the message was never delivered to the agent.

Root Cause

The Slack bot in packages/slack/src/index.ts only registered app.message() which handles regular channel messages. The app_mentions:read OAuth scope was listed in the README as required, but no app.event('app_mention', ...) handler existed in the code.

Changes

File Change
packages/slack/src/index.ts Add app.event('app_mention') handler, extract processMessage(), use dedup
packages/slack/src/dedup.ts New module: timestamp-based deduplication with configurable TTL
packages/slack/test/dedup.test.ts 6 tests for dedup logic including TTL expiry and Slack event simulation
packages/slack/tsconfig.json Exclude test dir from typecheck (bun:test types)
plan.md Task tracking

Closes #13251

**Original Pull Request:** https://github.com/anomalyco/opencode/pull/13252 **State:** closed **Merged:** No --- ## Summary - Add `app.event('app_mention')` handler so @mention messages in threads are processed by the agent - Extract shared `processMessage()` function to eliminate code duplication between `message` and `app_mention` handlers - Add timestamp-based deduplication to prevent double-processing when Slack sends both `message` and `app_mention` events for the same @mention ## Problem When a user @mentions the bot in a Slack thread (e.g. `@SupportEngineer, please create a PR with a code fix`), Slack sends an `app_mention` event. The bot only had an `app.message()` handler registered and completely ignored `app_mention` events, so the message was never delivered to the agent. ## Root Cause The Slack bot in `packages/slack/src/index.ts` only registered `app.message()` which handles regular channel messages. The `app_mentions:read` OAuth scope was listed in the README as required, but no `app.event('app_mention', ...)` handler existed in the code. ## Changes | File | Change | |------|--------| | `packages/slack/src/index.ts` | Add `app.event('app_mention')` handler, extract `processMessage()`, use dedup | | `packages/slack/src/dedup.ts` | New module: timestamp-based deduplication with configurable TTL | | `packages/slack/test/dedup.test.ts` | 6 tests for dedup logic including TTL expiry and Slack event simulation | | `packages/slack/tsconfig.json` | Exclude test dir from typecheck (bun:test types) | | `plan.md` | Task tracking | Closes #13251
yindo added the pull-request label 2026-02-16 18:19:22 -05:00
yindo closed this issue 2026-02-16 18:19:22 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#14581