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 (
onQueryChange(event.target.value)} placeholder={ - isPersona ? "Search people" : "Search by name or NIP-05." + isPersona + ? "Search people or paste a public key" + : "Search by name, NIP-05, or public key." } value={query} /> @@ -402,6 +411,32 @@ function AllowlistPicker({ ) : null} {deferredQuery.length > 0 ? (
+ {directPubkey ? ( + + ) : null} {searchIsLoading ? (

Searching… @@ -436,31 +471,7 @@ function AllowlistPicker({ ))}

- ) : queryIsDirectPubkey ? ( - - ) : ( + ) : directPubkey ? null : (

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.filled(n + 1, n); + final destinationStop = List.filled(n + 1, n); + for (var i = n - 1; i >= 0; i--) { + final unit = text.codeUnitAt(i); + labelStop[i] = unit == 0x5d || unit == 0x0a ? i : labelStop[i + 1]; + destinationStop[i] = unit == 0x29 || _isRegExpWhitespace(unit) + ? i + : destinationStop[i + 1]; + } + final spans = <(int, int)>[]; + var i = 0; + while (i < n) { + final unit = text.codeUnitAt(i); + final open = unit == 0x5b + ? i + : unit == 0x21 && i + 1 < n && text.codeUnitAt(i + 1) == 0x5b + ? i + 1 + : -1; + if (open >= 0) { + final close = labelStop[open + 1]; + if (close + 1 < n && + text.codeUnitAt(close) == 0x5d && + text.codeUnitAt(close + 1) == 0x28) { + final end = destinationStop[close + 2]; + if (end < n && text.codeUnitAt(end) == 0x29) { + spans.add((i, end + 1)); + i = end + 1; + continue; + } + } + } + i++; + } + return spans; +} + +/// The code units Dart's (non-Unicode) RegExp `\s` matches. +bool _isRegExpWhitespace(int unit) => + (unit >= 0x09 && unit <= 0x0d) || + unit == 0x20 || + unit == 0xa0 || + unit == 0x1680 || + (unit >= 0x2000 && unit <= 0x200a) || + unit == 0x2028 || + unit == 0x2029 || + unit == 0x202f || + unit == 0x205f || + unit == 0x3000 || + unit == 0xfeff; + String _linkifyPlain(String text) { final links = findBareLinks(text); if (links.isEmpty) return text; diff --git a/mobile/lib/shared/hosted_agents/hosted_agent_client.dart b/mobile/lib/shared/hosted_agents/hosted_agent_client.dart index 8245e66965c..9425c70ce8a 100644 --- a/mobile/lib/shared/hosted_agents/hosted_agent_client.dart +++ b/mobile/lib/shared/hosted_agents/hosted_agent_client.dart @@ -457,7 +457,17 @@ class HostedAgentClient implements HostedAgentProvisioner { ...fields, }; final payload = stableJsonSha256(body); + int? lastSignedSecond; for (var attempt = 0; ; attempt++) { + // The API burns a proof by its event id, which covers `created_at` in + // whole seconds: a retry signed in the same second would repeat the + // burnt id, so it signs at least one second later. + final nowSecond = DateTime.now().millisecondsSinceEpoch ~/ 1000; + final signedSecond = + lastSignedSecond != null && nowSecond <= lastSignedSecond + ? lastSignedSecond + 1 + : nowSecond; + lastSignedSecond = signedSecond; final proof = buildOwnerWriteProof( ownerSecretHex: ownerSecretHex(), action: action, @@ -466,6 +476,7 @@ class HostedAgentClient implements HostedAgentProvisioner { providerAgentId: providerAgentId, communityId: route.communityId, payloadSha256: payload, + now: DateTime.fromMillisecondsSinceEpoch(signedSecond * 1000), ); try { final (status, response) = await _send( diff --git a/mobile/lib/shared/hosted_agents/hosted_agent_identity.dart b/mobile/lib/shared/hosted_agents/hosted_agent_identity.dart index 146170bd1b5..b39c27ba91c 100644 --- a/mobile/lib/shared/hosted_agents/hosted_agent_identity.dart +++ b/mobile/lib/shared/hosted_agents/hosted_agent_identity.dart @@ -82,8 +82,11 @@ class HostedAgentIdentity { ..add(secret) ..add([attestation.length >> 8, attestation.length & 0xff]) ..add(attestation); + // `copy: false` keeps a reference to `secret`, so copy the bundle out + // before wiping it; wiping first would seal an all-zero key. + final bytes = bundle.toBytes(); secret.fillRange(0, secret.length, 0); - return bundle.toBytes(); + return bytes; } /// Drop the secret. Further signing or sealing throws. diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 596c0f2d3ce..ce83bbd3e28 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -202,8 +202,8 @@ importers: specifier: ^3.3.0 version: 3.3.0 linkifyjs: - specifier: ^4.3.2 - version: 4.3.2 + specifier: ^4.3.3 + version: 4.3.3 lucide-react: specifier: ^1.0.0 version: 1.16.0(react@19.2.8) @@ -2893,9 +2893,6 @@ packages: linkify-it@5.0.2: resolution: {integrity: sha512-ONTm2jCMAVZjgQa/Fy1kScXsuOoF5NPTsoFBdE1KVIZ2vAh/r9+Bqo+0jINCBYnavTPQZz38QzFTme79ENoN3Q==} - linkifyjs@4.3.2: - resolution: {integrity: sha512-NT1CJtq3hHIreOianA8aSXn6Cw0JzYOuDQbOrSPe7gqFnCpKP++MQe3ODgO3oh2GJFORkAAdqredOa60z63GbA==} - linkifyjs@4.3.3: resolution: {integrity: sha512-P8aEP5U/D1/IlTY2OeYsErdwh9bGuLE30NcXtKEjgdHcahveQoQwM2yZNsioQHsWFz0P7KKudisbrzCgR0sDHg==} @@ -6156,8 +6153,6 @@ snapshots: dependencies: uc.micro: 2.1.0 - linkifyjs@4.3.2: {} - linkifyjs@4.3.3: {} locate-path@5.0.0: