fix(nip-22): render root event as card using KindRenderer

CRITICAL FIX: Use getCommentRootPointer instead of getCommentReplyPointer
when opening chat on kind 1111 comments.

Previously:
- Clicking "Chat" on a comment-to-comment used getCommentReplyPointer
- This returned the PARENT comment, not the thread ROOT
- Resulted in trying to open chat on intermediate comments
- Failed with "Event not found" when parent wasn't fetchable

Now:
- Uses getCommentRootPointer to find the actual thread root
- Opens chat on the original event (blog post, etc.)
- Properly resolves multi-level comment threads

Also fixes:
- NIP-22 adapter now properly uses getCommentRootPointer in resolveConversation
- Reply detection in eventToMessage uses getCommentReplyPointer correctly
- Reply previews now show for comment-to-comment replies
This commit is contained in:
Claude
2026-01-23 21:27:33 +00:00
parent 1f47f9da72
commit 4613c1c53e

View File

@@ -36,7 +36,7 @@ import { nip19 } from "nostr-tools";
import { getTagValue } from "applesauce-core/helpers";
import { parseAddressPointer } from "@/lib/nip89-helpers";
import { getSeenRelays } from "applesauce-core/helpers/relays";
import { getCommentReplyPointer } from "applesauce-common/helpers";
import { getCommentRootPointer } from "applesauce-common/helpers";
import { parseChatCommand } from "@/lib/chat-parser";
import { EventFooter } from "@/components/EventFooter";
import { cn } from "@/lib/utils";
@@ -218,7 +218,7 @@ export function EventMenu({
const openChatWindow = () => {
// Special handling for kind 1111 comments - open chat with root event
if (event.kind === 1111) {
const rootPointer = getCommentReplyPointer(event);
const rootPointer = getCommentRootPointer(event);
if (rootPointer) {
// Encode root as nevent/naddr and parse
const seenRelaysSet = getSeenRelays(event);
@@ -455,7 +455,7 @@ export function EventContextMenu({
const openChatWindow = () => {
// Special handling for kind 1111 comments - open chat with root event
if (event.kind === 1111) {
const rootPointer = getCommentReplyPointer(event);
const rootPointer = getCommentRootPointer(event);
if (rootPointer) {
// Encode root as nevent/naddr and parse
const seenRelaysSet = getSeenRelays(event);