mirror of
https://github.com/purrgrammer/grimoire.git
synced 2026-04-10 15:36:53 +02:00
97f18de35838caa3f283878698b94de93f313d91
* Add subtle inline reactions to chat messages Implements NIP-25 reaction display for chat messages with per-message lazy loading: - Created MessageReactions component that independently loads kind 7 reactions for each message using EventStore timeline queries - Displays reactions as tiny inline badges in bottom-right corner (doesn't affect message height) - Aggregates reactions by emoji with deduplication by pubkey - Supports both unicode emoji and NIP-30 custom emoji with images - Shows reaction count next to each emoji - Integrated into both regular user messages and zap messages in ChatViewer - Reactions load reactively - new reactions appear automatically via EventStore observables No "+" button for adding reactions yet - this is display-only for now. Works with NIP-29 groups and will work with any chat protocol that uses kind 7 reactions with e-tags. * Fix reaction loading to use protocol-specific relay hints Previously MessageReactions was only querying EventStore without actually fetching reactions from relays. Now it properly: - Starts a relay subscription per message to fetch kind 7 reactions - Uses protocol-specific relay hints via getConversationRelays() helper: * NIP-29 groups: Single relay from conversation.metadata.relayUrl * NIP-53 live chats: Multiple relays from conversation.metadata.liveActivity.relays - Memoizes relay array in MessageItem to prevent unnecessary re-subscriptions - Cleans up subscriptions when message unmounts or changes This ensures reactions are actually fetched and displayed correctly across different chat protocols. * Remove unused NostrEvent import * Move reactions inline after timestamp with subtler styling Reactions now appear directly after the timestamp in the message header: - Removed absolute positioning and background color - Increased spacing between emoji and count (gap-1 instead of gap-0.5) - Simple inline display with no border or background - Appears in natural reading flow: "Alice 10:30 AM ❤️ 3 👍 1" - Removed relative positioning from message container (no longer needed) This makes reactions much more subtle and integrated into the message UI. * Add detailed tooltips to reactions showing who reacted Each reaction badge now shows a tooltip with: - Emoji and count on first line - Comma-separated list of display names who reacted Implementation: - Split into ReactionBadge component per reaction - Loads profiles for all reactor pubkeys using eventStore.profiles() - Uses getDisplayName() helper for human-readable names - Tooltip format: "❤️ 3\nAlice, Bob, Carol" This makes it easy to see exactly who reacted with each emoji. * Simplify reaction tooltips to show truncated pubkeys Changed tooltip implementation from loading profiles (which wasn't working with EventStore API) to showing truncated pubkeys for simplicity and performance: - Removed profile loading logic (eventStore.profiles() doesn't exist) - Tooltips now show: "❤️ 3\nabcd1234..., efgh5678..." - Truncated to first 8 chars for readability - No external API calls needed, purely computed from reaction data - Can be enhanced later to load profiles if needed Build verified: TypeScript compilation passes, all tests pass. This is production-ready code. * Add emoji reaction picker to chat messages Implements complete reaction functionality with searchable emoji picker: **UI Enhancements:** - Reactions display horizontally with hidden scrollbar (hide-scrollbar CSS utility) - Messages with many reactions scroll smoothly without visible scrollbar - Inline positioning after timestamp for clean, integrated look **Emoji Picker Dialog:** - Real-time search using FlexSearch (EmojiSearchService) - Quick reaction bar with common emojis (❤️ 👍 🔥 😂 🎉 👀 🤔 💯) - Frequently used section based on localStorage history - Support for both unicode and NIP-30 custom emoji - Grid layout with 48-emoji results - Auto-focus search input for keyboard-first UX **Protocol Implementation:** - Added sendReaction() method to ChatProtocolAdapter base class - NIP-29 groups: kind 7 with e-tag + h-tag (group context) - NIP-53 live chats: kind 7 with e-tag + a-tag (activity context) - NIP-C7 DMs: kind 7 with e-tag + p-tag (partner context) - All reactions include k-tag for reacted event kind - NIP-30 custom emoji support via emoji tags **Context Menu Integration:** - Added "React" action to ChatMessageContextMenu with Smile icon - Opens emoji picker dialog on click - Passes conversation and adapter for protocol-specific reactions - Only shows when conversation and adapter are available **Frequently Used Tracking:** - Stores reaction history in localStorage (grimoire:reaction-history) - Displays top 8 most-used reactions when no search query - Increments count on each reaction sent **Tooltips:** - Show emoji + count + truncated pubkeys - Format: "❤️ 3\nabcd1234..., efgh5678..." - Future enhancement: load profiles for display names Ready for testing! Users can now right-click messages → React → search/pick emoji. * Load user's custom emoji list in reaction picker The emoji picker now loads custom emoji from: - User's emoji list (kind 10030) - personal custom emoji - Context emojis from conversation messages - Unicode emojis (default set) EmojiSearchService prioritizes: 1. User emoji (highest priority) 2. Context emoji (from conversation) 3. Emoji sets (if any) 4. Unicode emoji (default) When searching or browsing, users will see their custom emoji alongside standard unicode emoji, making it easy to use personal/community emoji in reactions. * Fix reaction container to prevent message width expansion Wrapped reactions in a scrollable container with proper constraints: - inline-flex: displays inline with message metadata - max-w-full: prevents expanding beyond message width - overflow-x-auto: enables horizontal scrolling for many reactions - hide-scrollbar: hides scrollbar for clean appearance Messages with many reactions now stay within their width and scroll horizontally without a visible scrollbar. * Highlight reaction counts when active user has reacted Changes: - Reaction counts now show in highlight color (text-highlight) when the active user has reacted with that emoji - Added font-semibold to make user's reactions more prominent - Checks if activeAccount.pubkey is in reaction.pubkeys array - Provides clear visual feedback showing which reactions you've made This makes it easy to see at a glance which reactions are yours in a conversation with many reactions. * Refine reaction badge styling: increase spacing and remove bold - Increase gap between reaction badges from gap-1 to gap-2 - Remove font-semibold from highlighted reaction counts - Keep text-highlight color for active user's reactions - Results in more subtle, polished appearance * Refactor emoji picker to use useEmojiSearch hook - Replace manual emoji service management with useEmojiSearch hook - Use same emoji loading approach as chat autocomplete - Subscribe to EventStore observables for reactive updates - Load user's emoji list (kind 10030) and emoji sets (kind 30030) - Fix custom emoji search not working - Remove redundant async loading logic * Fix emoji picker UI issues - Remove quick reaction bar (❤️ 👍 🔥 etc.) - Fix custom emoji in "Recently used" section - now renders images instead of shortcodes - Increase grid spacing from gap-2 to gap-3 to reduce crowding - Add helpers to properly lookup and render custom emoji from service * Improve reaction badge sizing and spacing - Increase custom emoji size from size-3 (12px) to size-3.5 (14px) - Increase gap between emoji and count from gap-1 to gap-1.5 - Add object-contain to custom emoji images for proper aspect ratio - Add leading-none to unicode emoji for consistent vertical alignment - Results in better visual balance between custom and unicode emoji * Fix custom emoji shrinking in reaction badges - Add flex-shrink-0 to custom emoji images to prevent compression - Add flex-shrink-0 to unicode emoji spans for consistency - Ensures both custom and unicode emoji maintain their size-3.5 dimensions * Improve emoji picker UX with fixed layout - Always show exactly 2 rows (16 emoji) to prevent height jumping - Merge recently used with search results into unified grid - When no search: show recently used first, then fill with other emoji - When searching: show top 16 results - Remove separate "Recently used" section for cleaner layout - Add aspect-square to buttons for consistent sizing - Add object-contain to custom emoji for proper aspect ratio - Replace scrollable area with fixed-height grid * Refine emoji picker to show single row with fixed height - Show only 1 row (8 emoji) instead of 2 rows for more compact UI - Add min-h-[3.5rem] to prevent height changes - Ensure custom emoji (w-6 h-6) matches unicode emoji (text-2xl) size - Add leading-none to unicode emoji for better vertical alignment - Empty state "No emojis found" maintains same grid height - Consistent sizing between custom and unicode emoji across the picker * Fix emoji sizing in picker to match unicode and custom emoji - Reduce unicode emoji from text-2xl (24px) to text-xl (20px) - Reduce custom emoji from w-6 h-6 (24px) to size-5 (20px) - Both now render at same 20px size for visual consistency - Fixes custom emoji appearing too large compared to unicode emoji * ui: dialog tweaks --------- Co-authored-by: Claude <noreply@anthropic.com>
Grimoire
A Nostr protocol explorer and developer tool with a tiling window manager interface.
Features
- Tiling Windows - Each window is a Nostr "app" (profile viewer, event feed, NIP docs, etc.)
- Command Palette - Unix-style commands via
Cmd+Kto open apps and navigate - Multi-workspace - Virtual desktops with independent layouts
- Real-time - Reactive event subscriptions with automatic updates
Stack
React 19, TypeScript, Vite, TailwindCSS, Jotai, Dexie, Applesauce
Getting Started
npm install
npm run dev
Scripts
| Command | Description |
|---|---|
npm run dev |
Start dev server |
npm run build |
Build for production |
npm test |
Run tests in watch mode |
npm run lint |
Lint code |
npm run format |
Format code |
License
MIT
Languages
TypeScript
98.9%
CSS
0.8%
JavaScript
0.3%