mirror of
https://github.com/purrgrammer/grimoire.git
synced 2026-04-09 23:16:50 +02:00
80a421b9fe80ff56cb23012177764dcdd008dfb6
6 Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
fdc7b1499f |
fix: build proper q-tag with relay hint and author pubkey for replies (#224)
* fix: build proper q-tag with relay hint and author pubkey for replies When sending replies in NIP-29 and NIP-C7 adapters, now build the full q-tag format per NIP-C7 spec: ["q", eventId, relayUrl, pubkey] Previously only the event ID was included, making it harder for clients to fetch the referenced event. Now: - NIP-29: includes group relay URL and author pubkey - NIP-C7: includes seen relay hint and author pubkey https://claude.ai/code/session_01Jy51Ayk57fzaFuuFFm1j1K * chore: remove unused NIP-C7 adapter The NIP-C7 adapter was already disabled/commented out everywhere. Removing the file to reduce dead code. https://claude.ai/code/session_01Jy51Ayk57fzaFuuFFm1j1K * chore: remove NIP-C7 references from docs and code - Remove nip-c7 from ChatProtocol type - Remove commented NIP-C7 adapter imports and switch cases - Update comments to reference NIP-29 instead of NIP-C7 - Update kind 9 renderer docs to reference NIP-29 - Clean up chat-parser docs and error messages https://claude.ai/code/session_01Jy51Ayk57fzaFuuFFm1j1K --------- Co-authored-by: Claude <noreply@anthropic.com> |
||
|
|
8f008ddd39 |
feat: nip-10 chat interface (#153)
* docs: add comprehensive NIP-10 thread chat design documentation
Add detailed design documents for implementing NIP-10 thread chat feature:
- nip10-thread-chat-design.md: Full architecture, data structures, adapter
implementation plan, relay selection strategy, UI requirements, and 7-phase
implementation checklist
- nip10-thread-chat-examples.md: Complete code examples showing identifier
parsing, conversation resolution, message loading, reply sending with proper
NIP-10 tags, and ChatViewer integration
- nip10-thread-chat-summary.md: Quick reference with visual comparisons,
architecture diagrams, protocol comparison table, data flow, and FAQ
The feature will enable "chat nevent1..." to display kind 1 threaded
conversations as chat interfaces, with the root event prominently displayed
at the top and all replies shown as chat messages below.
Key design decisions:
- Use e-tags with NIP-10 markers (root/reply) instead of q-tags
- Merge multiple relay sources (seen, hints, outbox) for coverage
- Display root event centered with full feed renderer
- Reuse existing ChatViewer infrastructure via adapter pattern
- Support both nevent (with relay hints) and note (ID only) formats
* feat: implement NIP-10 thread chat support
Add complete NIP-10 thread chat implementation enabling "chat nevent..." to
display kind 1 threaded conversations as chat interfaces.
**Type Definitions**:
- Add ThreadIdentifier for nevent/note event pointers
- Add "nip-10" to ChatProtocol type
- Extend ConversationMetadata with thread-specific fields (rootEventId,
providedEventId, threadDepth, relays)
**NIP-10 Adapter** (src/lib/chat/adapters/nip-10-adapter.ts):
- parseIdentifier: Decode nevent/note format, reject non-kind-1 events
- resolveConversation: Fetch provided event, find root via NIP-10 refs,
determine conversation relays (merge hints, outbox, fallbacks)
- loadMessages: Subscribe to kind 1 replies, kind 7 reactions, kind 9735 zaps
- sendMessage: Build proper NIP-10 tags (root/reply markers), add p-tags for
all participants
- sendReaction: Send kind 7 with proper event/author references
- Smart relay selection: Merges seen relays, nevent hints, author outbox,
user outbox (limit 7 relays for performance)
**ChatViewer Updates**:
- Detect NIP-10 threads (protocol === "nip-10")
- Fetch and display root event at top (centered with KindRenderer)
- Show visual separator ("Replies") between root and messages
- Update empty state message for threads ("No replies yet...")
- Enhanced header: Show "Author • Preview" for thread chats
- Update getAdapter to handle "nip-10" protocol
**Chat Parser**:
- Add Nip10Adapter to priority list (before other adapters to catch
nevent/note)
- Update error message with nevent/note format examples
- Update adapter priority documentation
**Component Enhancements**:
- ReplyPreview: Show "thread root" when replying to root event (NIP-10)
- RelaysDropdown: Support conversation.metadata.relays for thread relay
breakdown
- ChatMessageContextMenu: Add "Zap" option to context menu (opens ZapWindow)
**Features**:
- Root event displayed with full feed renderer (can interact: like, zap, etc.)
- All replies shown as chat messages with proper threading
- Reply/React/Zap options on all messages
- Relay dropdown shows breakdown of thread relays
- Participants dropdown shows all thread participants
- @ mention autocomplete works for participants
- Proper NIP-10 tag structure for nested replies
- Smart relay selection for maximum reach
**Usage**:
chat nevent1qqsxyz... # Thread with relay hints
chat note1abc... # Thread with event ID only
Root event is centered at top, all replies below as chat messages. Sending
replies creates kind 1 events with proper NIP-10 root/reply markers and
p-tags for all participants.
* fix: remove unused imports and mark intentionally unused parameter
- Remove unused getTagValues import
- Prefix providedEvent parameter with underscore to indicate intentional non-use (reserved for future relay hint extraction)
* feat: hide reply preview when directly replying to root in NIP-10 threads
In NIP-10 thread chats, the root event is already displayed prominently at
the top, so showing a reply preview when replying directly to the root is
redundant.
Changes:
- Skip reply preview for regular messages when replying to thread root
- Skip reply preview for zap messages when zapping the thread root
- Root event remains visible at top as reference point
This reduces visual clutter and makes the chat feel cleaner when replies
are directed at the already-visible root post.
* refactor: simplify NIP-10 thread chat implementation
Major simplifications based on user feedback:
- Render root event as regular message instead of special feed renderer
- Remove special-case logic for hiding reply preview when replying to root
- Include root event in messages list using RxJS combineLatest
- Change root author role from "admin" to "op" (original poster)
- Fix NIP-10 protocol link handler in chat header
- Add "Chat" option to event context menu for kind 1 events
- Fix unused parameter warnings in nip-10-adapter
This refactoring reduces complexity and makes NIP-10 threads behave
more consistently with other chat protocols.
* feat: add zap support for NIP-10 thread chat messages
Implement getZapConfig method to enable zapping messages in NIP-10 threads:
- Returns message author as recipient
- Includes event pointer for the message being zapped
- Uses conversation metadata relays for zap receipt publishing
- Integrates with new zap infrastructure from main branch
* fix: pass protocol and identifier directly to chat window
Fix 'undefined protocol' error when opening chat from event menu.
Instead of passing raw nevent as args, directly pass the parsed
protocol and identifier props that ChatViewer expects.
* debug: add logging to diagnose chat protocol issue
Add console logging to:
- chat command argParser to see input args and parsed result
- ChatViewer to see received props
This will help diagnose why 'undefined protocol' error appears
when opening chat via command or event menu.
* refactor: improve NIP-10 thread chat UX and relay/participant handling
UI Improvements:
- Remove "thread root" marker from reply previews - treat all replies uniformly
- Hide "load older messages" for NIP-10 threads (all replies loaded reactively)
- Display "Thread" with note icon instead of "Group" for NIP-10 conversations
- Remove debug logging from chat command parser and ChatViewer
Participant Management:
- Derive participants dynamically from messages (like live-chat does)
- Root author (OP) always listed first with "op" role
- All unique message authors included in member list
- Updates in real-time as new people reply
Relay Management:
- Expand relay collection to include participant outbox relays
- Fetch relays from root author, provided event author, and p-tagged participants
- Check up to 5 participants for relay diversity
- Increase max relay limit from 7 to 10 for better coverage
- Add logging for relay collection debugging
This makes NIP-10 threads feel more like proper chat conversations with
accurate participant lists and better relay coverage across the thread.
* refactor: remove debug logging from NIP-10 adapter
Remove informational console.log statements to reduce noise in production.
Keep only console.warn and console.error for actual problems.
This makes the adapter production-ready while maintaining useful error
and warning messages for debugging issues.
* fix: resolve lint errors from logging cleanup
- Fix empty block statement by simplifying next handler
- Prefix unused parameters with underscore (_response, _err)
- All lint checks now pass with 0 errors
* refactor: use AGGREGATOR_RELAYS constant and remove design docs
Replace hardcoded relay URLs with AGGREGATOR_RELAYS constant:
- Import AGGREGATOR_RELAYS from @/services/loaders
- Use constant for fallback relays in getThreadRelays()
- Use constant for default relays in getDefaultRelays()
Remove design documentation files (no longer needed):
- docs/nip10-thread-chat-design.md
- docs/nip10-thread-chat-examples.md
- docs/nip10-thread-chat-summary.md
This improves maintainability by centralizing relay configuration
and reduces repository clutter.
* refactor: remove relay.nostr.band and update AGGREGATOR_RELAYS
relay.nostr.band is no longer operational, so remove it from the codebase:
AGGREGATOR_RELAYS changes:
- Removed: wss://relay.nostr.band/
- Removed: wss://purplepag.es/
- Added: wss://relay.snort.social/
- Added: wss://relay.damus.io/
- New list: nos.lol, relay.snort.social, relay.primal.net, relay.damus.io
Updated code:
- src/services/loaders.ts: Updated AGGREGATOR_RELAYS constant
- src/lib/chat/adapters/nip-53-adapter.ts: Use AGGREGATOR_RELAYS instead of hardcoded relays
Updated tests:
- All test files updated to expect new relay URLs
- Replaced relay.nostr.band references with relay.snort.social
- Replaced purplepag.es references with relay.snort.social
- Fixed URL formats to include trailing slashes for normalization
All 980 tests passing ✓
* fix: change grimRelays from let to const in supporters.ts
Fix lint error from rebase - grimRelays is never reassigned so it should
use const instead of let.
* style: reduce padding on sign-in message to match composer
Change from px-3 py-2 to px-2 py-1 to match the horizontal and vertical
padding of the logged-in message composer (px-2 py-1), ensuring
consistent height between logged-in and logged-out states.
* feat: make sign-in message clickable to open login dialog
Add clickable 'Sign in' link to the logged-out message composer:
- Import LoginDialog component
- Add showLogin state management
- Make 'Sign in' text an underlined button that opens the login dialog
- Add LoginDialog component with controlled state
This provides a better UX by allowing users to quickly sign in
directly from the chat interface.
---------
Co-authored-by: Claude <noreply@anthropic.com>
|
||
|
|
c4687da3ef |
Add multi-room group chat support (#70)
* feat: add multi-room group chat interface (GroupListViewer) Add a Discord/Slack-style multi-room chat interface for NIP-29 groups: - New GroupListViewer component with split layout: - Left panel: List of groups from kind 10009, sorted by recency - Right panel: Full chat view for selected group - Loads group metadata (kind 39000) for icons and names - Tracks latest messages (kind 9) for activity-based sorting |
||
|
|
5bc89386ea |
Add NIP-53 live event chat adapter (#56)
* feat: add NIP-53 live activity chat adapter Add support for joining live stream chat via naddr (kind 30311): - Create Nip53Adapter with parseIdentifier, resolveConversation, loadMessages, sendMessage - Show live activity status badge (LIVE/UPCOMING/ENDED) in chat header - Display host name and stream metadata from the live activity event - Support kind 1311 live chat messages with a-tag references - Use relays from activity's relays tag or naddr relay hints - Add tests for adapter identifier parsing and chat-parser integration * ui: derive live chat participants from messages, icon-only status badge - Derive participants list from unique pubkeys in chat messages for NIP-53 - Move status badge after title with hideLabel for compact icon-only display * feat: show zaps in NIP-53 live chat with gradient border - Fetch kind 9735 zaps with #a tag matching the live activity - Combine zaps and chat messages in the timeline, sorted by timestamp - Display zap messages with gradient border (yellow → orange → purple → cyan) - Show zapper, amount, recipient, and optional comment - Add "zap" message type with zapAmount and zapRecipient metadata * fix: use RichText for zap comments and remove arrow in chat - Use RichText with zap request event for zap comments (renders emoji tags) - Remove the arrow (→) between zapper and recipient in zap messages * refactor: simplify zap message rendering in chat - Put timestamp right next to recipient (removed ml-auto) - Use RichText with content prop and event for emoji resolution - Inline simple expressions, remove unnecessary variables - Follow codebase patterns from ZapCompactPreview * docs: update chat command to include NIP-53 live activity - Update synopsis to use generic <identifier> - Add NIP-53 live activity chat to description - Update option description to cover both protocols - Add naddr example for live activity chat - Add 'live' to seeAlso references * fix: use host outbox relays for NIP-53 live chat events Combine activity relays, naddr hints, and host's outbox relays when subscribing to chat messages and zaps. This ensures events are fetched from all relevant sources where they may be published. * ui: show host first in members list, all relays in dropdown - derivedParticipants now puts host first with 'host' role - Other participants from messages follow as 'member' - RelaysDropdown shows all NIP-53 liveActivity.relays --------- Co-authored-by: Claude <noreply@anthropic.com> |
||
|
|
0b20a628e2 |
feat: add mention editor and NIP-29 chat enhancements
Implements rich text editing with profile mentions, NIP-29 system messages, day markers, and naddr support for a more complete chat experience. Editor Features: - TipTap-based rich text editor with @mention autocomplete - FlexSearch-powered profile search (case-insensitive) - Converts mentions to nostr:npub URIs on submission - Keyboard navigation (Arrow keys, Enter, Escape) - Fixed Enter key and Send button submission NIP-29 Chat Improvements: - System messages for join/leave events (kinds 9000, 9001, 9021, 9022) - Styled system messages aligned left with muted text - Shows "joined" instead of "was added" for consistency - Accepts kind 39000 naddr (group metadata addresses) - Day markers between messages from different days - Day markers use locale-aware formatting (short month, no year) Components: - src/components/editor/MentionEditor.tsx - TipTap editor with mention support - src/components/editor/ProfileSuggestionList.tsx - Autocomplete dropdown - src/services/profile-search.ts - FlexSearch service for profile indexing - src/hooks/useProfileSearch.ts - React hook for profile search Dependencies: - @tiptap/react, @tiptap/starter-kit, @tiptap/extension-mention - @tiptap/extension-placeholder, @tiptap/suggestion - flexsearch@0.7.43, tippy.js@6.3.7 Tests: - Added 6 new tests for naddr parsing in NIP-29 adapter - All 710 tests passing Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> |
||
|
|
6d01ee33ef |
feat: implement unified chat system with NIP-C7 and NIP-29 support
Core Architecture: - Protocol adapter pattern for chat implementations - Base adapter interface with protocol-specific implementations - Auto-detection of protocol from identifier format - Reactive message loading via EventStore observables Protocol Implementations: - NIP-C7 adapter: Simple chat (kind 9) with npub/nprofile support - NIP-29 adapter: Relay-based groups with member roles and moderation - Protocol-aware reply message loading with relay hints - Proper NIP-29 members/admins fetching using #d tags UI Components: - ChatViewer: Main chat interface with virtualized message timeline - ChatMessage: Message rendering with reply preview - ReplyPreview: Auto-loading replied-to messages from relays - MembersDropdown: Virtualized member list with role labels - RelaysDropdown: Connection status for chat relays - ChatComposer: Message input with send functionality Command System: - chat command with identifier parsing and auto-detection - Support for npub, nprofile, NIP-05, and relay'group-id formats - Integration with window system and dynamic titles NIP-29 Specific: - Fetch kind:39000 (metadata), kind:39001 (admins), kind:39002 (members) - Extract roles from p tags: ["p", "<pubkey>", "<role1>", "<role2>"] - Role normalization (admin, moderator, host, member) - Single group relay connection management Testing: - Comprehensive chat parser tests - Protocol adapter test structure - All tests passing (704 tests) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> |