diff --git a/TODO.md b/TODO.md index 3d36644..c4083c3 100644 --- a/TODO.md +++ b/TODO.md @@ -111,3 +111,77 @@ Show timestamps/dates for notes in feed views for better chronological context. - **Collapsible relay list** - Show user relay links without inbox/outbox icons initially - **NIP badges everywhere** - Use consistent NIP badge components for linking to NIP documentation - **External spec event kind support** - Add references and documentation links for commented-out event kinds from external specs (Blossom, Marmot Protocol, NKBIP, nostrocket, Corny Chat, NUD, etc.) in `src/constants/kinds.ts`. Consider adding a separate registry or documentation for non-official-NIP event kinds. + +### NIP-22 Comment Threading Support +**Priority**: High +**Files**: `src/components/nostr/kinds/Kind1Renderer.tsx`, potentially new `Kind1111Renderer.tsx` + +**Current State**: +- Kind 1111 (Comment) is registered in constants with MessageCircle icon +- Kind 1111 currently falls back to DefaultKindRenderer (just shows raw content) +- Kind1Renderer only handles NIP-10 threading (kind 1 notes), not NIP-22 comments + +**NIP-22 Requirements**: +- Kind 1111 events are **not** replies to kind 1 notes - they use a different threading model +- Comments MUST use uppercase tags (K, E, A, I, P) for root scope +- Comments MUST use lowercase tags (k, e, a, i, p) for parent item +- Comments can thread on: + - Nostr events (using E/e, A/a tags with K/k for kinds, P/p for authors) + - External identifiers (using I/i tags with K/k for types - URLs, podcast GUIDs, etc.) +- Comments MUST NOT reply to kind 1 notes (NIP-10 should be used instead) + +**Implementation Tasks**: + +1. **Create Kind1111Renderer component**: + - Parse uppercase tags (K, E, A, I, P) to identify root scope + - Parse lowercase tags (k, e, a, i, p) to identify parent item + - Display comment content with RichText (plaintext only, no HTML/Markdown per spec) + - Show "replying to" context with appropriate UI based on tag types: + - For E/e tags: Fetch and display parent nostr event + - For A/a tags: Fetch and display addressable event + - For I/i tags: Display external identifier (URL, podcast, etc.) + - Handle nested comment threading (when parent is also kind 1111) + - Show root context indicator (what the comment thread is about) + +2. **Tag Parsing Utilities** (potentially in `src/lib/nip22.ts`): + - `getRootScope(event)` - extracts K, E, A, or I tags + - `getParentItem(event)` - extracts k, e, a, or i tags + - `getRootAuthor(event)` - extracts P tag + - `getParentAuthor(event)` - extracts p tag + - `isTopLevelComment(event)` - checks if root === parent + - Helper to determine comment type (event comment vs external identifier comment) + +3. **UI Components**: + - Comment thread visualization (show depth/nesting) + - Root context banner (e.g., "Comment on article", "Comment on podcast episode") + - External identifier display (for I tags - URLs, podcasts, etc.) + - Parent comment preview (for nested threads) + - Kind badge display (show what kind of event is being commented on) + +4. **Integration Points**: + - Update kind registry to use Kind1111Renderer + - Consider how comments relate to other viewers (e.g., showing comments on a 30023 article) + - Timeline/feed integration (how to display comment threads) + - Reply UI for creating new comments + +5. **Edge Cases to Handle**: + - Comments on replaceable/addressable events (both `a` and `e` tags present) + - Comments on external identifiers without nostr events + - Comments with q tags (quote references) + - Invalid comment structure (missing required K/k tags) + - Mixed case handling and validation + +6. **Testing Scenarios**: + - Top-level comment on blog post (kind 30023) + - Top-level comment on file (kind 1063) + - Nested reply to another comment (kind 1111 → 1111) + - Comment on external URL (I tag with "web" type) + - Comment on podcast episode (I tag with podcast GUID) + - Validation: ensure kind 1 notes don't use kind 1111 (should fail/warn) + +**References**: +- [NIP-22 Spec](https://github.com/nostr-protocol/nips/blob/master/22.md) +- [NIP-73 External Identities](https://github.com/nostr-protocol/nips/blob/master/73.md) (for I/i tag types) +- [NIP-10 Threading](https://github.com/nostr-protocol/nips/blob/master/10.md) (for contrast - what NOT to do) + +**Note**: This is a significant feature requiring careful attention to the threading model differences between NIP-10 (kind 1 notes) and NIP-22 (kind 1111 comments).