diff --git a/desktop/package.json b/desktop/package.json index 0d3ed766732..afe91beb95d 100644 --- a/desktop/package.json +++ b/desktop/package.json @@ -67,7 +67,7 @@ "embla-carousel-react": "^8.6.0", "emoji-mart": "^5.6.0", "jdenticon": "^3.3.0", - "linkifyjs": "^4.3.2", + "linkifyjs": "^4.3.3", "lucide-react": "^1.0.0", "mdast-util-from-markdown": "^2.0.3", "motion": "^12.38.0", diff --git a/desktop/src/features/agents/ui/RespondToField.tsx b/desktop/src/features/agents/ui/RespondToField.tsx index d910bfc8a6f..1e9722ecb64 100644 --- a/desktop/src/features/agents/ui/RespondToField.tsx +++ b/desktop/src/features/agents/ui/RespondToField.tsx @@ -126,7 +126,10 @@ export function CreateAgentRespondToField({ ); const userSearchQuery = useUserSearchQuery(deferredQuery, { enabled: mode === "allowlist" && deferredQuery.length > 0, - limit: 8, + // Same page size as the channel member picker: the relay ranks profile + // hits against the whole kind:0 blob, so a tight page can push an exact + // display-name match off it before the client re-ranks. + limit: 25, }); const isArchivedDiscovery = useIsArchivedPredicate(); const searchResults = React.useMemo( @@ -324,12 +327,16 @@ function AllowlistPicker({ }) { const isPersona = variant === "persona"; - // Detect if the query is a pubkey (npub or hex) not already in the list; - // direct entry offers the canonical hex for storage. + // A pasted npub or hex key can always be added directly, whatever the + // profile search returns — people without a searchable kind:0 profile are + // otherwise unreachable. Direct entry stores the canonical hex. const queryPubkey = parseCanonicalPubkey(deferredQuery); - const queryIsDirectPubkey = + const directPubkey = queryPubkey !== null && - !allowlist.some((p) => p.toLowerCase() === queryPubkey); + !allowlist.some((p) => p.toLowerCase() === queryPubkey) && + !searchResults.some((user) => user.pubkey.toLowerCase() === queryPubkey) + ? queryPubkey + : null; return (
Searching… @@ -436,31 +471,7 @@ function AllowlistPicker({ ))}
No matching users.
diff --git a/desktop/src/features/channels/openChannelDirectoryResolver.test.mjs b/desktop/src/features/channels/openChannelDirectoryResolver.test.mjs index e54873308c4..b70330152ae 100644 --- a/desktop/src/features/channels/openChannelDirectoryResolver.test.mjs +++ b/desktop/src/features/channels/openChannelDirectoryResolver.test.mjs @@ -19,6 +19,13 @@ Object.assign(globalThis, { IS_REACT_ACT_ENVIRONMENT: true, MutationObserver: dom.window.MutationObserver, document: dom.window.document, + // Under NODE_ENV=test TanStack Router treats a document-bearing process as a + // client and sets up scroll restoration through bare `history`, + // `addEventListener` and `scrollTo`; jsdom only puts them on window. + addEventListener: dom.window.addEventListener.bind(dom.window), + history: dom.window.history, + removeEventListener: dom.window.removeEventListener.bind(dom.window), + scrollTo: () => {}, localStorage: dom.window.localStorage, self: dom.window, window: dom.window, diff --git a/desktop/src/features/guest-access/ui/requesterLine.test.mjs b/desktop/src/features/guest-access/ui/requesterLine.test.mjs index bdb226690be..337fed32773 100644 --- a/desktop/src/features/guest-access/ui/requesterLine.test.mjs +++ b/desktop/src/features/guest-access/ui/requesterLine.test.mjs @@ -98,7 +98,9 @@ test("an older route's requester renders the name and link state only", () => { ); assert.match(html, /Jess/); assert.match(html, /Not linked/); - assert.doesNotMatch(html, /TEST|request|linked \d/); + // Visible text only: the wrapper's data-testid itself contains "request". + const text = html.replace(/<[^>]+>/g, " "); + assert.doesNotMatch(text, /TEST|request|linked \d/); }); test("with nothing requested, nothing is pre-ticked and each source says what it exposes", () => { diff --git a/desktop/src/features/home/ui/inboxReopenNavigation.test.mjs b/desktop/src/features/home/ui/inboxReopenNavigation.test.mjs index ad350f7a5c5..76b4d081671 100644 --- a/desktop/src/features/home/ui/inboxReopenNavigation.test.mjs +++ b/desktop/src/features/home/ui/inboxReopenNavigation.test.mjs @@ -94,6 +94,13 @@ Object.assign(globalThis, { MutationObserver: dom.window.MutationObserver, ResizeObserver: NoopObserver, document: dom.window.document, + // Under NODE_ENV=test TanStack Router treats a document-bearing process as a + // client and sets up scroll restoration through bare `history`, + // `addEventListener` and `scrollTo`; jsdom only puts them on window. + addEventListener: dom.window.addEventListener.bind(dom.window), + history: dom.window.history, + removeEventListener: dom.window.removeEventListener.bind(dom.window), + scrollTo: () => {}, localStorage: dom.window.localStorage, self: dom.window, window: dom.window, diff --git a/desktop/src/features/projects/ui/useRetainedProjectGitViews.test.mjs b/desktop/src/features/projects/ui/useRetainedProjectGitViews.test.mjs index 2e111369cc9..baef941b323 100644 --- a/desktop/src/features/projects/ui/useRetainedProjectGitViews.test.mjs +++ b/desktop/src/features/projects/ui/useRetainedProjectGitViews.test.mjs @@ -169,6 +169,13 @@ Object.assign(globalThis, { MutationObserver: dom.window.MutationObserver, ResizeObserver: NoopObserver, document: dom.window.document, + // Under NODE_ENV=test TanStack Router treats a document-bearing process as a + // client and sets up scroll restoration through bare `history`, + // `addEventListener` and `scrollTo`; jsdom only puts them on window. + addEventListener: dom.window.addEventListener.bind(dom.window), + history: dom.window.history, + removeEventListener: dom.window.removeEventListener.bind(dom.window), + scrollTo: () => {}, getComputedStyle: (...args) => dom.window.getComputedStyle(...args), localStorage: dom.window.localStorage, self: dom.window, diff --git a/docs/kiingo-fork-inventory.json b/docs/kiingo-fork-inventory.json index 9eeac7c3f0f..04991c8f531 100644 --- a/docs/kiingo-fork-inventory.json +++ b/docs/kiingo-fork-inventory.json @@ -2101,6 +2101,21 @@ "purpose": "Preserve a member's removal from a huddle across audio reconnect and parent-channel auto-admission (M-4581). Audio admission refuses an externally removed or unknown-provenance membership (using channel_members.removed_by), rechecked under the membership lock for every join commit; explicit re-invitation and voluntary leave and rejoin still work. The desktop treats the relay's terminal removal or ended frame as leave instead of reconnecting. Also touches crates/buzz-db/src/store/channel_members.rs, crates/buzz-relay/src/audio/handler.rs and desktop/src/features/huddle/HuddleContext.tsx, which other deltas already own.", "removalCondition": "Drop when upstream audio admission honors member removal provenance and its desktop stops reconnecting after a terminal removal frame.", "upstreamStatus": "Generic, provider-neutral bug fix; not yet submitted to block/buzz." + }, + { + "id": "desktop-unit-fixes-2026-10-24", + "classification": "retain-generic", + "owner": "Buzz desktop maintainers", + "purpose": "Desktop unit-test repairs. The respond-to picker again offers a pasted npub or hex key whatever the profile search returns and asks for the member picker's page size (25); an upstream sync had dropped that fork change. Desktop resolves linkifyjs 4.3.3, the version @tiptap/extension-link uses, so Link's onCreate registers the buzz protocol on the same linkify instance the composer and bare-link code read. The router-mounting tests expose jsdom's history, addEventListener and scrollTo, which TanStack Router's scroll restoration reads as bare globals when NODE_ENV=test resolves it as a client.", + "upstreamStatus": "Generic; the picker change and the test globals are candidates for block/buzz, the linkify pin follows the fork's tiptap version.", + "removalCondition": "Drop the picker change once upstream ships equivalent direct entry; drop the linkify pin when upstream desktop and tiptap resolve one linkifyjs; drop the test globals once upstream's router tests set them.", + "paths": [ + "desktop/package.json", + "desktop/src/features/agents/ui/RespondToField.tsx", + "desktop/src/features/channels/openChannelDirectoryResolver.test.mjs", + "desktop/src/features/home/ui/inboxReopenNavigation.test.mjs", + "desktop/src/features/projects/ui/useRetainedProjectGitViews.test.mjs" + ] } ], "budgetAmendments": [ diff --git a/mobile/lib/features/channels/message_content/link_normalizer.dart b/mobile/lib/features/channels/message_content/link_normalizer.dart index e02738523c3..4aeabf4d793 100644 --- a/mobile/lib/features/channels/message_content/link_normalizer.dart +++ b/mobile/lib/features/channels/message_content/link_normalizer.dart @@ -271,25 +271,81 @@ String _normalizeProseLinks(String segment) { return _linkifyBareText(normalized); } -// Markdown links produced above (and scheme URLs left as labels). Their -// destinations never contain `)`: bare-link matches stop at it. -final _markdownLinkPattern = RegExp(r'!?\[[^\]\n]*\]\([^)\s]*\)'); - /// Links bare domains, `www.` hosts, emails and phone numbers in prose that /// is outside every Markdown link (see `bare_links.dart`). String _linkifyBareText(String segment) { final result = StringBuffer(); var offset = 0; - for (final link in _markdownLinkPattern.allMatches(segment)) { + for (final (start, end) in _markdownLinkSpans(segment)) { result - ..write(_linkifyPlain(segment.substring(offset, link.start))) - ..write(link[0]); - offset = link.end; + ..write(_linkifyPlain(segment.substring(offset, start))) + ..write(segment.substring(start, end)); + offset = end; } result.write(_linkifyPlain(segment.substring(offset))); return result.toString(); } +/// Markdown links produced above (and scheme URLs left as labels): the +/// non-overlapping, leftmost `!?[label](destination)` spans with no `]` or +/// newline in the label and no `)` or whitespace in the destination (bare-link +/// matches stop at `)`). The same spans as that regex, found in one pass: a +/// regex scan restarts at every `[` and rereads the rest of an unclosed run, +/// which is quadratic on long malformed input. +List<(int, int)> _markdownLinkSpans(String text) { + final n = text.length; + // First index at or after i holding the character that ends the label + // (`]` or a newline) or the destination (`)` or whitespace); n if none. + final labelStop = List