diff --git a/src/components/ChatViewer.tsx b/src/components/ChatViewer.tsx index b29de40..ec405e4 100644 --- a/src/components/ChatViewer.tsx +++ b/src/components/ChatViewer.tsx @@ -139,7 +139,7 @@ function isLiveActivityMetadata(value: unknown): value is LiveActivityMetadata { * Returns a string that can be passed to the `chat` command to open this conversation * * For NIP-29 groups: relay'group-id (without wss:// prefix) - * For communikeys (NIP-CC): relay'pubkey or just pubkey + * For communikeys (NIP-CC): relay'pubkey (relay hint required) * For NIP-53 live activities: naddr1... encoding */ function getChatIdentifier(conversation: Conversation): string | null { @@ -156,16 +156,12 @@ function getChatIdentifier(conversation: Conversation): string | null { if (conversation.protocol === "communikeys") { const pubkey = conversation.metadata?.groupId; // For communikeys, groupId is the pubkey const relayUrl = conversation.metadata?.relayUrl; - if (!pubkey) return null; - // If there's a relay hint, include it - if (relayUrl) { - const cleanRelay = relayUrl.replace(/^wss?:\/\//, ""); - return `${cleanRelay}'${pubkey}`; - } + // Communikeys require relay hints (from naddr or relay'pubkey format) + if (!pubkey || !relayUrl) return null; - // Otherwise just return the pubkey - return pubkey; + const cleanRelay = relayUrl.replace(/^wss?:\/\//, ""); + return `${cleanRelay}'${pubkey}`; } if (conversation.protocol === "nip-53") { diff --git a/src/lib/chat/adapters/nip-29-adapter.ts b/src/lib/chat/adapters/nip-29-adapter.ts index 693f685..b99b08b 100644 --- a/src/lib/chat/adapters/nip-29-adapter.ts +++ b/src/lib/chat/adapters/nip-29-adapter.ts @@ -45,9 +45,7 @@ export class Nip29Adapter extends ChatProtocolAdapter { * - relay.example.com'bitcoin-dev (NIP-29, wss:// prefix is optional) * - naddr1... (kind 39000 group metadata address, NIP-29) * - naddr1... (kind 10222 communikey definition, NIP-CC) - * - relay.example.com'npub1xxx (NIP-CC communikey) - * - npub1xxx (NIP-CC communikey, relays from kind 10222) - * - hex-pubkey (NIP-CC communikey, relays from kind 10222) + * - relay.example.com'npub1xxx (NIP-CC communikey with relay hint) */ parseIdentifier(input: string): ProtocolIdentifier | null { // Try naddr format first @@ -126,17 +124,6 @@ export class Nip29Adapter extends ChatProtocolAdapter { }; } - // NIP-CC bare communikey format: npub1xxx or hex pubkey - // Check if input is a valid pubkey (relays will be fetched from kind 10222) - const pubkey = this.extractPubkey(input); - if (pubkey) { - return { - type: "group", - value: pubkey, - relays: [], // Will be resolved from kind 10222 - }; - } - return null; } diff --git a/src/lib/command-reconstructor.ts b/src/lib/command-reconstructor.ts index 3d13c13..182ad3e 100644 --- a/src/lib/command-reconstructor.ts +++ b/src/lib/command-reconstructor.ts @@ -116,9 +116,9 @@ export function reconstructCommand(window: WindowInstance): string { } } - // NIP-CC communikeys: chat npub1... or chat relay'npub1... + // NIP-CC communikeys: chat relay'npub1... (relay hint required) if (protocol === "communikeys" && identifier.type === "group") { - const relayUrl = identifier.relays?.[0] || ""; + const relayUrl = identifier.relays?.[0]; const groupId = identifier.value; // This is a pubkey if (relayUrl && groupId) { @@ -127,10 +127,8 @@ export function reconstructCommand(window: WindowInstance): string { return `chat ${cleanRelay}'${groupId}`; } - // If no relay hint, just return the pubkey - if (groupId) { - return `chat ${groupId}`; - } + // Fallback: communikeys should always have relay hints + return "chat"; } // NIP-53 live activities: chat naddr1...