Skip to content

feat: mention mapped GitHub users in Wire - #184

Open
netbe wants to merge 2 commits into
mainfrom
codex/github-user-mentions
Open

netbe wants to merge 2 commits into
mainfrom
codex/github-user-mentions

Conversation

@netbe

@netbe netbe commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

GitHub notifications can now mention the corresponding Wire users. /github map <github-login> @Wire user registers a persistent, conversation-specific mapping using Wire's mention picker.

  • PR review requests mention the mapped requested reviewer.
  • PR reviews, inline comments, and issue/PR conversation comments resolve exact, case-sensitive @github-login tags in their bodies, excluding the reviewer/comment author.
  • Issue notifications resolve tags in the rendered title/body, excluding the issue author. Custom Actions messages resolve tags in their text.
  • Other notifications remain unchanged; unmapped tags stay plain text.

Build configuration now resolves plugin dependencies directly from Maven Central, avoiding missing transitive dependencies through the Plugin Portal.

Validation: the full local build and all 64 tests passed, including mapping storage, author exclusions, template offsets, and webhook/Actions delivery. ktlintCheck, detekt, and git diff --check passed. Live Wire delivery has not been tested.

@netbe
netbe requested a review from a team as a code owner December 2, 2026 15:13
@claude

claude Bot commented Dec 2, 2026

Copy link
Copy Markdown

Review: mention mapped GitHub users in Wire

Overall this is a solid feature. Using UUID placeholders in TemplateHandler.mentionRanges to find where user-written fields land in the rendered message is a good approach. It handles text in headers that happens to match the body, Mustache escaping of non-marked fields, and emoji (UTF-16) offsets without needing per-template offset tables. The tests cover the tricky parts well (partial names, emails, URL paths, author exclusion, emoji offsets). Some notes below.

Potential bugs / behavioural issues

  1. Review-request lookup is case-sensitive, but GitHub logins are not. (AuthorMentions.kt reviewRequestMentions → RedisService.getAuthorMapping)
    hget(key, login) uses the exact requested_reviewer.login from the payload, which GitHub always sends in its canonical capitalization (e.g. Octocat). If someone runs /github map octocat @User, the reviewer is never mentioned, and the bot gives no hint why. The same mismatch means octocat and Octocat can end up as two separate hash entries that point to different Wire users. Some options:

    • store the field under login.lowercase() and keep the display form only for the confirmation message, or
    • at least do a case-insensitive lookup for the review-request path (one hgetall plus entries.firstOrNull { it.key.equals(login, true) }).
      For explicit @tags in bodies, exact case matching is documented and defensible. For the reviewer path, which is driven by GitHub's own payload, it is more likely to surprise users.
  2. Trailing whitespace makes /github map fail. MAPPING_COMMAND captures the target with (.+), and the mention must cover the whole capture (it.length == target.value.length). If a Wire client leaves a trailing space after the mention picker inserts the name (some clients do), the user gets the usage error even though they did everything right. Consider trimming the command first, or requiring only mention.offset == target.range.first && mention.offset + mention.length == command.trimEnd().length.

  3. Mentions inside code spans and blocks. A body like Run `@octocat` locally, or a fenced block that contains @octocat, still produces a native mention. This is minor, but you may want to note it in the README or skip backtick-delimited ranges.

Security

  • Any participant can overwrite a mapping (this is documented). Also note that selectedUser.userId comes from the client-supplied mention. A modified client could map a login to a Wire user who isn't in the conversation. The impact is low, because the mention would only be noise in this conversation, but it's worth knowing.
  • Mapping data is never cleaned up. There is no unmap or list command, and nothing deletes …:authors when the app leaves a conversation. That isn't a security issue, but users currently have no way to see or remove a wrong mapping. A /github map list or /github unmap <login> would round this out, either here or in a follow-up.

Code quality

  • repositoryMentions uses else -> return reviewRequestMentions(...) inside the val author = when expression. It works, but routing the pull_request case through the "author" when is a bit hidden. A top-level when (event) that dispatches to the review-request path and the body-tag path separately would be easier to follow.
  • mentionRanges lives in TemplateHandler but has to know which fields of which events are user-authored, and repositoryMentions repeats the same event list for authors. Consider keeping both event→field tables in one place (for example both in AuthorMentions.kt) so a new event can't be added to one and forgotten in the other.
  • title = mark(it.title)!!: if Issue.title is non-null, a small markRequired(value: String): String overload would avoid the !!.
  • registerMapping splits the command and then also runs MAPPING_COMMAND.matchEntire. Since the regex already anchors /github map, the split pre-check is only there to tell "not my command" apart from "malformed map". That's fine, but a short comment would help.
  • The help text says map a PR reviewer, but the feature now covers comment, review, issue and Actions tags as well. Something like "map a GitHub login to a Wire user for mentions" would be more accurate.
  • @Suppress("TooManyFunctions") on RedisService is acceptable. Alternatively, a small AuthorMappingRepository would keep the class focused and avoid the suppression.

Performance

  • For issues, issue_comment and review events, the template is now rendered twice (once normally, once with markers), and getAuthorMappings does an HGETALL per delivery. Mustache templates are cached by DefaultMustacheFactory and hashes per conversation are small, so this is negligible. One cheap win: call getAuthorMappings before mentionRanges and skip the second render when there are no mappings (the common case).
  • The regex is rebuilt from all mapped logins on every message. That's fine at this scale.

Tests

Coverage is good. A few gaps worth filling:

  • A review request where the stored mapping's case differs from the payload login (this documents the behaviour in point 1, whichever way you decide).
  • /github map with trailing whitespace, and with a valid login plus a correctly placed mention but extra text after it.
  • An issue_comment where the body is identical to the issue title. The title is rendered twice in that template, so this checks that only the body range is used.
  • A webhook-level (ApplicationTest) test for a comment or issue event with a mapping, to cover the repositoryMentions wiring in Routing.kt end to end. Today only the review-request path is covered there.
  • The PR description says live Wire delivery hasn't been tested. Please verify on at least one client that UTF-16 offsets render correctly with emoji before the mention (the 🚀 cases).

Nice work overall. The main item I'd address before merging is the case-sensitivity on the review-request path.

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