Repository navigation
fix(composer): open @, # and : suggestions after CJK punctuation - #2768
cheng-block wants to merge 2 commits into
Conversation
Chinese and Japanese prose puts no space after fullwidth punctuation, so 你好,@alice, (@alice and 看看,#general are ordinary text. The mention, channel and emoji queries only opened at the start of the text or after whitespace, (, [ or {, so none of those menus opened there. The three queries now share TRIGGER_BOUNDARY from mention-query.ts, which adds the fullwidth and CJK punctuation that ends a bare link since block#2404. Letters and digits still never count, so a@host and word#tag stay text. Mention rules section 2 and its query fixtures now say the same. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Cheng Peng <cheng@block.xyz> Co-authored-by: Cursor <cursoragent@cursor.com>
… case The mention query test repeated the portable fixture's 你好,@ho, so that case now lives only in the fixture. Mention rules section 2 calls the list punctuation marks rather than fullwidth or CJK punctuation, since “”‘’… are general punctuation. The agent help guide says the @, # and : suggestions open right after CJK punctuation without a space. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Cheng Peng <cheng@block.xyz> Co-authored-by: Cursor <cursoragent@cursor.com>
|
🤖 Design review at Exact-source query diagnostics matched all 13 portable query fixtures and confirmed Evidence: shared trigger boundary, composer coverage. Fullwidth trigger characters, IME behavior and punctuation after a picked name remain outside this change. Unchecked: native app/IME, keyboard/focus and screen-reader integration, themes, widths, enlarged text and many-agent states. No attached screenshots; no app run or package test suite in this review. |
|
🤖 Could you add a screenshot or short video of the change to the PR? Design uses these for faster reviews. |
Added under Screenshots in the description. They come from the debug build I tested. |
…#2834) ## Why Edit turns a name inside literal Markdown (HTML, link titles, reference definitions) into a mention link, so saving changes text you never touched. `[ref]: https://example.com "Ask @sam"` is saved as `[ref]: https://example.com "Ask [@sam](nostr:npub1…)"`. The timeline and Copy show those names as plain text. `messageEditText` links every name `profileMentionParts` finds, and that finder skips only code, links and URLs (`src/features/messages/profile-mentions.ts:99`). The timeline drops a name that overlaps a range from `literalRanges` (`src/features/messages/markdown-preparation.ts:39`). Edit had no such check. ## What Edit now leaves a name as written when it sits inside literal Markdown, using the timeline's ranges. Names outside literal Markdown still become mention links. ## How - `messageEditText` parses the text it edits (`sourceContent`, which keeps attachment Markdown) with `scanMarkdown` and takes `literalRanges(tree, true)`. `literalRanges` is now exported. - It walks the ranges in order beside the names, like the timeline, so it checks each range once. - No second Markdown heuristic. Copy's own walk is left alone. ## Risk Low. Only the text Edit loads changes. Recipients stay the same: an edited message keeps the original event's `p` tags, so a name left as text drops no one. - Copy and the timeline read a body over 100,000 characters or 100 levels deep as plain text. Edit has no such guard, but it opens only your own messages, and Buzz sends at most 32 KiB. Another client can send more. - Known limit: the timeline repairs a pasted `[Hi @sam]\(https://example.com)` into a link and shows no mention. Edit and Copy read it as written and still link that `@Sam`, same as on `main`. - Out of scope: bare URL ends (#2777), suggestions after CJK punctuation (#2768), picked name ends (#2713), `protectedTextEnd` time on unmatched brackets. - With #2777 merged in, this also closes the Edit limit #2777 lists: `[ref]: https://example.com/a,@Sam` stays as written. ## Testing - No browser cases added or removed. The change is text only. - A one-off script compared names linked by the timeline, Copy and Edit on 55 bodies. All three agree on 54; the other is the known limit. On `main`, Edit linked more than Copy on 20. - The 8 new Edit test texts pass through the composer's load and save helpers unchanged. - `messageEditText` runs once when Edit opens (Node and jsdom, median of five runs). A body that alternates names and code spans took about 72 ms at 16,000 characters and 270 ms at 32 KiB before the in-order check. After it, 8 ms and 16 ms. ## Screenshots Debug build of this PR: Edit shows the real mention as a chip and leaves `@BeeBee` inside the span title as plain text. <img width="760" alt="Composer in Editing message mode with Hi `@BeeBee` on line one and a literal span tag with title \"`@BeeBee`\" below." src="https://github.com/user-attachments/assets/26434d42-f342-4007-a9b3-382d1627742e" /> After saving, the message keeps the real mention and the literal span exactly as written. <img width="744" alt="Edited message reading Hello with a BeeBee mention chip and the literal span tag below." src="https://github.com/user-attachments/assets/4abdf2a0-6162-482c-84ca-c90f24f445a0" /> ## In-app check Verified in the macOS app by Cheng. Build: this PR at `bcc62911e`, merged locally with my other open PRs onto `main` at `c037057a1`, run as a debug app bundle. Later commits only merge `main`. Use a test channel with a person or agent in it. The steps call them Name. 1. Type `Hi @`, pick Name, press Shift+Enter twice, then paste `<span title="@name">hi</span>` with their exact name. Send. 2. The message shows `Hi`, the mention, then `<span title="@name">hi</span>` as typed. 3. Open Edit. The second line still reads `<span title="@name">hi</span>`. On `main`, Edit put a profile link inside the quotes. 4. Change `Hi` to `Hello` and save. The message shows `Hello`, the mention, and the same `<span>` line. buzz-review-completed --------- Signed-off-by: Cheng Peng <cheng@block.xyz> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Cursor <cursoragent@cursor.com>
Why
Chinese and Japanese text puts no space after fullwidth punctuation, as in
你好,@alice. Typing@,#or:there never opened the mention, channel or emoji suggestions. All three queries opened only at the start of the text or after whitespace,(,[or{.What
The
@,#and:suggestions now also open right after fullwidth and CJK punctuation.How
mention-query.tsexports oneTRIGGER_BOUNDARYset, and all three queries use it.a@hostand12:30stay text.@#:triggers, IME composition, and a trigger right after CJK letters (谢谢@alice).Risk
Only when three composer menus open changes. The portable mention rules (README §2, new
after_fullwidth_punctuationfixture) change too, so this needs a maintainer OK.version 2, as feat(agents): add your agents to your other communities #1601 and fix(mentions): resolve fast-typed @name mentions with a pending chip #1623 did.#nametyped by hand after CJK punctuation still shows as plain text. Picked channels are links.(#ge)the menu can stay open onge), since fullwidth closing brackets count as query text.https://x.com,@Honey), a picked mention shows as plain text and a community emoji loses itsemojitag, as onmain. fix(emoji): show custom emoji after a link that ends at CJK punctuation #2772 fixes the emoji part. The mention display needs its own PR.,still drops the mention.@opens after“but not after ASCII"or', which fix(mentions): keep @mentions tagged when punctuation or quotes follow the name #2713 lists as open.Testing
No manual testing beyond the in-app check.
Screenshots
Debug build of this PR: typing #cheng right after a Chinese comma opens the channel suggestions.
Debug build of this PR: typing :smi right after a Chinese comma opens the emoji suggestions.
In-app check
Verified in the macOS app by Cheng.
Build: this PR at
5602a2241, merged locally with my other open PRs ontomainatc037057a1, run as a debug app bundle (BUZZ_DEV_VIEWER= just desktop-bundle).Use a test channel with a running agent, since it replies only to a real mention. Type
@,#and:in English input.你好,@and the start of your agent's name. Suggestions open. Press Enter.,, and the agent replies.看看,#and a channel name start. Pick one and send. The link opens that channel.好的,:smi. Emoji suggestions open.(@,「@,。@,!#and」:smeach open their menu.email@host,word#tag,12:30and谢谢@open nothing, as before.buzz-review-completed