Repository navigation
Commit cae3922
fix(mentions): keep @mentions tagged when punctuation or quotes follow the name (#2713)
## Summary
Typing `@SomeAgent's`, `@SomeAgent"` or `@SomeAgent,` sent the message
without a `p` tag, so the agent was never woken and nothing warned the
user. Two independent composer causes were responsible; both are fixed
here.
1. **Only Space selected a fully typed name.** Every other key,
including closing punctuation, was typed into the search text.
`SomeAgent,` matched no one, so nothing was tagged.
2. **Quotes weren't in the boundary allowlist.** After a mention was
picked from the list, `mentionBoundary` accepted `, . ! ? : ; )` as the
character following a name but not `'` `’` `"` `”`, so a quote right
after a chip turned it back into plain text and dropped the recipient.
Nothing on the relay or Rust side reads `@names` from text; agents wake
only on `p` tags, so both fixes are in the frontend composer.
## Changes
- **Where a name ends** (`mention-draft.ts`): a mention now ends at the
first character that isn't a letter, combining mark, digit or `_`,
matching how the timeline renders mentions. The check runs on every
edit, so it also covers macOS smart-quote substitution. `codePointAt`
avoids treating half a surrogate pair as a boundary.
- **Closing punctuation selects** (`ComposerCompletions.tsx`,
`MentionCompletion.tsx`, `MessageComposer.tsx`, `EditableInput.tsx`,
`composer-dom.ts`): `, . ! ? ; : )` and `' ’ " ”` typed straight after
an exact, unique name select it the way Space does, and the character
stays after the mention (`@Name,` rather than `@Name ,`). They also hold
a pending mention while names are still loading.
- **Same guards as Space:** a longer known name that continues the query
(`Pat O` while `Pat O'Brien` is known; `Wes` while `Wes Smith` is known)
blocks every one of these keys; team and evidence rules that block Space
block them too; Ctrl/Cmd stay shortcuts; the typed key stays literal
inside code spans. Option/Alt is allowed only for mentions so Mac curly
quotes work, and emoji completion is unchanged from `main`.
- **Docs:** mentions README §5 now says closing punctuation SHOULD
select under the same rule as Space (no contract version bump; §5
changes haven't bumped it before, and no fixture covers which key
commits). Pointer sentences in `docs/agents.md`,
`docs/plugin-architecture.md` and `docs/buzz-help.md`.
## Before / after
Left: `main` (`fe3dd19`). Right: this branch. The same keystrokes go to
both panes in lockstep. Each pane shows a chip badge under the composer
and a log of sent events with their `p`-tag count (green = agent tagged,
red = not tagged). On `main` the agent is tagged in 1 of 6 sends (only
the Space control); with the fix, 6 of 6.
https://github.com/user-attachments/assets/aa5b9043-d489-45bd-a9ab-389b13d2b894
| Step | Keys | `main` | this branch |
|---|---|---|---|
| Control | `@Other Honey`, Space, `please look` | tagged | tagged |
| Typed `'s` | `@Other Honey's turn` | **not tagged** | tagged |
| Typed `’s` | `@Other Honey` + Option+Shift+`]`, `s turn` | **not
tagged** | tagged |
| Typed `,` | `@Other Honey, please look` | **not tagged** | tagged |
| Typed `"` | `@Other Honey" said hi` | **not tagged** | tagged |
| Picked, then `'` | click the row, Backspace, `'s turn` | **not
tagged** | tagged |
Recorded in headless Chromium against
`tests/fixtures/mentions.html?identity-names`; the native app, WebKit
and IME were not recorded.
## Test plan
- [x] New regression tests for both causes (fail with the fix reverted):
`mention-draft.test.ts`, `EditableInput.test.tsx`,
`MessageComposer.test.tsx`, `src/bundled/mentions`
- [x] Longer-name guard (`Pat O` / `Pat O'Brien`, `Wes` / `Wes Smith`),
loading-race case where `'` holds a pending mention and the directory
later reports `Pat O'Brien`
- [x] Option+`:` after an emoji shortcode no longer converts (matches
`main`)
- [x] macOS smart-quote substitution after a picked chip keeps the
recipient
- [x] 1,336 tests across the composer, mention and conversation suites;
`tsc --noEmit` and Biome clean
- [x] Browser repro against the real composer passes on this branch
## Known gaps (unchanged)
- A quote before the `@` (`"@Name`) still doesn't open the mention list;
that's part of the portable mention contract (README §2 / `query`
fixtures) and needs sign-off.
- `@Wes,` still doesn't select while `Wes Smith` is known, the same as
Space.
- Keys that arrive without a normal keydown (dead-key layouts such as
US-International, IME, the character viewer) don't select a typed name.
A picked chip keeps its tag in all of these cases.
- With smart quotes on, the selecting apostrophe is inserted straight
(`'`) rather than curly; both are treated the same.
- The composer counts combining marks as part of a name; the timeline
doesn't. Follow-up: have `profileMentionParts` call `mentionBoundary`.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
---------
Signed-off-by: mtoohey <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>1 parent bb98864 commit cae3922
15 files changed
Lines changed: 411 additions & 82 deletions
File tree
- docs
- src
- bundled/mentions
- features
- conversation
- messages
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
814 | 814 | | |
815 | 815 | | |
816 | 816 | | |
817 | | - | |
818 | | - | |
| 817 | + | |
| 818 | + | |
| 819 | + | |
819 | 820 | | |
820 | 821 | | |
821 | 822 | | |
| |||
910 | 911 | | |
911 | 912 | | |
912 | 913 | | |
913 | | - | |
914 | | - | |
| 914 | + | |
| 915 | + | |
| 916 | + | |
| 917 | + | |
| 918 | + | |
915 | 919 | | |
916 | 920 | | |
917 | 921 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
249 | 249 | | |
250 | 250 | | |
251 | 251 | | |
252 | | - | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
253 | 256 | | |
254 | 257 | | |
255 | 258 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2466 | 2466 | | |
2467 | 2467 | | |
2468 | 2468 | | |
2469 | | - | |
2470 | | - | |
| 2469 | + | |
| 2470 | + | |
| 2471 | + | |
| 2472 | + | |
2471 | 2473 | | |
2472 | 2474 | | |
2473 | 2475 | | |
2474 | 2476 | | |
2475 | 2477 | | |
2476 | | - | |
| 2478 | + | |
| 2479 | + | |
| 2480 | + | |
2477 | 2481 | | |
2478 | 2482 | | |
2479 | 2483 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| 25 | + | |
25 | 26 | | |
26 | 27 | | |
27 | 28 | | |
| |||
241 | 242 | | |
242 | 243 | | |
243 | 244 | | |
| 245 | + | |
244 | 246 | | |
245 | | - | |
246 | | - | |
| 247 | + | |
| 248 | + | |
247 | 249 | | |
248 | 250 | | |
249 | 251 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
20 | | - | |
21 | | - | |
22 | | - | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
23 | 23 | | |
24 | 24 | | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
| |||
197 | 197 | | |
198 | 198 | | |
199 | 199 | | |
200 | | - | |
| 200 | + | |
201 | 201 | | |
202 | 202 | | |
203 | 203 | | |
| |||
245 | 245 | | |
246 | 246 | | |
247 | 247 | | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
248 | 261 | | |
249 | 262 | | |
250 | 263 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
804 | 804 | | |
805 | 805 | | |
806 | 806 | | |
807 | | - | |
| 807 | + | |
| 808 | + | |
808 | 809 | | |
809 | 810 | | |
810 | 811 | | |
| |||
3480 | 3481 | | |
3481 | 3482 | | |
3482 | 3483 | | |
| 3484 | + | |
| 3485 | + | |
| 3486 | + | |
| 3487 | + | |
| 3488 | + | |
3483 | 3489 | | |
3484 | 3490 | | |
3485 | 3491 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
6 | 9 | | |
7 | 10 | | |
8 | 11 | | |
| |||
285 | 288 | | |
286 | 289 | | |
287 | 290 | | |
288 | | - | |
289 | | - | |
290 | | - | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
291 | 296 | | |
292 | 297 | | |
293 | 298 | | |
| |||
400 | 405 | | |
401 | 406 | | |
402 | 407 | | |
403 | | - | |
| 408 | + | |
404 | 409 | | |
405 | 410 | | |
406 | 411 | | |
| |||
437 | 442 | | |
438 | 443 | | |
439 | 444 | | |
440 | | - | |
441 | | - | |
442 | | - | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
443 | 456 | | |
444 | 457 | | |
445 | 458 | | |
| |||
458 | 471 | | |
459 | 472 | | |
460 | 473 | | |
461 | | - | |
| 474 | + | |
462 | 475 | | |
463 | 476 | | |
464 | 477 | | |
465 | 478 | | |
466 | | - | |
| 479 | + | |
467 | 480 | | |
468 | 481 | | |
469 | 482 | | |
| |||
476 | 489 | | |
477 | 490 | | |
478 | 491 | | |
479 | | - | |
| 492 | + | |
480 | 493 | | |
481 | 494 | | |
482 | 495 | | |
483 | 496 | | |
484 | 497 | | |
485 | 498 | | |
486 | | - | |
| 499 | + | |
487 | 500 | | |
488 | 501 | | |
489 | 502 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3624 | 3624 | | |
3625 | 3625 | | |
3626 | 3626 | | |
3627 | | - | |
3628 | | - | |
3629 | | - | |
3630 | | - | |
3631 | | - | |
3632 | | - | |
3633 | | - | |
3634 | | - | |
| 3627 | + | |
| 3628 | + | |
| 3629 | + | |
| 3630 | + | |
| 3631 | + | |
| 3632 | + | |
| 3633 | + | |
| 3634 | + | |
| 3635 | + | |
| 3636 | + | |
| 3637 | + | |
| 3638 | + | |
| 3639 | + | |
| 3640 | + | |
| 3641 | + | |
| 3642 | + | |
| 3643 | + | |
| 3644 | + | |
| 3645 | + | |
| 3646 | + | |
| 3647 | + | |
| 3648 | + | |
| 3649 | + | |
| 3650 | + | |
| 3651 | + | |
| 3652 | + | |
| 3653 | + | |
| 3654 | + | |
| 3655 | + | |
| 3656 | + | |
| 3657 | + | |
| 3658 | + | |
| 3659 | + | |
| 3660 | + | |
3635 | 3661 | | |
3636 | 3662 | | |
3637 | 3663 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
747 | 747 | | |
748 | 748 | | |
749 | 749 | | |
750 | | - | |
| 750 | + | |
751 | 751 | | |
752 | 752 | | |
753 | 753 | | |
754 | 754 | | |
| 755 | + | |
| 756 | + | |
| 757 | + | |
| 758 | + | |
755 | 759 | | |
756 | 760 | | |
757 | 761 | | |
758 | 762 | | |
759 | | - | |
760 | 763 | | |
761 | 764 | | |
762 | 765 | | |
| |||
811 | 814 | | |
812 | 815 | | |
813 | 816 | | |
814 | | - | |
| 817 | + | |
815 | 818 | | |
816 | 819 | | |
817 | 820 | | |
| |||
985 | 988 | | |
986 | 989 | | |
987 | 990 | | |
988 | | - | |
| 991 | + | |
| 992 | + | |
989 | 993 | | |
990 | 994 | | |
991 | 995 | | |
| 996 | + | |
992 | 997 | | |
993 | 998 | | |
994 | 999 | | |
| |||
1015 | 1020 | | |
1016 | 1021 | | |
1017 | 1022 | | |
1018 | | - | |
| 1023 | + | |
1019 | 1024 | | |
1020 | 1025 | | |
1021 | 1026 | | |
| |||
0 commit comments