fix(desktop): resolve overlapping mention recipients by span#2939
fix(desktop): resolve overlapping mention recipients by span#2939yinkev wants to merge 1 commit into
Conversation
|
@codex review |
709ebbd to
97f3c3a
Compare
There was a problem hiding this comment.
💡 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".
| candidate.displayName ? [candidate.displayName] : [], | ||
| ), | ||
| ], | ||
| selectedNames, |
There was a problem hiding this comment.
Scope selected-name preference to its original span
Passing every autocomplete-selected name as a global preference applies that preference to all matching spans, not only the selected occurrence. For example, after selecting @OriginalName and then manually pasting @OriginalName copy later in the same message, resolving @OriginalName then @OriginalName copy with the short name selected returns only OriginalName; the short prefix wins at both spans and the intended longer recipient is omitted. Preserve selection metadata per occurrence, or restrict preference so an earlier selected short mention cannot override an independent longer span.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in the current head. A name-only autocomplete record is now preferred only while that display name has one occurrence in the current text. If later edits create another occurrence, each span returns to longest-match resolution, so an earlier selected short mention cannot suppress a later independent longer mention. Added the exact selected-short + pasted-long regression; all 35 focused mention tests pass.
Signed-off-by: Kevin Yin <182213728+yinkev@users.noreply.github.com>
97f3c3a to
cc3fe80
Compare
|
@codex review |
There was a problem hiding this comment.
💡 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".
| const displayNames = [...selectedPersonaMentions.keys()]; | ||
| const resolvedDisplayNames = new Set( | ||
| resolveMentionedNames(text, displayNames, displayNames).map((name) => | ||
| name.toLowerCase(), | ||
| ), |
There was a problem hiding this comment.
Resolve persona spans against competing pubkey mentions
When a shorter persona and a longer pubkey identity have both been selected, then the shorter mention is deleted so only the longer text remains (for example, persona OriginalName followed by managed agent OriginalName copy), this resolver considers only persona names and still interprets the prefix as the persona mention. createMentionedPersonaAgents consequently provisions the unintended persona, while the pubkey resolver—whose candidate set includes both names—correctly chooses only the longer identity. Resolve personas using the same competing selected/candidate names so both extraction paths agree on the visible span.
Useful? React with 👍 / 👎.
Summary
useMentions.tsbelow the repository's file-size limitBefore this change,
@OriginalName copymatched bothOriginalNameandOriginalName copy, so Desktop emitted twoptags 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
pnpm typecheckpnpm buildgit diff --checkThe repository-wide
just cifrontend file-size step still reports the existing untoucheddesktop/src-tauri/src/managed_agents/runtime.rsupstream violation. PR #2930 restores that ratchet without changing runtime behavior and has a fully successful GitHub CI run. After extracting the new recipient helper,useMentions.tsremains below its 1,000-line limit.