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
4 changes: 2 additions & 2 deletions desktop/src/app/useTrayMenu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
useManagedAgentsQuery,
useRelayAgentsQuery,
} from "@/features/agents/hooks";
import { normalizePubkey, truncatePubkey } from "@/shared/lib/pubkey";
import { normalizePubkey, truncateNpub } from "@/shared/lib/pubkey";
import { useNow } from "@/shared/lib/useNow";
import { formatElapsed } from "@/features/agents/ui/agentSessionUtils";
import type { Channel } from "@/shared/api/types";
Expand Down Expand Up @@ -72,7 +72,7 @@ export function useTrayMenu({
activityId: `${channelTurn.channelId}:${normalizePubkey(pubkey)}`,
agentName:
agentNames.get(normalizePubkey(pubkey)) ??
`Agent ${truncatePubkey(pubkey)}`,
`Agent ${truncateNpub(pubkey)}`,
channelId: channelTurn.channelId,
channelName:
channelNames.get(channelTurn.channelId) ?? "Unknown channel",
Expand Down
4 changes: 2 additions & 2 deletions desktop/src/features/agents/ui/PersonaShareRecipients.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { ProfileAvatar } from "@/features/profile/ui/ProfileAvatar";
import { SelectedRecipientChip } from "@/features/profile/ui/SelectedRecipientChip";
import { useIdentityQuery } from "@/shared/api/hooks";
import type { UserSearchResult } from "@/shared/api/types";
import { normalizePubkey, truncatePubkey } from "@/shared/lib/pubkey";
import { normalizePubkey, truncateNpub } from "@/shared/lib/pubkey";
import { Popover, PopoverAnchor, PopoverContent } from "@/shared/ui/popover";
import { Skeleton } from "@/shared/ui/skeleton";

Expand All @@ -25,7 +25,7 @@ export function formatShareRecipientName(user: UserSearchResult) {
return (
user.displayName?.trim() ||
user.nip05Handle?.trim() ||
truncatePubkey(user.pubkey)
truncateNpub(user.pubkey)
);
}

Expand Down
4 changes: 2 additions & 2 deletions desktop/src/features/channels/lib/memberUtils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { ChannelMember } from "@/shared/api/types";
import { truncatePubkey } from "@/shared/lib/pubkey";
import { truncateNpub } from "@/shared/lib/pubkey";

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

return member.displayName ?? truncatePubkey(member.pubkey);
return member.displayName ?? truncateNpub(member.pubkey);
}

export function compareMembersByRole(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Bot } from "lucide-react";
import type { UserSearchResult } from "@/shared/api/types";
import { Button } from "@/shared/ui/button";
import { cn } from "@/shared/lib/cn";
import { truncatePubkey } from "@/shared/lib/pubkey";
import { truncateNpub } from "@/shared/lib/pubkey";
import { UserAvatar } from "@/shared/ui/UserAvatar";

const MEMBER_ROW_INSET_DIVIDER_CLASS =
Expand All @@ -13,7 +13,7 @@ export function formatAddCandidateName(user: UserSearchResult) {
return (
user.displayName?.trim() ||
user.nip05Handle?.trim() ||
truncatePubkey(user.pubkey)
truncateNpub(user.pubkey)
);
}

Expand Down Expand Up @@ -67,7 +67,7 @@ export function AddMemberSearchResultRow({
/>
</div>
<span className="block truncate font-mono text-2xs text-muted-foreground">
{truncatePubkey(user.pubkey)}
{truncateNpub(user.pubkey)}
</span>
{ownerLabel ? (
<span className="block truncate text-xs text-muted-foreground">
Expand Down
10 changes: 5 additions & 5 deletions desktop/src/features/channels/ui/ChannelMemberInviteCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Search, UserPlus, X } from "lucide-react";
import * as React from "react";

import { parsePubkeyInput } from "@/shared/lib/nostrUtils";
import { truncatePubkey } from "@/shared/lib/pubkey";
import { truncateNpub } from "@/shared/lib/pubkey";
import { PubKey } from "@/shared/ui/PubKey";
import { useIsArchivedPredicate } from "@/features/identity-archive/hooks";
import { useUserSearchQuery } from "@/features/profile/hooks";
Expand All @@ -19,7 +19,7 @@ function formatSearchUserName(user: UserSearchResult) {
return (
user.displayName?.trim() ||
user.nip05Handle?.trim() ||
truncatePubkey(user.pubkey)
truncateNpub(user.pubkey)
);
}

Expand Down Expand Up @@ -270,11 +270,11 @@ export function ChannelMemberInviteCard({
<div className="flex min-w-0 items-center gap-2">
<UserAvatar
avatarUrl={null}
displayName={truncatePubkey(directInvitee.pubkey)}
displayName={truncateNpub(directInvitee.pubkey)}
size="xs"
/>
<p className="truncate text-sm font-medium leading-5">
{truncatePubkey(directInvitee.pubkey)}
{truncateNpub(directInvitee.pubkey)}
</p>
<span className="shrink-0 text-xs text-muted-foreground">
by public key
Expand Down Expand Up @@ -370,7 +370,7 @@ export function ChannelMemberInviteCard({
<div className="space-y-1 text-sm text-destructive">
{submissionErrors.map((error) => (
<p key={`${error.pubkey}-${error.error}`}>
{truncatePubkey(error.pubkey)}: {error.error}
{truncateNpub(error.pubkey)}: {error.error}
</p>
))}
</div>
Expand Down
6 changes: 3 additions & 3 deletions desktop/src/features/channels/ui/MembersSidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ import {
} from "@/shared/ui/dialog";
import { useProfilePanel } from "@/shared/context/ProfilePanelContext";
import { useFeedbackToasts } from "@/shared/hooks/useToastEffect";
import { normalizePubkey, truncatePubkey } from "@/shared/lib/pubkey";
import { normalizePubkey, truncateNpub } from "@/shared/lib/pubkey";
import {
MODAL_SEARCH_INPUT_CLASS,
MODAL_SEARCH_SHELL_CLASS,
Expand Down Expand Up @@ -641,7 +641,7 @@ export function MembersSidebar({
managedAgentRuntime={managedAgentRuntime}
member={member}
memberIsBot={memberIsBot}
memberAvatarLabel={member.displayName ?? truncatePubkey(member.pubkey)}
memberAvatarLabel={member.displayName ?? truncateNpub(member.pubkey)}
memberLabel={formatMemberName(member, currentPubkey)}
moderationState={moderationStateByPubkey.get(
normalizePubkey(member.pubkey),
Expand Down Expand Up @@ -886,7 +886,7 @@ export function MembersSidebar({
<div className="mt-4 space-y-1 text-sm text-destructive">
{inviteSubmissionErrors.map((error) => (
<p key={`${error.pubkey}-${error.error}`}>
{truncatePubkey(error.pubkey)}: {error.error}
{truncateNpub(error.pubkey)}: {error.error}
</p>
))}
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import {
MANAGED_AGENT_PAIR_ACTION_LABELS,
type ManagedAgentPairAction,
} from "@/features/agents/managedAgentRuntimeStatus";
import { truncatePubkey } from "@/shared/lib/pubkey";
import { truncateNpub } from "@/shared/lib/pubkey";
import type {
ChannelMember,
ManagedAgent,
Expand Down Expand Up @@ -195,7 +195,7 @@ export function MembersSidebarMemberCard({
</div>
<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">
<span className="truncate font-mono text-sm text-muted-foreground">
{truncatePubkey(member.pubkey)}
{truncateNpub(member.pubkey)}
</span>
</span>
</div>
Expand Down
4 changes: 2 additions & 2 deletions desktop/src/features/channels/ui/useChannelAgentSessions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import type {
RelayAgent,
} from "@/shared/api/types";
import { usePanelReturnTarget } from "@/shared/hooks/usePanelReturnTarget";
import { normalizePubkey, truncatePubkey } from "@/shared/lib/pubkey";
import { normalizePubkey, truncateNpub } from "@/shared/lib/pubkey";
import {
channelBotMemberPubkeySet,
channelMemberPubkeySet,
Expand Down Expand Up @@ -100,7 +100,7 @@ export function buildChannelAgentSessionCandidates({

byPubkey.set(key, {
pubkey: member.pubkey,
name: member.displayName ?? truncatePubkey(member.pubkey),
name: member.displayName ?? truncateNpub(member.pubkey),
status: "deployed",
agentSource: "member-bot",
canInterruptTurn: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { ProfileAvatar } from "@/features/profile/ui/ProfileAvatar";
import { SelectedRecipientChip } from "@/features/profile/ui/SelectedRecipientChip";
import type { RelayMemberRole, UserSearchResult } from "@/shared/api/types";
import { parsePubkeyInput } from "@/shared/lib/nostrUtils";
import { truncatePubkey } from "@/shared/lib/pubkey";
import { truncateNpub } from "@/shared/lib/pubkey";
import { Button } from "@/shared/ui/button";
import {
Dialog,
Expand Down Expand Up @@ -50,7 +50,7 @@ function formatSearchUserName(user: UserSearchResult) {
return (
user.displayName?.trim() ||
user.nip05Handle?.trim() ||
truncatePubkey(user.pubkey)
truncateNpub(user.pubkey)
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { MoreHorizontal, Plus, Shield, ShieldCheck, User } from "lucide-react";
import { toast } from "sonner";

import { useUsersBatchQuery } from "@/features/profile/hooks";
import { truncatePubkey } from "@/shared/lib/pubkey";
import { truncateNpub } from "@/shared/lib/pubkey";
import { PubKey } from "@/shared/ui/PubKey";
import {
useChangeRelayMemberRoleMutation,
Expand Down Expand Up @@ -101,7 +101,7 @@ function MemberRow({
<div className="min-w-0">
<div className="flex items-center gap-2">
<span className="truncate text-sm font-medium">
{displayName || truncatePubkey(member.pubkey)}
{displayName || truncateNpub(member.pubkey)}
</span>
<RoleBadge role={member.role} />
{isSelf ? (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@ import type {
RelayMemberRole,
UserProfileSummary,
} from "@/shared/api/types";
import { normalizePubkey, truncatePubkey } from "@/shared/lib/pubkey";
import {
normalizePubkey,
truncateNpub,
UNAVAILABLE_KEY_LABEL,
} from "@/shared/lib/pubkey";
import { Button } from "@/shared/ui/button";
import {
DropdownMenu,
Expand Down Expand Up @@ -65,7 +69,7 @@ function HoverMemberIdentity({
displayName: string;
pubkey: string;
}) {
const npub = npubFromPubkey(pubkey) ?? pubkey;
const npub = npubFromPubkey(pubkey) ?? UNAVAILABLE_KEY_LABEL;
return (
<span className="inline-grid min-w-0 max-w-full grid-cols-1" title={npub}>
<span
Expand All @@ -78,7 +82,7 @@ function HoverMemberIdentity({
className="col-start-1 row-start-1 max-w-0 truncate font-mono text-2xs opacity-0 blur-0 transition-[max-width,opacity,filter] duration-[250ms] ease-in-out group-hover/member:max-w-40 group-hover/member:opacity-100 group-hover/member:blur-0 group-focus-within/member:max-w-40 group-focus-within/member:opacity-100 group-focus-within/member:blur-0 motion-reduce:transition-none"
data-testid={`relay-member-npub-${pubkey}`}
>
{truncatePubkey(npub)}
{truncateNpub(npub)}
</span>
</span>
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { toast } from "sonner";

import { truncatePubkey } from "@/shared/lib/pubkey";
import { truncateNpub } from "@/shared/lib/pubkey";
import { PubKey } from "@/shared/ui/PubKey";
import { useRemoveRelayMemberMutation } from "@/features/community-members/hooks";
import type { RelayMember } from "@/shared/api/types";
Expand All @@ -25,7 +25,7 @@ export function ConfirmRemoveDialog({
onOpenChange: (open: boolean) => void;
}) {
const removeMutation = useRemoveRelayMemberMutation();
const label = displayName || (member ? truncatePubkey(member.pubkey) : "");
const label = displayName || (member ? truncateNpub(member.pubkey) : "");

function handleOpenChange(next: boolean) {
if (!next) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ import { QueryClient, QueryClientProvider } from "@tanstack/react-query";

import { useCommunityJoinAlerts } from "@/features/community-members/useCommunityJoinAlerts.ts";
import { joinAlertStorageKey } from "@/features/community-members/lib/joinAlerts.ts";
import { truncateNpub } from "@/shared/lib/pubkey.ts";
import { relayClient } from "@/shared/api/relayClient.ts";
import { CommunitiesProvider } from "@/features/communities/useCommunities.tsx";
import { useCommunities } from "@/features/communities/useCommunities.tsx";
Expand Down Expand Up @@ -1715,7 +1716,7 @@ describe("useCommunityJoinAlerts — mounted subscription behaviour", () => {
"a frame that predates the demotion must not re-open disclosure",
);
assert.ok(
!notifications.some((entry) => entry.body?.includes(BOB.slice(0, 8))),
!notifications.some((entry) => entry.body?.includes(truncateNpub(BOB))),
"the demoted viewer must never learn the new member's identity",
);
assert.equal(
Expand Down Expand Up @@ -1982,11 +1983,11 @@ describe("useCommunityJoinAlerts — mounted subscription behaviour", () => {
"a community switch clears the latch: the feature recovers without a reload",
);
assert.ok(
notifications.some((entry) => entry.body?.includes(BOB.slice(0, 8))),
notifications.some((entry) => entry.body?.includes(truncateNpub(BOB))),
"the join suppressed by the latch is re-announced, not lost",
);
assert.ok(
notifications.some((entry) => entry.body?.includes(CAROL.slice(0, 8))),
notifications.some((entry) => entry.body?.includes(truncateNpub(CAROL))),
"and the new join lands too",
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ async function setup(options = {}) {
"@/shared/lib/pubkey": {
normalizePubkey: (s) => s.toLowerCase(),
truncatePubkey: (s) => s,
// Compact-identity seam stubbed alongside its sibling: this suite
// renders display names, never key-form labels.
truncateNpub: (s) => s,
},
"@/features/channels/hooks": {
useAddChannelMembersMutation: () => ({
Expand Down
4 changes: 2 additions & 2 deletions desktop/src/features/forum/ui/useForumMentionPreparation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { PRIVATE_CHANNEL_ADD_DENIED_MESSAGE } from "@/features/channels/lib/chan
import { useCanAddChannelMembers } from "@/features/channels/useCanAddChannelMembers";
import type { UseMentionsResult } from "@/features/messages/lib/useMentions";
import type { ChannelType } from "@/shared/api/types";
import { normalizePubkey, truncatePubkey } from "@/shared/lib/pubkey";
import { normalizePubkey, truncateNpub } from "@/shared/lib/pubkey";

type PendingInvite = {
channelId: string;
Expand Down Expand Up @@ -176,7 +176,7 @@ export function useForumMentionPreparation(
isInvitePending: isInviting,
names: (pending?.nonMemberPubkeys ?? []).map(
(pubkey) =>
mentions.getMentionDisplayName(pubkey) ?? truncatePubkey(pubkey),
mentions.getMentionDisplayName(pubkey) ?? truncateNpub(pubkey),
),
onDismiss: dismiss,
onInvite: () => void invite(),
Expand Down
5 changes: 2 additions & 3 deletions desktop/src/features/home/ui/RecentNotesSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type { UserNote } from "@/shared/api/socialTypes";
import type { UserProfileSummary } from "@/shared/api/types";
import { Markdown } from "@/shared/ui/markdown";
import { UserAvatar } from "@/shared/ui/UserAvatar";
import { truncatePubkey } from "@/shared/lib/pubkey";
import { truncateNpub } from "@/shared/lib/pubkey";

type RecentNotesSectionProps = {
notes: UserNote[];
Expand Down Expand Up @@ -52,8 +52,7 @@ export function RecentNotesSection({
<div className="space-y-0 overflow-hidden rounded-md border border-border/60">
{notes.slice(0, 5).map((note) => {
const profile = profiles[note.pubkey.toLowerCase()];
const displayName =
profile?.displayName ?? truncatePubkey(note.pubkey);
const displayName = profile?.displayName ?? truncateNpub(note.pubkey);
const isAgent = agentPubkeys.has(note.pubkey);

return (
Expand Down
4 changes: 2 additions & 2 deletions desktop/src/features/huddle/components/HuddleBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import { AddAgentDialog, type AgentAddResult } from "./AddAgentDialog";
import type { HuddleAgentVoiceSettings } from "./AgentVoiceMenu";
import { MicControls, SpeakerControls } from "./MicControls";
import { HuddleParticipantsControl } from "./ParticipantList";
import { truncatePubkey } from "@/shared/lib/pubkey";
import { truncateNpub } from "@/shared/lib/pubkey";

// Mirrors HuddleState in src-tauri/src/huddle/mod.rs.
type HuddleState = {
Expand Down Expand Up @@ -98,7 +98,7 @@ function clampReactionName(name: string): string {
}

function fallbackNameForPubkey(pubkey?: string | null): string {
return pubkey ? `Participant ${truncatePubkey(pubkey)}` : "Someone";
return pubkey ? `Participant ${truncateNpub(pubkey)}` : "Someone";
}

function parseHuddleReactionEvent(event: RelayEvent) {
Expand Down
Loading
Loading