From 9e7ff9f68c3643c212cd4750721f3f1f777656fb Mon Sep 17 00:00:00 2001 From: Ross Hartmann Date: Sat, 24 Oct 2026 09:31:30 -0700 Subject: [PATCH 1/2] fix(clients): desktop and mobile unit failures from the post-deploy run Real defects: - mobile: the hosted-agent identity bundle wiped the agent secret before copying the bundle out of a no-copy BytesBuilder, so the sealed envelope carried an all-zero key. Copy first, then wipe. - mobile: an owner-write retry signed its fresh proof in the same second as the burnt one, giving the same event id. The retry now signs at least one second later. - mobile: the bare-link pass found Markdown links with a regex that rereads the rest of an unclosed `[` run from every opener, which is quadratic on long malformed input (the near-limit openers test took 108 s). A one-pass scanner finds the same spans. - desktop: an upstream sync dropped the fork's respond-to picker change: a pasted npub or hex key is offered whatever the search returns, and the search asks for the member picker's page size (25). Restored on top of upstream's truncateNpub and squircle avatars. - desktop: the lockfile resolved linkifyjs 4.3.2 for desktop and 4.3.3 for @tiptap/extension-link, so Link's onCreate registered the buzz protocol on a different linkify instance than composerMessageLinkNode and bareLinks read. Desktop now resolves 4.3.3 as well. Test-only: - desktop: under NODE_ENV=test TanStack Router treats a jsdom process as a client and sets up scroll restoration through bare history, addEventListener and scrollTo. The router tests now expose them. - desktop: the older-route requester test matched "request" inside the wrapper's data-testid; it now checks visible text only. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01J3gDfAMsUq8X2NqFTrbJc6 Signed-off-by: Ross Hartmann --- desktop/package.json | 2 +- .../src/features/agents/ui/RespondToField.tsx | 73 +++++++++++-------- .../openChannelDirectoryResolver.test.mjs | 7 ++ .../guest-access/ui/requesterLine.test.mjs | 4 +- .../home/ui/inboxReopenNavigation.test.mjs | 7 ++ .../ui/useRetainedProjectGitViews.test.mjs | 7 ++ .../message_content/link_normalizer.dart | 72 ++++++++++++++++-- .../hosted_agents/hosted_agent_client.dart | 11 +++ .../hosted_agents/hosted_agent_identity.dart | 5 +- pnpm-lock.yaml | 9 +-- 10 files changed, 148 insertions(+), 49 deletions(-) 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/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: From 4ed2bb0ff3ce064f5dd2d445068cbafda1886288 Mon Sep 17 00:00:00 2001 From: Ross Hartmann Date: Sat, 24 Oct 2026 09:48:13 -0700 Subject: [PATCH 2/2] docs(fork): inventory the desktop unit fixes and huddle removal files Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01J3gDfAMsUq8X2NqFTrbJc6 Signed-off-by: Ross Hartmann --- docs/kiingo-fork-inventory.json | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/docs/kiingo-fork-inventory.json b/docs/kiingo-fork-inventory.json index e9ca4673da4..d7ca1d3d69c 100644 --- a/docs/kiingo-fork-inventory.json +++ b/docs/kiingo-fork-inventory.json @@ -2075,6 +2075,37 @@ "purpose": "RUSTSEC-2026-0387 (crypto-bigint 0.5 constant-time issues): buzz-push-gateway moves from p256 0.13 to p256 0.14 (elliptic-curve 0.14, crypto-bigint 0.7.6). The only code change is the renamed SEC1 trait (ToEncodedPoint::to_encoded_point to ToSec1Point::to_sec1_point) in App Attest public-key parsing and its tests. The deny.toml advisory ignore is removed in the same change.", "removalCondition": "Drop when upstream buzz-push-gateway is on p256 0.14 or later.", "upstreamStatus": "Generic dependency security bump; 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" + ] + }, + { + "id": "huddle-removal-across-reconnect-2026-10-24", + "classification": "retain-generic", + "owner": "Buzz huddle maintainers", + "purpose": "An authorized removal from a huddle survives audio reconnect and parent-channel auto-admission: audio admission refuses an externally removed or unknown-provenance membership (rechecked under the membership lock, with re-invitation and self-leave/rejoin preserved), and the desktop treats the relay's terminal removal/ended frame as a leave instead of reconnecting. Inventory entry for the files that change added outside the existing deltas.", + "upstreamStatus": "Generic huddle correctness fix; not yet submitted to block/buzz.", + "removalCondition": "Drop when upstream keeps huddle removal across audio reconnect.", + "paths": [ + "crates/buzz-relay/src/audio/huddle_removal_postgres_tests.rs", + "desktop/src-tauri/src/huddle/playout.rs", + "desktop/src-tauri/src/huddle/relay_api.rs", + "desktop/src/features/huddle/lib/huddleAudioDisconnect.test.mjs", + "desktop/src/features/huddle/lib/huddleAudioDisconnect.ts", + "docs/implementation-plans/M-4581-huddle-removal.md" + ] } ], "budgetAmendments": [