From b53f20ef4b9c152d026e1f4ddeb02e4c4de5139d Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 19 Jan 2026 16:40:51 +0000 Subject: [PATCH] fix: NIP-10 adapter delegates to NIP-22 for non-kind-1 events When NIP-10 adapter encounters a non-kind-1 event (e.g., kind 9735 zap), it now gracefully delegates to NIP-22 comment adapter instead of throwing an error. This enables seamless chat on any event type. Also changed menu label from "Comments" to "Chat" for all event types. --- .../nostr/kinds/BaseEventRenderer.tsx | 2 +- src/lib/chat/adapters/nip-10-adapter.ts | 19 ++++++++++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/components/nostr/kinds/BaseEventRenderer.tsx b/src/components/nostr/kinds/BaseEventRenderer.tsx index a49a6b3..b10f633 100644 --- a/src/components/nostr/kinds/BaseEventRenderer.tsx +++ b/src/components/nostr/kinds/BaseEventRenderer.tsx @@ -278,7 +278,7 @@ export function EventMenu({ event }: { event: NostrEvent }) { - {event.kind === 1 ? "Chat" : "Comments"} + Chat diff --git a/src/lib/chat/adapters/nip-10-adapter.ts b/src/lib/chat/adapters/nip-10-adapter.ts index 16fe770..6d0c837 100644 --- a/src/lib/chat/adapters/nip-10-adapter.ts +++ b/src/lib/chat/adapters/nip-10-adapter.ts @@ -30,6 +30,7 @@ import { eventToMessage, AGGREGATOR_RELAYS, } from "../utils"; +import { Nip22Adapter } from "./nip-22-adapter"; const LOG_PREFIX = "[NIP-10]"; @@ -122,8 +123,24 @@ export class Nip10Adapter extends ChatProtocolAdapter { throw new Error("Event not found"); } + // If not kind 1, delegate to NIP-22 comment adapter if (providedEvent.kind !== 1) { - throw new Error(`Expected kind 1 note, got kind ${providedEvent.kind}`); + console.log( + `${LOG_PREFIX} Event is kind ${providedEvent.kind}, delegating to NIP-22`, + ); + const nip22Adapter = new Nip22Adapter(); + // Build a comment identifier from the event + const commentIdentifier = { + type: "comment" as const, + value: { + id: providedEvent.id, + relays: relayHints, + author: providedEvent.pubkey, + kind: providedEvent.kind, + }, + relays: relayHints, + }; + return nip22Adapter.resolveConversation(commentIdentifier); } // 2. Parse NIP-10 references to find root