fix(slack): use replace offset for duplicate mentions, invalidate cache on user_change#236
Merged
cramforce merged 2 commits intoslack-at-mentions-from-markdownfrom Mar 13, 2026
Conversation
…he on user_change
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
cramforce
added a commit
that referenced
this pull request
Mar 13, 2026
…messages (#230) * feat(slack): resolve @DisplayName mentions to <@USER_ID> in outgoing messages Build a reverse index from display name → user IDs during lookupUser(), track thread participants on incoming messages, and resolve @name mentions to Slack's <@USER_ID> format before sending. Disambiguates using thread participants when multiple users share a display name. Also increases user/channel cache TTLs to 8 days. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix(slack): use replace offset for duplicate mentions, invalidate cache on user_change * Revert "fix(slack): use replace offset for duplicate mentions, invalidate cache on user_change" This reverts commit 8cb0d90. * fix(slack): use replace offset for duplicate mentions, invalidate cache on user_change (#236) * fix(slack): use replace offset for duplicate mentions, invalidate cache on user_change * style: align handleUserChange to async/await, expand changeset --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Co-authored-by: Matan Kushner <hello@matchai.dev>
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.
Fixes issues found during review of #230.
Duplicate mention bug
resolveOutgoingMentionsusedtext.indexOf(match)inside the.replace()callback, which always returns the index of the first occurrence. When the same@nameappears multiple times, every match gets its<prefix check evaluated against the first occurrence's position. Uses theoffsetparameter that.replace()already provides.Stale user cache on name changes
The user cache (
slack:user:{userId}) has an 8-day TTL. When a Slack user changes their display name, the cache serves stale data until expiry — incoming messages show the old name and the reverse index doesn't learn the new name.Subscribes to Slack's
user_changeevent and deletes the cached entry so the nextlookupUsercall hits the API and picks up the new profile. The stale reverse index entry is left to expire naturally via TTL — it's harmless since<@USER_ID>renders as the user's current display name in Slack regardless.Requires adding
user_changetobot_eventsin the Slack app manifest (users:readscope is already present).Test comment
Fixed misleading "fire-and-forget" comment — the code actually
awaits participant tracking.