Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion desktop/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
73 changes: 42 additions & 31 deletions desktop/src/features/agents/ui/RespondToField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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 (
<div
Expand Down Expand Up @@ -368,7 +375,9 @@ function AllowlistPicker({
disabled={disabled}
onChange={(event) => 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}
/>
Expand Down Expand Up @@ -402,6 +411,32 @@ function AllowlistPicker({
) : null}
{deferredQuery.length > 0 ? (
<div className="border-t border-border/70 px-2 py-2">
{directPubkey ? (
<button
className="flex w-full items-center justify-between rounded-md px-2.5 py-1.5 text-left transition-colors hover:bg-accent hover:text-accent-foreground"
data-testid="agent-respond-to-add-raw-pubkey"
disabled={disabled}
onClick={() => onAddRawPubkey(directPubkey)}
type="button"
>
<div className="flex items-center gap-2 min-w-0">
<UserAvatar
avatarUrl={null}
displayName={truncateNpub(directPubkey)}
size="xs"
/>
<div className="min-w-0">
<p className="truncate text-sm font-medium leading-5">
{truncateNpub(directPubkey)}
</p>
<p className="truncate text-xs text-muted-foreground">
Add pubkey directly
</p>
</div>
</div>
<span className="text-xs text-muted-foreground">Add</span>
</button>
) : null}
{searchIsLoading ? (
<p className="px-2 py-1 text-sm text-muted-foreground">
Searching…
Expand Down Expand Up @@ -436,31 +471,7 @@ function AllowlistPicker({
</button>
))}
</div>
) : queryIsDirectPubkey ? (
<button
className="flex w-full items-center justify-between rounded-md px-2.5 py-1.5 text-left transition-colors hover:bg-accent hover:text-accent-foreground"
data-testid="agent-respond-to-add-raw-pubkey"
onClick={() => onAddRawPubkey(queryPubkey)}
type="button"
>
<div className="flex items-center gap-2 min-w-0">
<UserAvatar
avatarUrl={null}
displayName={truncateNpub(queryPubkey)}
size="xs"
/>
<div className="min-w-0">
<p className="truncate text-sm font-medium leading-5">
{truncateNpub(queryPubkey)}
</p>
<p className="truncate text-xs text-muted-foreground">
Add pubkey directly
</p>
</div>
</div>
<span className="text-xs text-muted-foreground">Add</span>
</button>
) : (
) : directPubkey ? null : (
<p className="px-2 py-1 text-sm text-muted-foreground">
No matching users.
</p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 3 additions & 1 deletion desktop/src/features/guest-access/ui/requesterLine.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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", () => {
Expand Down
7 changes: 7 additions & 0 deletions desktop/src/features/home/ui/inboxReopenNavigation.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
15 changes: 15 additions & 0 deletions docs/kiingo-fork-inventory.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand Down
72 changes: 64 additions & 8 deletions mobile/lib/features/channels/message_content/link_normalizer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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<int>.filled(n + 1, n);
final destinationStop = List<int>.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;
Expand Down
11 changes: 11 additions & 0 deletions mobile/lib/shared/hosted_agents/hosted_agent_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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(
Expand Down
5 changes: 4 additions & 1 deletion mobile/lib/shared/hosted_agents/hosted_agent_identity.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
9 changes: 2 additions & 7 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading