Skip to content

Commit 8cce3c0

Browse files
loganjLarry
andcommitted
fix(desktop): render compact npub for unnamed relay thread participants
jedwards27 review of PR #7495 (exact head a1ffa77, 22:10:51Z) flagged [P2] that buildRelayThreadSummary fell back from a missing profile name to the raw pubkey, so a cold/relay-only thread facepile exposed the raw 64-char hex identity via UserAvatar's displayName label while the client-assembled path (resolveUserLabel) already renders the compact npub. Fall back to truncateNpub(pubkey) instead — the same canonical compact identity form used everywhere else in this PR. Authored profile names are untouched; distinct key-tail avatar initials come for free because getInitials derives them from the compact npub shape. Replace the review-flagged invalid relay-summary fixture ("bob") with a valid 64-hex key and assert the compact npub label — the value MessageThreadSummaryRow binds to UserAvatar's visible/accessible displayName. Verified falsifiable: reverting the fallback to raw pubkey fails the test. Co-authored-by: Larry <627498bd4bd1f281a16431e3c6cce3b5c25b6692798c78672298aefbf2f8f8b5@buzz.block.builderlab.xyz> Signed-off-by: Logan Johnson <[email protected]>
1 parent a1ffa77 commit 8cce3c0

2 files changed

Lines changed: 18 additions & 4 deletions

File tree

‎desktop/src/features/messages/lib/threadPanel.test.mjs‎

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -607,14 +607,21 @@ test("buildThreadPanelDataFromIndex matches direct panel data", () => {
607607

608608
test("buildMainTimelineEntries renders a relay-only thread summary", () => {
609609
const root = message({ id: "root", createdAt: 1 });
610+
// Realistic 64-hex relay participant keys: a cold/relay-only summary has no
611+
// client messages to derive labels from, so an unnamed participant must
612+
// fall back to the compact npub (`truncateNpub`, the same form the
613+
// client-assembled path derives via `resolveUserLabel`) — never the raw
614+
// hex identity. `participant.author` is what `MessageThreadSummaryRow`
615+
// binds to `UserAvatar`'s visible/accessible `displayName` label.
616+
const bob = "deadbeef".repeat(8); // → npub1m6k…zuz0
610617
const summaries = new Map([
611618
[
612619
"root",
613620
{
614621
replyCount: 2,
615622
descendantCount: 4,
616623
lastReplyAt: 9,
617-
participantPubkeys: ["alice", "bob"],
624+
participantPubkeys: ["alice", bob],
618625
},
619626
],
620627
]);
@@ -631,10 +638,10 @@ test("buildMainTimelineEntries renders a relay-only thread summary", () => {
631638
threadHeadId: "root",
632639
replyCount: 4,
633640
lastReplyAt: 9,
634-
// Relay returns participants most-recent-first (["alice", "bob"]); the
641+
// Relay returns participants most-recent-first (["alice", bob]); the
635642
// facepile renders them oldest-first so the last replier lands rightmost.
636643
participants: [
637-
{ id: "bob", author: "bob", avatarUrl: null },
644+
{ id: bob, author: "npub1m6k…zuz0", avatarUrl: null },
638645
{ id: "alice", author: "Alice", avatarUrl: "alice.png" },
639646
],
640647
});

‎desktop/src/features/messages/lib/threadPanel.ts‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import type { TimelineMessage } from "@/features/messages/types";
22
import type { ChannelWindowThreadSummary } from "@/features/messages/lib/channelWindowStore";
33
import type { UserProfileLookup } from "@/features/profile/lib/identity";
44
import { isBroadcastReply } from "@/features/messages/lib/threading";
5+
import { truncateNpub } from "@/shared/lib/pubkey";
56
import { KIND_HUDDLE_STARTED } from "@/shared/constants/kinds";
67

78
type ThreadPanelData = {
@@ -408,7 +409,13 @@ function buildRelayThreadSummary(
408409
.reverse()
409410
.map((pubkey) => ({
410411
id: pubkey,
411-
author: profiles?.[pubkey.toLowerCase()]?.displayName ?? pubkey,
412+
// Unnamed participants fall back to the compact npub — the same label
413+
// the client-assembled path derives via `resolveUserLabel` — so a
414+
// cold/relay-only facepile never surfaces raw hex. This `author` is
415+
// what `MessageThreadSummaryRow` binds to `UserAvatar`'s
416+
// `displayName` (the visible/accessible avatar label).
417+
author:
418+
profiles?.[pubkey.toLowerCase()]?.displayName ?? truncateNpub(pubkey),
412419
avatarUrl: profiles?.[pubkey.toLowerCase()]?.avatarUrl ?? null,
413420
...(profiles?.[pubkey.toLowerCase()]?.isAgent === true
414421
? { isAgent: true }

0 commit comments

Comments
 (0)