diff --git a/.agents/skills/nostr-comments/files/components/comments/Comment.tsx b/.agents/skills/nostr-comments/files/components/comments/Comment.tsx index e776ce2..b0ab0c1 100644 --- a/.agents/skills/nostr-comments/files/components/comments/Comment.tsx +++ b/.agents/skills/nostr-comments/files/components/comments/Comment.tsx @@ -40,7 +40,6 @@ import { Trash2, } from 'lucide-react'; import { formatDistanceToNow } from 'date-fns'; -import { genUserName } from '@/lib/genUserName'; interface CommentProps { root: NostrEvent | URL | `#${string}`; @@ -63,7 +62,7 @@ export function Comment({ root, comment, depth = 0, maxDepth = 3, limit }: Comme const queryClient = useQueryClient(); const metadata = author.data?.metadata; - const displayName = metadata?.name ?? genUserName(comment.pubkey); + const displayName = metadata?.name ?? 'Anonymous'; const timeAgo = formatDistanceToNow(new Date(comment.created_at * 1000), { addSuffix: true }); const nevent = nip19.neventEncode({ id: comment.id, author: comment.pubkey, kind: comment.kind }); const isOwnComment = user?.pubkey === comment.pubkey; diff --git a/.agents/skills/note-content/SKILL.md b/.agents/skills/note-content/SKILL.md index e969256..549c7a4 100644 --- a/.agents/skills/note-content/SKILL.md +++ b/.agents/skills/note-content/SKILL.md @@ -176,11 +176,10 @@ The stubs shipped here are deliberately minimal so the skill works immediately a ## Tests -`NoteContent.test.tsx` covers URL linkification (kinds 1 and 1111), plain text, hashtag linkification, and mention rendering with generated vs real display names. It uses the template's `TestApp` wrapper. Run via `npm run test` once the files are in `src/`. +`NoteContent.test.tsx` covers URL linkification (kinds 1 and 1111), plain text, hashtag linkification, and mention rendering with fallback vs real display names. It uses the template's `TestApp` wrapper. Run via `npm run test` once the files are in `src/`. ## Related - **`useAuthor`** — used internally for mention resolution and for audio-embed author avatar. Core template. -- **`genUserName`** — fallback deterministic name when a mentioned user has no kind 0 metadata. Core template. - **`NIP19Page`** — the template's `/:nip19` route that handles every kind of NIP-19 link this component generates. - **`nwc` skill** — pair with `LightningInvoiceCard` for one-tap invoice payment via WebLN/NWC. diff --git a/.agents/skills/note-content/files/components/NoteContent.tsx b/.agents/skills/note-content/files/components/NoteContent.tsx index 1751dae..7770697 100644 --- a/.agents/skills/note-content/files/components/NoteContent.tsx +++ b/.agents/skills/note-content/files/components/NoteContent.tsx @@ -3,7 +3,6 @@ import { type NostrEvent } from '@nostrify/nostrify'; import { Link } from 'react-router-dom'; import { nip19 } from 'nostr-tools'; import { useAuthor } from '@/hooks/useAuthor'; -import { genUserName } from '@/lib/genUserName'; import { getDisplayName } from '@/lib/getDisplayName'; import { getAvatarShape } from '@/lib/avatarShape'; import { useProfileUrl } from '@/hooks/useProfileUrl'; @@ -532,7 +531,7 @@ export function NoteContent({ const author = useAuthor(hasMedia ? event.pubkey : undefined); const authorMetadata = author.data?.metadata; const authorDisplayName = useMemo( - () => getDisplayName(authorMetadata, event.pubkey) ?? genUserName(event.pubkey), + () => getDisplayName(authorMetadata, event.pubkey), [authorMetadata, event.pubkey], ); @@ -843,7 +842,7 @@ function InlineImage({ url, onClick }: { url: string; onClick: (e: React.MouseEv function NostrMention({ pubkey }: { pubkey: string }) { const author = useAuthor(pubkey); const hasRealName = !!author.data?.metadata?.name; - const displayName = author.data?.metadata?.name ?? genUserName(pubkey); + const displayName = author.data?.metadata?.name ?? 'Anonymous'; const profileUrl = useProfileUrl(pubkey, author.data?.metadata); return ( diff --git a/.agents/skills/note-content/files/lib/getDisplayName.ts b/.agents/skills/note-content/files/lib/getDisplayName.ts index 6ec92e7..4fa23a9 100644 --- a/.agents/skills/note-content/files/lib/getDisplayName.ts +++ b/.agents/skills/note-content/files/lib/getDisplayName.ts @@ -1,15 +1,14 @@ -import { genUserName } from '@/lib/genUserName'; import type { NostrMetadata } from '@nostrify/nostrify'; /** * Get a display name for a user. - * Uses metadata.name if available, otherwise generates a deterministic username. + * Uses metadata.name if available, otherwise falls back to "Anonymous". * Visual truncation is handled by CSS (`truncate` class) on the containing element * to avoid breaking NIP-30 custom emoji shortcodes. */ export function getDisplayName( metadata: NostrMetadata | undefined, - pubkey: string, + _pubkey: string, ): string { - return metadata?.name || genUserName(pubkey); + return metadata?.name || 'Anonymous'; } diff --git a/AGENTS.md b/AGENTS.md index cbc47dd..3a066a0 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -155,13 +155,12 @@ Fetch profile metadata (kind 0) for a pubkey: ```tsx import type { NostrEvent, NostrMetadata } from '@nostrify/nostrify'; import { useAuthor } from '@/hooks/useAuthor'; -import { genUserName } from '@/lib/genUserName'; function Post({ event }: { event: NostrEvent }) { const author = useAuthor(event.pubkey); const metadata: NostrMetadata | undefined = author.data?.metadata; - const displayName = metadata?.name ?? genUserName(event.pubkey); + const displayName = metadata?.name ?? 'Anonymous'; const profileImage = metadata?.picture; // ... }