Skip to content

Commit ad2a841

Browse files
loganjLarry
andauthored
fix(desktop): npub identity displays for mention, member, and workflow surfaces (#7495)
🤖 ## Summary Every Buzz account is identified by a long public key. Before this change, when someone had no display name, surfaces fell back to inconsistent labels — mostly raw hex fragments like `abcd1234…wxyz`, sometimes a generic role label with no key — so the same person looked different from surface to surface, and nothing looked like an npub address. This PR applies the npub identity foundation from #7488 to the everyday surfaces: a person without a display name now falls back to the same compact npub everywhere — `npub1xxxx…yyyy`, the human-readable spelling of their public key (first 8 + last 4 characters of the full npub) — across messages and mentions, reactions, huddles, member and participant lists, the sidebar and channel activity, search, projects, tray, notifications, and workflow surfaces. - **Mentions and messages**: key-only mention chips render the compact npub. Pasting a copied mention back still re-binds it byte-exactly to the identity it declares, for both the new npub chips and legacy hex-truncated chips copied by older clients — wrong, missing, or tampered key qualification is rejected instead of silently degrading to plain text. - **Reactions and huddles**: huddle reaction events and the huddle roster/participants render the compact npub for unnamed participants; workflow reaction triggers describe authors with the same form. - **Members and sidebar**: channel and community member lists, add-member results and invites, the members sidebar, the channel-activity popover, search, projects (assignees/reviewers/PR panels), the tray menu, and desktop notifications all fall back to the compact npub; titles and aria labels keep the machine-readable full labels. - **Profile labels**: panel/popover display names and owner handles fall back to the compact npub (never raw hex) when there is no name; linked-event (nevent) message metadata shows the npub-shaped author fallback while the event lookup and event IDs are unchanged. - **Workflows**: author-picker secondary labels, step destination keys, and trigger-author references render compact npubs; event and blob IDs keep their existing hex compacts (they are not identities). - **Avatars stay distinct**: fallback avatars for key-only identities derive initials from the key's tail, so prefixed role labels like "Participant npub1…" no longer collapse every unnamed participant onto the same initials; people with names keep their name initials. Preserved exactly: display names and distinct avatars, internal hex keys (storage/API forms unchanged), clipboard identity roundtrips, event/blob ID compaction, private keys (no nsec path is touched), and nevent link handling. Scope: this PR changes what identity labels **display**, not identity controls — profile/settings copy controls, the respond-to allowlist, workflow key fields, and agent dialogs are the sibling slice #7489, and the shared primitives (`canonicalNpub`, `truncateNpub`, the `<PubKey>` gate, strict input parsing) come from the foundation #7488. ### Related issue - Fixes: N/A. Searched existing issues/PRs for duplicates — none found; the related work is the npub identity stack this slice belongs to. - Base/dependency: stacks on #7488 (foundation) — this PR does not stand alone on main. - #7489 is a sibling slice on the same #7488 base (profile/agent/workflow controls), not a dependency: this PR does not require #7489, and #7489 does not require this PR — both only require #7488. ### Testing At exact head `4763cbeae1dd521309755e6d61f657324cb98667` (base: `fix/desktop-npub-identity-d1a` @ `5f3a4a8111998c8aa41ad77cf66992bd1c85343c`; 71 files, +656/−189 — production +277/−136, test support +379/−53): - At this head: targeted `mentions.spec.ts` (1/1), the e2e build, typecheck, and biome — green. - 9 changed/related unit files: 100/100 green; typecheck, e2e build, biome, and px text/truncation checks clean; huddle-roster focused run green; channel-activity e2e 11/11; mutation checks confirm the fallback wiring (removing it collapses shared initials and drops fallback rows). - Known pre-existing local e2e failures, unchanged by this PR and reproduced identically at the upstream merge-base: huddle-transcription voice-menu attribution (25 pass / 1 fail) and the `workflow-local-controls` 438px caret drift. Not claimed green locally. - Update at head `236af9e6137386737e84d3a474d6bc808a704c50` (test-only follow-ups `1143af345` + `236af9e6`): the `workflow-local-controls` races were fixed in the test drivers, and the 438px diff was shown to be a stale Darwin snapshot baseline (name-row enable switch already absent and `message_posted` already MessageSquare at recording commit `9390e11c9`) and refreshed — the focused screenshot test, including keyboard/caret assertions, now passes locally (twice). The full spec was not rerun after the snapshot refresh; the huddle-transcription item above is unchanged. Label/copy text changes are asserted by the e2e specs (`mentions`, `mention-recipients`, `pubkey-display-screenshots`, `huddle-transcription`, `channel-activity-popover`, `workflow-local-controls`) rather than new screenshots; the screenshot spec pins the compact npub text forms. ### Task provenance Buzz channel: `1f0e4a3d-7e01-4efe-bb16-843b357f85c9` Task: buzz://message?channel=1f0e4a3d-7e01-4efe-bb16-843b357f85c9&id=86b34eb4bd84a1472419e9af22636c011c0fe273e3c196f967d7a36996e149b6 --------- Signed-off-by: Logan Johnson <[email protected]> Co-authored-by: Larry <627498bd4bd1f281a16431e3c6cce3b5c25b6692798c78672298aefbf2f8f8b5@buzz.block.builderlab.xyz>
1 parent bfc3848 commit ad2a841

75 files changed

Lines changed: 716 additions & 198 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎desktop/src/app/useTrayMenu.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {
1010
useManagedAgentsQuery,
1111
useRelayAgentsQuery,
1212
} from "@/features/agents/hooks";
13-
import { normalizePubkey, truncatePubkey } from "@/shared/lib/pubkey";
13+
import { normalizePubkey, truncateNpub } from "@/shared/lib/pubkey";
1414
import { useNow } from "@/shared/lib/useNow";
1515
import { formatElapsed } from "@/features/agents/ui/agentSessionUtils";
1616
import type { Channel } from "@/shared/api/types";
@@ -72,7 +72,7 @@ export function useTrayMenu({
7272
activityId: `${channelTurn.channelId}:${normalizePubkey(pubkey)}`,
7373
agentName:
7474
agentNames.get(normalizePubkey(pubkey)) ??
75-
`Agent ${truncatePubkey(pubkey)}`,
75+
`Agent ${truncateNpub(pubkey)}`,
7676
channelId: channelTurn.channelId,
7777
channelName:
7878
channelNames.get(channelTurn.channelId) ?? "Unknown channel",

‎desktop/src/features/agents/ui/PersonaShareRecipients.tsx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import { ProfileAvatar } from "@/features/profile/ui/ProfileAvatar";
1515
import { SelectedRecipientChip } from "@/features/profile/ui/SelectedRecipientChip";
1616
import { useIdentityQuery } from "@/shared/api/hooks";
1717
import type { UserSearchResult } from "@/shared/api/types";
18-
import { normalizePubkey, truncatePubkey } from "@/shared/lib/pubkey";
18+
import { normalizePubkey, truncateNpub } from "@/shared/lib/pubkey";
1919
import { Popover, PopoverAnchor, PopoverContent } from "@/shared/ui/popover";
2020
import { Skeleton } from "@/shared/ui/skeleton";
2121

@@ -25,7 +25,7 @@ export function formatShareRecipientName(user: UserSearchResult) {
2525
return (
2626
user.displayName?.trim() ||
2727
user.nip05Handle?.trim() ||
28-
truncatePubkey(user.pubkey)
28+
truncateNpub(user.pubkey)
2929
);
3030
}
3131

‎desktop/src/features/channels/lib/memberUtils.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { ChannelMember } from "@/shared/api/types";
2-
import { truncatePubkey } from "@/shared/lib/pubkey";
2+
import { truncateNpub } from "@/shared/lib/pubkey";
33

44
export const roleOrder: Record<ChannelMember["role"], number> = {
55
owner: 0,
@@ -17,7 +17,7 @@ export function formatMemberName(
1717
return "You";
1818
}
1919

20-
return member.displayName ?? truncatePubkey(member.pubkey);
20+
return member.displayName ?? truncateNpub(member.pubkey);
2121
}
2222

2323
export function compareMembersByRole(

‎desktop/src/features/channels/ui/AddMemberSearchResultRow.tsx‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { Bot } from "lucide-react";
33
import type { UserSearchResult } from "@/shared/api/types";
44
import { Button } from "@/shared/ui/button";
55
import { cn } from "@/shared/lib/cn";
6-
import { truncatePubkey } from "@/shared/lib/pubkey";
6+
import { truncateNpub } from "@/shared/lib/pubkey";
77
import { UserAvatar } from "@/shared/ui/UserAvatar";
88

99
const MEMBER_ROW_INSET_DIVIDER_CLASS =
@@ -13,7 +13,7 @@ export function formatAddCandidateName(user: UserSearchResult) {
1313
return (
1414
user.displayName?.trim() ||
1515
user.nip05Handle?.trim() ||
16-
truncatePubkey(user.pubkey)
16+
truncateNpub(user.pubkey)
1717
);
1818
}
1919

@@ -67,7 +67,7 @@ export function AddMemberSearchResultRow({
6767
/>
6868
</div>
6969
<span className="block truncate font-mono text-2xs text-muted-foreground">
70-
{truncatePubkey(user.pubkey)}
70+
{truncateNpub(user.pubkey)}
7171
</span>
7272
{ownerLabel ? (
7373
<span className="block truncate text-xs text-muted-foreground">

‎desktop/src/features/channels/ui/ChannelMemberInviteCard.tsx‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Search, UserPlus, X } from "lucide-react";
22
import * as React from "react";
33

44
import { parsePubkeyInput } from "@/shared/lib/nostrUtils";
5-
import { truncatePubkey } from "@/shared/lib/pubkey";
5+
import { truncateNpub } from "@/shared/lib/pubkey";
66
import { PubKey } from "@/shared/ui/PubKey";
77
import { useIsArchivedPredicate } from "@/features/identity-archive/hooks";
88
import { useUserSearchQuery } from "@/features/profile/hooks";
@@ -19,7 +19,7 @@ function formatSearchUserName(user: UserSearchResult) {
1919
return (
2020
user.displayName?.trim() ||
2121
user.nip05Handle?.trim() ||
22-
truncatePubkey(user.pubkey)
22+
truncateNpub(user.pubkey)
2323
);
2424
}
2525

@@ -270,11 +270,11 @@ export function ChannelMemberInviteCard({
270270
<div className="flex min-w-0 items-center gap-2">
271271
<UserAvatar
272272
avatarUrl={null}
273-
displayName={truncatePubkey(directInvitee.pubkey)}
273+
displayName={truncateNpub(directInvitee.pubkey)}
274274
size="xs"
275275
/>
276276
<p className="truncate text-sm font-medium leading-5">
277-
{truncatePubkey(directInvitee.pubkey)}
277+
{truncateNpub(directInvitee.pubkey)}
278278
</p>
279279
<span className="shrink-0 text-xs text-muted-foreground">
280280
by public key
@@ -370,7 +370,7 @@ export function ChannelMemberInviteCard({
370370
<div className="space-y-1 text-sm text-destructive">
371371
{submissionErrors.map((error) => (
372372
<p key={`${error.pubkey}-${error.error}`}>
373-
{truncatePubkey(error.pubkey)}: {error.error}
373+
{truncateNpub(error.pubkey)}: {error.error}
374374
</p>
375375
))}
376376
</div>

‎desktop/src/features/channels/ui/MembersSidebar.tsx‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ import {
4949
} from "@/shared/ui/dialog";
5050
import { useProfilePanel } from "@/shared/context/ProfilePanelContext";
5151
import { useFeedbackToasts } from "@/shared/hooks/useToastEffect";
52-
import { normalizePubkey, truncatePubkey } from "@/shared/lib/pubkey";
52+
import { normalizePubkey, truncateNpub } from "@/shared/lib/pubkey";
5353
import {
5454
MODAL_SEARCH_INPUT_CLASS,
5555
MODAL_SEARCH_SHELL_CLASS,
@@ -641,7 +641,7 @@ export function MembersSidebar({
641641
managedAgentRuntime={managedAgentRuntime}
642642
member={member}
643643
memberIsBot={memberIsBot}
644-
memberAvatarLabel={member.displayName ?? truncatePubkey(member.pubkey)}
644+
memberAvatarLabel={member.displayName ?? truncateNpub(member.pubkey)}
645645
memberLabel={formatMemberName(member, currentPubkey)}
646646
moderationState={moderationStateByPubkey.get(
647647
normalizePubkey(member.pubkey),
@@ -886,7 +886,7 @@ export function MembersSidebar({
886886
<div className="mt-4 space-y-1 text-sm text-destructive">
887887
{inviteSubmissionErrors.map((error) => (
888888
<p key={`${error.pubkey}-${error.error}`}>
889-
{truncatePubkey(error.pubkey)}: {error.error}
889+
{truncateNpub(error.pubkey)}: {error.error}
890890
</p>
891891
))}
892892
</div>

‎desktop/src/features/channels/ui/MembersSidebarMemberCard.tsx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import {
2727
MANAGED_AGENT_PAIR_ACTION_LABELS,
2828
type ManagedAgentPairAction,
2929
} from "@/features/agents/managedAgentRuntimeStatus";
30-
import { truncatePubkey } from "@/shared/lib/pubkey";
30+
import { truncateNpub } from "@/shared/lib/pubkey";
3131
import type {
3232
ChannelMember,
3333
ManagedAgent,
@@ -195,7 +195,7 @@ export function MembersSidebarMemberCard({
195195
</div>
196196
<span className="absolute inset-0 flex items-center opacity-0 transition-opacity duration-150 ease-out group-hover/member:opacity-100 group-focus-within/member:opacity-100">
197197
<span className="truncate font-mono text-sm text-muted-foreground">
198-
{truncatePubkey(member.pubkey)}
198+
{truncateNpub(member.pubkey)}
199199
</span>
200200
</span>
201201
</div>

‎desktop/src/features/channels/ui/useChannelAgentSessions.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import type {
88
RelayAgent,
99
} from "@/shared/api/types";
1010
import { usePanelReturnTarget } from "@/shared/hooks/usePanelReturnTarget";
11-
import { normalizePubkey, truncatePubkey } from "@/shared/lib/pubkey";
11+
import { normalizePubkey, truncateNpub } from "@/shared/lib/pubkey";
1212
import {
1313
channelBotMemberPubkeySet,
1414
channelMemberPubkeySet,
@@ -100,7 +100,7 @@ export function buildChannelAgentSessionCandidates({
100100

101101
byPubkey.set(key, {
102102
pubkey: member.pubkey,
103-
name: member.displayName ?? truncatePubkey(member.pubkey),
103+
name: member.displayName ?? truncateNpub(member.pubkey),
104104
status: "deployed",
105105
agentSource: "member-bot",
106106
canInterruptTurn: false,

‎desktop/src/features/community-members/ui/AddMemberDialog.tsx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { ProfileAvatar } from "@/features/profile/ui/ProfileAvatar";
1313
import { SelectedRecipientChip } from "@/features/profile/ui/SelectedRecipientChip";
1414
import type { RelayMemberRole, UserSearchResult } from "@/shared/api/types";
1515
import { parsePubkeyInput } from "@/shared/lib/nostrUtils";
16-
import { truncatePubkey } from "@/shared/lib/pubkey";
16+
import { truncateNpub } from "@/shared/lib/pubkey";
1717
import { Button } from "@/shared/ui/button";
1818
import {
1919
Dialog,
@@ -50,7 +50,7 @@ function formatSearchUserName(user: UserSearchResult) {
5050
return (
5151
user.displayName?.trim() ||
5252
user.nip05Handle?.trim() ||
53-
truncatePubkey(user.pubkey)
53+
truncateNpub(user.pubkey)
5454
);
5555
}
5656

‎desktop/src/features/community-members/ui/CommunityMembersCard.tsx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { MoreHorizontal, Plus, Shield, ShieldCheck, User } from "lucide-react";
33
import { toast } from "sonner";
44

55
import { useUsersBatchQuery } from "@/features/profile/hooks";
6-
import { truncatePubkey } from "@/shared/lib/pubkey";
6+
import { truncateNpub } from "@/shared/lib/pubkey";
77
import { PubKey } from "@/shared/ui/PubKey";
88
import {
99
useChangeRelayMemberRoleMutation,
@@ -101,7 +101,7 @@ function MemberRow({
101101
<div className="min-w-0">
102102
<div className="flex items-center gap-2">
103103
<span className="truncate text-sm font-medium">
104-
{displayName || truncatePubkey(member.pubkey)}
104+
{displayName || truncateNpub(member.pubkey)}
105105
</span>
106106
<RoleBadge role={member.role} />
107107
{isSelf ? (

0 commit comments

Comments
 (0)