Skip to content

fix(desktop): resolve overlapping mention recipients by span - #2939

Open
yinkev wants to merge 2 commits into
block:mainfrom
yinkev:fix/mention-longest-match
Open

fix(desktop): resolve overlapping mention recipients by span#2939
yinkev wants to merge 2 commits into
block:mainfrom
yinkev:fix/mention-longest-match

Conversation

@yinkev

@yinkev yinkev commented Jul 26, 2026

Copy link
Copy Markdown

Summary

  • resolve outgoing mentions by their concrete text spans instead of independently accepting every candidate whose name is a prefix of the visible mention
  • preserve an explicit autocomplete selection when its display name occurs once; when later edits create multiple occurrences, stop treating that name-only record as a global preference
  • for pasted/manual ambiguous text, choose the longest exact display name within each overlapping span
  • keep separate intentional short-name and long-name mentions independent, so both identities are emitted only when both spans are actually present
  • move recipient extraction into a focused helper, keeping useMentions.ts below the repository's file-size limit

Before this change, @OriginalName copy matched both OriginalName and OriginalName copy, so Desktop emitted two p tags and could start two distinct managed agents even though the composer visibly named only the copy.

Related issue

Fixes #2909

No competing implementation was found before opening this PR. Related historical mention work addresses autocomplete or other routing mechanisms, not outgoing overlapping-span tag extraction.

Testing

  • focused mention and outgoing-recipient regressions — 35 passed
  • pnpm typecheck
  • full Desktop test suite — passed
  • pnpm build
  • Biome format/check on all changed files
  • git diff --check

The unrelated runtime file-size ratchet was subsequently restored upstream by the runtime.rs module split. After extracting the new recipient helper, useMentions.ts remains below its 1,000-line limit.

@yinkev

yinkev commented Jul 26, 2026

Copy link
Copy Markdown
Author

@codex review

@yinkev
yinkev force-pushed the fix/mention-longest-match branch from 709ebbd to 97f3c3a Compare July 26, 2026 09:17

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 97f3c3a2c5

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread desktop/src/features/messages/lib/outgoingMentionResolution.ts
Signed-off-by: Kevin Yin <182213728+yinkev@users.noreply.github.com>
@yinkev
yinkev force-pushed the fix/mention-longest-match branch from 97f3c3a to cc3fe80 Compare July 26, 2026 09:39
@yinkev

yinkev commented Jul 26, 2026

Copy link
Copy Markdown
Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: cc3fe80bae

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread desktop/src/features/messages/lib/outgoingMentionResolution.ts Outdated
Signed-off-by: Kevin Yin <182213728+yinkev@users.noreply.github.com>
@yinkev
yinkev force-pushed the fix/mention-longest-match branch from 00a1665 to 3a0ee69 Compare July 27, 2026 23:40
@yinkev
yinkev marked this pull request as ready for review July 27, 2026 23:40
@yinkev
yinkev requested a review from a team as a code owner July 27, 2026 23:40
@cameronhotchkies cameronhotchkies added the triage-ready Appropriate for agentic review label Jul 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

triage-ready Appropriate for agentic review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Mentioning a longer display name also tags its shorter prefix

2 participants