Skip to content

fix(slack): resolve user mentions to display names#1409

Merged
saddlepaddle merged 1 commit into
mainfrom
slack-cant-see-mentions
Feb 12, 2026
Merged

fix(slack): resolve user mentions to display names#1409
saddlepaddle merged 1 commit into
mainfrom
slack-cant-see-mentions

Conversation

@saddlepaddle
Copy link
Copy Markdown
Collaborator

@saddlepaddle saddlepaddle commented Feb 12, 2026

Summary

  • The Slack agent was receiving raw user IDs (<@U0A4BLQB04B>) instead of human-readable names, so it couldn't identify who was being mentioned in threads or messages
  • Added resolveUserMentions() helper that collects unique <@U...> IDs and resolves them in parallel via slack.users.info()
  • Applied to all three places mentions appear: the prompt itself, thread context, and channel history

Test plan

  • Mention a user in a Slack thread with @Superset and verify the agent identifies them by name
  • Verify thread context shows resolved names (e.g. @John Smith: message) instead of raw IDs
  • Verify channel history tool returns resolved names
  • Test with an unresolvable user ID (e.g. deactivated user) — should fall back to raw ID gracefully

Summary by CodeRabbit

  • New Features
    • Slack integration now resolves user mentions before processing messages, displaying actual usernames instead of user IDs for improved clarity and agent processing.

The Slack agent received raw user IDs (<@U0A4BLQB04B>) instead of
human-readable names, making it unable to identify who was being
mentioned. Resolves mentions via parallel users.info calls in thread
context, channel history, and the prompt itself.
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Feb 12, 2026

📝 Walkthrough

Walkthrough

The changes introduce a new mention-resolution mechanism in the Slack integration. A new resolveUserMentions function is added to extract and resolve Slack user IDs from mention patterns, mapping them to usernames. This resolver is invoked before delegating to the Slack agent and is also integrated into thread context and channel history retrieval flows.

Changes

Cohort / File(s) Summary
Mention Resolution Implementation
apps/api/src/app/api/integrations/slack/events/utils/run-agent/run-agent.ts
Added new resolveUserMentions function that extracts <@U...> mention patterns, resolves user IDs via Slack's users.info API, and returns a replacer function. Integrated this resolver into fetchThreadContext and handleGetChannelHistory to replace user IDs with resolved usernames in both author and text fields.
Export Updates
apps/api/src/app/api/integrations/slack/events/utils/run-agent/index.ts
Updated public exports to include the new resolveUserMentions function alongside existing formatErrorForSlack and runSlackAgent exports.
Integration into Process Flow
apps/api/src/app/api/integrations/slack/events/process-mention/process-mention.ts
Modified to invoke resolveUserMentions before passing text to runSlackAgent, ensuring mention resolution occurs upstream in the processing pipeline.

Sequence Diagram(s)

sequenceDiagram
    participant PM as process-mention
    participant RAM as resolveUserMentions
    participant SA as Slack API
    participant RAN as runSlackAgent

    PM->>RAM: Call with event.text
    RAM->>RAM: Extract <@U...> patterns
    RAM->>SA: Call users.info for each user ID
    SA-->>RAM: Return user details
    RAM->>RAM: Build ID→username mapping
    RAM->>RAM: Create replacer function
    RAM-->>PM: Return replacer function
    PM->>PM: Apply replacer to text
    PM->>RAN: Pass resolved text
    RAN-->>PM: Process with agent
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Possibly related PRs

Poem

🐰 Mentions resolved with a hop and a bound,
User IDs transformed, no more lost and unfound,
Slack speaks in names now, clear as can be,
The agent hops forward with clarity! 🌟

🚥 Pre-merge checks | ✅ 1 | ❌ 2
❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description provides a clear summary and test plan but does not follow the required template structure with sections like 'Related Issues', 'Type of Change', 'Testing', etc. Restructure the description to match the repository template: add 'Related Issues' section, select appropriate 'Type of Change' (Bug fix), expand 'Testing' section with detailed test steps, and organize content into the required sections.
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The PR title clearly summarizes the main change: adding user mention resolution to display names in Slack integration, which directly reflects the primary objective of the changeset.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch slack-cant-see-mentions

No actionable comments were generated in the recent review. 🎉


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Feb 12, 2026

🧹 Preview Cleanup Complete

The following preview resources have been cleaned up:

  • ✅ Neon database branch
  • ✅ Electric Fly.io app
  • ✅ Streams Fly.io app

Thank you for your contribution! 🎉

@saddlepaddle saddlepaddle merged commit 08516a5 into main Feb 12, 2026
15 checks passed
@Kitenite Kitenite deleted the slack-cant-see-mentions branch February 12, 2026 04:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant