44 mergeAllowlist ,
55 parsePubkeyInput ,
66} from "@/features/agents/lib/respondToAllowlist" ;
7- import { normalizePubkey , truncatePubkey } from "@/shared/lib/pubkey" ;
7+ import { parsePubkeyInput as parseCanonicalPubkey } from "@/shared/lib/nostrUtils" ;
8+ import { normalizePubkey , truncateNpub } from "@/shared/lib/pubkey" ;
89import { PubKey } from "@/shared/ui/PubKey" ;
910import { useIsArchivedPredicate } from "@/features/identity-archive/hooks" ;
1011import { useUserSearchQuery } from "@/features/profile/hooks" ;
@@ -59,7 +60,7 @@ function formatSearchUserName(user: UserSearchResult) {
5960 return (
6061 user . displayName ?. trim ( ) ||
6162 user . nip05Handle ?. trim ( ) ||
62- truncatePubkey ( user . pubkey )
63+ truncateNpub ( user . pubkey )
6364 ) ;
6465}
6566
@@ -69,7 +70,7 @@ function formatSearchUserSecondary(user: UserSearchResult) {
6970 if ( displayName && nip05Handle ) {
7071 return nip05Handle ;
7172 }
72- return truncatePubkey ( user . pubkey ) ;
73+ return truncateNpub ( user . pubkey ) ;
7374}
7475
7576const RESPOND_TO_OPTIONS : PersonaDropdownOption [ ] = [
@@ -278,8 +279,6 @@ export function CreateAgentRespondToField({
278279 ) ;
279280}
280281
281- const HEX_64_RE = / ^ [ 0 - 9 a - f ] { 64 } $ / i;
282-
283282function AllowlistPicker ( {
284283 allowlist,
285284 deferredQuery,
@@ -325,10 +324,12 @@ function AllowlistPicker({
325324} ) {
326325 const isPersona = variant === "persona" ;
327326
328- // Detect if the query is a valid hex pubkey that's not already in the list.
329- const queryIsHexPubkey =
330- HEX_64_RE . test ( deferredQuery ) &&
331- ! allowlist . some ( ( p ) => p . toLowerCase ( ) === deferredQuery . toLowerCase ( ) ) ;
327+ // Detect if the query is a pubkey (npub or hex) not already in the list;
328+ // direct entry offers the canonical hex for storage.
329+ const queryPubkey = parseCanonicalPubkey ( deferredQuery ) ;
330+ const queryIsDirectPubkey =
331+ queryPubkey !== null &&
332+ ! allowlist . some ( ( p ) => p . toLowerCase ( ) === queryPubkey ) ;
332333
333334 return (
334335 < div
@@ -382,12 +383,12 @@ function AllowlistPicker({
382383 >
383384 < UserAvatar
384385 avatarUrl = { null }
385- displayName = { truncatePubkey ( pubkey ) }
386+ displayName = { truncateNpub ( pubkey ) }
386387 size = "xs"
387388 />
388389 < PubKey pubkey = { pubkey } />
389390 < button
390- aria-label = { `Remove ${ truncatePubkey ( pubkey ) } ` }
391+ aria-label = { `Remove ${ truncateNpub ( pubkey ) } ` }
391392 className = "text-muted-foreground transition-colors hover:text-foreground"
392393 disabled = { disabled }
393394 onClick = { ( ) => onRemove ( pubkey ) }
@@ -435,22 +436,22 @@ function AllowlistPicker({
435436 </ button >
436437 ) ) }
437438 </ div >
438- ) : queryIsHexPubkey ? (
439+ ) : queryIsDirectPubkey ? (
439440 < button
440441 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"
441442 data-testid = "agent-respond-to-add-raw-pubkey"
442- onClick = { ( ) => onAddRawPubkey ( deferredQuery . toLowerCase ( ) ) }
443+ onClick = { ( ) => onAddRawPubkey ( queryPubkey ) }
443444 type = "button"
444445 >
445446 < div className = "flex items-center gap-2 min-w-0" >
446447 < UserAvatar
447448 avatarUrl = { null }
448- displayName = { truncatePubkey ( deferredQuery ) }
449+ displayName = { truncateNpub ( queryPubkey ) }
449450 size = "xs"
450451 />
451452 < div className = "min-w-0" >
452453 < p className = "truncate text-sm font-medium leading-5" >
453- { truncatePubkey ( deferredQuery ) }
454+ { truncateNpub ( queryPubkey ) }
454455 </ p >
455456 < p className = "truncate text-xs text-muted-foreground" >
456457 Add pubkey directly
@@ -494,22 +495,22 @@ function AllowlistPicker({
494495 id = "agent-respond-to-direct-panel"
495496 >
496497 < p className = "text-xs text-muted-foreground" >
497- One per line, or comma/space-separated. 64-char lowercase hex
498- only — npub decoding is not yet supported here .
498+ One per line, or comma/space-separated. Each entry is an npub
499+ (npub1…) or a 64-char hex public key .
499500 </ p >
500501 < Textarea
501502 className = "min-h-20 font-mono text-xs"
502503 data-testid = "agent-respond-to-paste"
503504 disabled = { disabled }
504505 onChange = { ( event ) => onPasteTextChange ( event . target . value ) }
505- placeholder = "abcdef0123…"
506+ placeholder = "npub1… or abcdef0123…"
506507 value = { pasteText }
507508 />
508509 { pasteInvalid . length > 0 ? (
509510 < p className = "text-xs text-destructive" >
510511 { pasteInvalid . length } entr
511- { pasteInvalid . length === 1 ? "y is" : "ies are" } not 64-char
512- hex and will be ignored.
512+ { pasteInvalid . length === 1 ? "y is" : "ies are" } not a valid
513+ npub or 64-char hex public key and will be ignored.
513514 </ p >
514515 ) : null }
515516 < div className = "flex items-center justify-between gap-2" >
0 commit comments