mirror of
https://github.com/block/buzz.git
synced 2026-11-24 18:21:59 +00:00
Follow-up to [#9699 mention typing](https://github.com/block/buzz/pull/9699), fixing two identity problems found in its review. **Identity-link pills name the key they open.** An edit writes each mention as an identity link, `[@Name](nostr:npub1…)`, and every message from any client draws such a link as a pill. Mobile showed the label written in the link, so `[@Wes](nostr:<mallory>)` drew an ordinary `@Wes` pill that opened Mallory's profile, and two namesakes in an edited message both read `Scout`. The pill now shows the name its key resolves to in the channel (with the namesake qualifier and agent icon), as buzz-app's `ProfileMention` already does. The written label shows only when the key has no name on this device (no profile, directory or roster name), never a compact npub in its place. This holds whether or not the link's key is also tagged. A pill requests its key's profile when uncached, so a written label gives way to the key's name once it loads. Edits carry no `p` tag, so an identity-link pill resolves its own key. In channel, thread and forum rows the pill watches that one key's channel label (with the namesake qualifier and agent icon) and requests the key's profile when it builds, so only links that actually draw a pill cost a lookup, whatever Markdown surrounds them. Inbox and search previews draw identity links the same way, taking keys from the preview pieces they render. These keys never feed the text bindings, so plain `@Name` text still binds only through signed tags. **Typed names group the way the text scan reads them.** The composer grouped the roster by `toLowerCase` while the scan folds names with `foldMentionLabel`. With members `Sam` and `ſam`, typing `@ſam` sent Sam's `p` tag. Grouping, lookup and the send-time key qualifier now all fold, so namesakes under folding fail as ambiguous, as other namesakes already do. **Linked lookups stay current and bounded.** Pills and preview rows request their keys through the profile cache's revalidation path. A name restored from the last launch is revalidated, so a renamed key's link shows its current name. A lookup that fails while offline is retried once the relay reconnects, including when the reconnect comes while that lookup is still on the wire. A key the relay says has no profile is not asked for again for five minutes, and the cache remembers at most 1,000 such keys per community. Previews keep tilde and quoted code fences literal and read blockquotes as the full message does, and load only the links on lines they draw. Editing a message folds historical names the way the scan does, so a name two tagged people share under folding seeds no chip. Rendering binds signed names by the same fold, so with signed `Sam` and `ſam` a plain `@Sam` stays text instead of drawing Sam's pill. Desktop (buzz-app) already names identity-link chips from the key and needs no change. ### Validation Rows add no per-message work: message bodies are no longer scanned for links. Each drawn identity-link pill adds one label watch for its own key. Added tests: - [Channel page journey step](mobile/test/features/channels/channel_detail_page_test.dart): an edited message linking `[@Wes]` to Mallory's key draws `Mallory`, and two edited `Scout` namesakes draw distinct qualified labels, through the real channel row. - [Channel page journey step](mobile/test/features/channels/channel_detail_page_test.dart): a link to a key with no name here keeps its written label. - [Preview identity link](mobile/test/features/channels/message_content/preview_text_test.dart): an inbox/search preview shows the key's resolved name, or the written label when unknown. - [Preview keys](mobile/test/features/channels/message_content/preview_text_test.dart): a preview loads only links it draws (not ones in code or past its line limit), including labels with brackets. Full-app run (iOS simulator, debug build, signed in to a test community): posted a message with a spoofed identity link, a link to a key with no profile here, and a link inside inline code. The spoofed link drew the key's real name as a pill and opened that person's profile; the unknown key kept its written label; the code span stayed raw. The same message drew matching pills in search results and in the thread view. - [Channel row loads](mobile/test/features/channels/channel_detail_page_test.dart): a row requests profiles only for links it draws as pills, not ones in a quoted code fence or an HTML comment. - [Folded chip qualifiers](mobile/test/features/channels/compose_bar_test/exact_mention_tests.dart): picked `@Sam` and `@ſam` chips both carry their keys on send. - [Ambiguous typed names table](mobile/test/features/channels/compose_bar_test/exact_mention_tests.dart): `Sam` and `ſam` in either roster order now refuse `@ſam` as ambiguous. - [Restart and reconnect journey](mobile/test/features/channels/channel_detail_page_test.dart): a restored old name and an offline first lookup both resolve after the relay reconnects, on the same mounted pills, and a key with no profile is not requested again. - [Preview fences](mobile/test/features/channels/message_content/preview_text_test.dart): tilde and quoted fences keep links and Markdown literal and load no keys. - [Overtaken lookup](mobile/test/shared/profile/user_cache_provider_test.dart): a reconnect during a link's failing lookup asks once more after it settles. - [Folded signed names](mobile/test/features/channels/message_content_exact_mentions_test.dart): signed `Sam` and `ſam` in either tag order leave `@Sam` as text in the message and its preview. - [Folded edit chips](mobile/test/features/channels/message_edit_sheet_test.dart): `Sam` and `ſam` tagged in either order open as text, with no chip. - [Non-member labels](mobile/test/shared/identity_names/identity_names_test.dart): a non-member labels the same with or without the roster shortcut, including names shaped like qualifiers. ### Regressions - **Performance:** rows do no new scanning; each drawn identity-link pill adds one label watch. A non-member whose name can't collide no longer re-resolves the whole roster. - **Mention semantics:** unchanged for tagged mentions and plain text. Only identity-link pills change, from the written label to the key's resolved name. - **Composer:** names that differ only under Unicode folding (`ſ`/`s`, `µ`/`μ`, final `ς`/`σ`) are now one name when matching typed text, so a typed one between two such members asks for a pick instead of silently choosing one. Picked chips are unaffected. --------- Signed-off-by: Tom Brow <tomb@block.xyz> Co-authored-by: studio <dc2fc481343672df31a689840c09299972e704dac592e0da6f18486646a7ee3e@buzz>