mirror of
https://github.com/purrgrammer/grimoire.git
synced 2026-04-12 16:37:06 +02:00
ca58a4e7c3500d7c42aa8fa135f54de77b862331
25 Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
3f811ed072 |
feat: zap action for chat (#151)
* feat: add configurable zap tagging for chat messages Implements a protocol adapter interface for configuring how zap requests should be tagged for chat messages. This enables proper NIP-53 live activity zapping with appropriate a-tag and goal e-tag support. Changes: - Add ZapConfig interface to base-adapter for protocol-specific zap configuration - Add getZapConfig() method to ChatProtocolAdapter (default: unsupported) - Implement getZapConfig() in NIP-53 adapter with proper tagging: - Always a-tag the live activity (kind 30311) - If zapping host with goal, also e-tag the goal event - Add goal tag parsing to live-activity.ts and types - Update createZapRequest to accept custom tags parameter - Add Zap action to ChatMessageContextMenu (shown when supported) - Update ZapWindow to pass custom tags through to zap request - NIP-29 groups inherit default (unsupported) behavior * feat: add custom tags and relays to zap command Extends the zap command to support custom tags and relay specification, enabling full translation from chat zap config to zap command. Changes: - Add -T/--tag flag to specify custom tags (type, value, optional relay hint) - Add -r/--relay flag to specify where zap receipt should be published - Update ZapWindow to accept and pass through relays prop - Update ChatMessageContextMenu to pass relays from zapConfig - Update man page with new options and examples - Add comprehensive tests for zap parser flag handling Example usage: zap npub... -T a 30311:pk:id wss://relay.example.com zap npub... -r wss://relay1.com -r wss://relay2.com * fix: include event pointer when zapping chat messages Pass the message event as eventPointer when opening ZapWindow from chat context menu. This enables: - Event preview in the zap window - Proper window title showing "Zap [username]" * feat: add zap command reconstruction for Edit feature Add zap case to command-reconstructor.ts so that clicking "Edit" on a zap window title shows a complete command with: - Recipient as npub - Event pointer as nevent/naddr - Custom tags with -T flags - Relays with -r flags This enables users to see and modify the full zap configuration. * fix: separate eventPointer and addressPointer for proper zap tagging - Refactor createZapRequest to use separate eventPointer (for e-tag) and addressPointer (for a-tag) instead of a union type - Remove duplicate p-tag issue (only tag recipient, not event author) - Remove duplicate e-tag issue (only one e-tag with relay hint if available) - Update ZapConfig interface to include addressPointer field - Update NIP-53 adapter to return addressPointer for live activity context - Update ChatMessageContextMenu to pass addressPointer from zapConfig - Update command-reconstructor to properly serialize addressPointer as -T a - Update ZapWindow to pass addressPointer to createZapRequest This ensures proper NIP-53 zap tagging: message author gets p-tag, live activity gets a-tag, and message event gets e-tag (all separate). * refactor: move eventPointer to ZapConfig for NIP-53 adapter - Add eventPointer field to ZapConfig interface for message e-tag - NIP-53 adapter now returns eventPointer from getZapConfig - ChatMessageContextMenu uses eventPointer from zapConfig directly - Remove goal logic from NIP-53 zap config (simplify for now) This gives the adapter full control over zap configuration, including which event to reference in the e-tag. * fix: update zap-parser to return separate eventPointer and addressPointer The ParsedZapCommand interface now properly separates: - eventPointer: for regular events (nevent, note, hex ID) → e-tag - addressPointer: for addressable events (naddr) → a-tag This aligns with ZapWindowProps which expects separate fields, fixing the issue where addressPointer from naddr was being passed as eventPointer and ignored. * feat: improve relay selection for zap requests with e+a tags When both eventPointer and addressPointer are provided: - Collect outbox relays from both semantic authors - Include relay hints from both pointers - Deduplicate and use combined relay set Priority order: 1. Explicit params.relays (respects CLI -r flags) 2. Semantic author outbox relays + pointer relay hints 3. Sender read relays (fallback) 4. Aggregator relays (final fallback) * fix: pass all zap props from WindowRenderer to ZapWindow WindowRenderer was only passing recipientPubkey and eventPointer, dropping addressPointer, customTags, and relays. This caused CLI flags like -T (custom tags) and -r (relays) to be ignored. Now all parsed zap command props flow through to ZapWindow and subsequently to createZapRequest. * refactor: let createZapRequest collect relays from both authors Remove top-level relays from NIP-53 zapConfig so createZapRequest can automatically collect outbox relays from both: - eventPointer.author (message author / zap recipient) - addressPointer.pubkey (stream host) The relay hints in the pointers are still included via the existing logic in createZapRequest. * fix: deduplicate explicit relays in createZapRequest Ensure params.relays is deduplicated before use, not just the automatically collected relays. This handles cases where CLI -r flags might specify duplicate relay URLs. --------- Co-authored-by: Claude <noreply@anthropic.com> |
||
|
|
72fb47224c |
feat: add NIP-57 zap command foundation (#141)
* feat: add NIP-57 zap command foundation Implements the foundational structure for sending Lightning zaps (NIP-57) to Nostr users and events. This commit adds the command interface, UI components, and routing logic. The actual LNURL resolution and zap request creation will be implemented in follow-up commits. Components Added: - ZapWindow: Full-featured UI for zapping with amount presets, custom amounts, wallet integration, and QR code fallback - parseZapCommand: Parser supporting multiple formats (npub, nprofile, nevent, naddr, NIP-05, $me alias) - Command registration in man pages with examples - Window routing and title generation Features: - Preset amount buttons (21, 100, 500, 1000, 5000, 10000 sats) - Custom amount input - Amount usage tracking (remembers most-used amounts) - Comment field for zap messages - Event context rendering (shows zapped event in UI) - Dual payment methods: NWC wallet or QR code/invoice copy - Dynamic recipient resolution (from event author if zapping event) Usage: zap fiatjaf.com # Zap a user by NIP-05 zap npub1... # Zap a user by npub zap nevent1... # Zap an event (recipient = author) zap npub1... nevent1... # Zap specific user for specific event Next Steps: - Implement LNURL-pay resolution (fetch callback URL and nostrPubkey) - Create kind 9734 zap request event with applesauce factory - Implement invoice generation via LNURL callback - Integrate NWC wallet payment - Add zap action to event context menus - Implement zap receipt listening (kind 9735) * feat: implement full NIP-57 zap flow with LNURL and NWC Completes the production-ready implementation of Lightning zaps (NIP-57) with full LNURL-pay resolution, zap request creation, NWC wallet payment, and QR code fallback. Core Implementation: 1. **LNURL Resolution** (src/lib/lnurl.ts) - Resolve Lightning addresses (lud16) to LNURL-pay endpoints - Validate zap support (allowsNostr, nostrPubkey) - Fetch invoices from LNURL callbacks with zap requests - Amount validation (min/max sendable) - Comment length validation 2. **Zap Request Creation** (src/lib/create-zap-request.ts) - Build kind 9734 zap request events using applesauce EventFactory - Sign with user's active account - Include recipient (p tag), amount, relays, optional event context (e/a tags) - Serialize to URL-encoded JSON for LNURL callbacks - Smart relay selection (user's inbox relays for zap receipts) 3. **ZapWindow Complete Flow** (src/components/ZapWindow.tsx) - Resolve recipient's Lightning address from profile (lud16) - Create and sign zap request with user credentials - Fetch invoice from LNURL callback - Pay with NWC wallet OR show QR code - QR code generation with qrcode library - Success feedback with LNURL success actions - Comprehensive error handling and user notifications - Toast notifications for each step 4. **Event Menu Integration** (src/components/nostr/kinds/BaseEventRenderer.tsx) - Add "Zap" action to event dropdown menu - Automatically includes event context (e or a tag) - Yellow zap icon (⚡) for visual consistency - Opens ZapWindow with pre-filled recipient and event Flow Diagram: 1. User clicks "Zap" on event or runs `zap` command 2. Resolve recipient's lud16 → LNURL-pay endpoint 3. Validate zap support (allowsNostr, nostrPubkey) 4. Create kind 9734 zap request (signed by sender) 5. Send to LNURL callback → get BOLT11 invoice 6. Pay via NWC wallet OR show QR code 7. Zap receipt (kind 9735) published by LNURL service Features: - ✅ Full NIP-57 compliance - ✅ LNURL-pay support with validation - ✅ Applesauce EventFactory for signing - ✅ NWC wallet integration - ✅ QR code fallback for manual payment - ✅ Event context (zapping specific notes/articles) - ✅ Amount presets with usage tracking - ✅ Custom amounts and comments - ✅ Comprehensive error handling - ✅ Step-by-step user feedback - ✅ Event menu integration Security: - Uses user's active account signer - Validates LNURL responses - Validates amount ranges - No private key exposure - HTTPS-only LNURL endpoints Dependencies: - qrcode: QR code generation - applesauce-core: EventFactory for signing - Existing NWC wallet implementation Related: #135 (NWC wallet viewer) Implements: NIP-57 (Lightning Zaps) * fix: resolve TypeScript errors in ZapWindow - Remove unused imports (useEffect, isAddressableKind, NostrEvent) - Fix walletInfo access: fetch from getInfo() hook instead of direct property - Store wallet info in component state with useEffect - All TypeScript syntax errors resolved * fix: resolve all TypeScript build errors in zap implementation - ZapWindow.tsx: Import useProfile from @/hooks/useProfile instead of applesauce-react/hooks - ZapWindow.tsx: Remove Tabs import (unused) - ZapWindow.tsx: Remove htmlFor prop from Label components (not supported) - create-zap-request.ts: Remove non-existent EventTemplate import - create-zap-request.ts: Use inferred type for template object - lnurl.ts: Prefix unused lnurl parameter with underscore All TypeScript compilation errors resolved. Code ready for production build. * fix: correct useProfile usage and ProfileContent handling in ZapWindow - Remove eventStore argument from useProfile (takes pubkey and optional relay hints) - Fix recipientProfile usage: already ProfileContent, don't call getProfileContent again - Fix authorProfile: call getProfileContent on NostrEvent, not on ProfileContent - Fix lud16/lud06 access: use recipientProfile directly - Fix success toast: use recipientProfile?.name instead of content?.name All type errors resolved. ProfileContent is returned by useProfile, not NostrEvent. * feat: refine ZapWindow UI and add dynamic window title UI Refinements per user request: - Remove QrCode unused import - Simplify payment flow to single adaptive button - Button shows "Log in to Zap" if user can't sign - Button shows "Pay with Wallet" if NWC available, else "Pay" - Fix activeAccount usage to use accountManager.active - Remove unused getProfileContent import - Remove unused eventAuthorName variable Dynamic Title: - Add "Zap [username]" dynamic title in DynamicWindowTitle - Fetches recipient profile and displays name or fallback - Shows recipient's display name, name, or truncated pubkey Build fixes: - Fix TypeScript errors with unused imports - Fix activeAccount.signer property access - All tests passing (939 passed) * feat: add emoji autocompletion to zap comments and refine UI Zap Comment Enhancements: - Replace plain Input with MentionEditor for emoji autocompletion - Add NIP-30 emoji tag support to zap requests (kind 9734) - Emoji tags are properly serialized and included in zap events - Support :emoji: syntax with custom emoji from emoji search Event Preview Refinements: - Remove Card wrapper from zapped event preview - Remove padding and borders for cleaner display - Event renders directly without container styling Implementation Details: - Add EmojiTag interface to create-zap-request.ts - Update ZapRequestParams to include emojiTags array - Extract emoji tags from MentionEditor in handleZap - Pass emoji tags through zap request creation pipeline - Add useProfileSearch and useEmojiSearch hooks to ZapWindow - Use MentionEditor ref to get serialized content with emojis All tests passing (939 passed) Build successful * feat: compact ZapWindow UI and improve debugging UI Improvements: - Reduce padding from p-6 to p-4 and space-y-6 to space-y-3 - Convert amount grid to single-row flex layout with gap-1.5 - Add formatAmount() helper for shortened numbers (21, 1k, 5k, 10k) - Move custom amount input inline with preset amounts - Reduce button size to "sm" for more compact display - Remove separate label for custom amount - Make comment field more compact (removed min-height) Debugging Enhancements: - Add console.log for recipient profile and lud16/lud06 - Add logging for LNURL resolution steps - Add logging for zap request creation - Add logging for invoice fetch from callback - Add debug logging for emoji search service initialization - Test emoji search on mount to verify it's working Number Format: - 21 → "21" - 1000 → "1k" - 5000 → "5k" - 10000 → "10k" - Handles decimals: 1500 → "1.5k" The compact layout makes better use of vertical space and provides comprehensive debug logging to help troubleshoot LNURL and emoji issues. All tests passing (939 passed) Build successful * fix: open LoginDialog instead of connection window for zap login Changes: - Import LoginDialog component into ZapWindow - Add showLogin state to control LoginDialog visibility - Update handleLogin to open LoginDialog instead of connection window - Remove unused useGrimoire import and addWindow destructuring - Add LoginDialog component to render alongside QR dialog User Experience: - "Log in to Zap" button now opens proper login dialog - Users can log in with extension, readonly, nsec, or NIP-46 - After login, user can proceed with zap flow - More intuitive than opening relay connection window All tests passing (939 passed) Build successful * feat: auto-close ZapWindow after successful wallet payment Changes: - Add onClose callback prop to ZapWindowProps interface - Pass onClose from WindowRenderer to ZapWindow component - Call onClose() with 1.5s delay after successful wallet payment - Allow user to see success toast before window closes User Experience: - After zapping with wallet, window automatically closes - 1.5 second delay allows user to see success message - Prevents accidental double-zapping - Cleaner flow - no manual window closing needed Implementation: - WindowRenderer passes onClose callback to ZapWindow - ZapWindow calls onClose after payment success and toasts - setTimeout(onClose, 1500) provides brief delay for UX - QR code path unchanged (window stays open for payment) All tests passing (939 passed) Build successful * feat: full-width custom amount and wallet timeout with QR fallback Custom Amount Input: - Change custom amount input from w-24 to flex-1 - Now takes full remaining width in flex row - Better UX on smaller screens and more obvious input field Wallet Payment Timeout Handling: - Add 30 second timeout to wallet payments using Promise.race - On timeout, automatically show QR code as fallback - Add paymentTimedOut state to track timeout condition - Toast warning when payment times out Retry with Wallet Feature: - Add handleRetryWallet function to retry timed out payment - Show "Retry with Wallet" button in QR dialog when timed out - Button only appears if wallet is connected and payment capable - Retry uses same 30s timeout, shows error if fails again - Provides loading state with spinner during retry User Flow: 1. User attempts wallet payment 2. If timeout after 30s, shows QR code automatically 3. User can scan QR to pay manually OR 4. User can click "Retry with Wallet" to try again 5. If retry times out, stays on QR for manual payment Implementation Details: - Promise.race between payInvoice and 30s timeout - Timeout throws Error("TIMEOUT") for easy detection - QR dialog conditionally shows retry button - Retry resets state and attempts payment again - Console logging for debugging timeout issues All tests passing (939 passed) Build successful * feat: production-ready zaps with manual close and profile integration Payment Flow Improvements: - Remove auto-close after successful payment - Change "Zap Sent!" button to "Done" button that requires user click - User must manually close window by clicking Done after payment - Retry payment also requires manual close after success Profile Viewer Integration: - Add Zap icon next to lightning address in ProfileViewer - Click zap icon to open ZapWindow for that profile - Yellow icon with hover effect for visual feedback - Integrates seamlessly with existing profile UI Production Cleanup: - Remove all debug console.log statements - Keep console.error for production error logging - Remove unused emojiService variable from useEmojiSearch - Fix Loader2 className typo (animate-spin) - Clean code ready for production deployment User Experience: 1. View profile with lightning address 2. Click yellow zap icon to open zap window 3. Enter amount and optional comment 4. Pay with wallet (or QR code if timeout) 5. See success message 6. Click "Done" to close window (manual control) Testing: - All lint checks pass (no errors, only warnings) - TypeScript build successful - All 939 tests passing - Production-ready code Code Quality: - No debug logging in production - Proper error handling maintained - Clean, maintainable code - Follows project conventions * fix: remove duplicate zapTitle condition in DynamicWindowTitle Removed duplicate zapTitle if-else branch at line 870 that was causing lint error. The first zapTitle condition at line 803 handles all cases, making the second occurrence unreachable. * feat: improve zap UX with inline QR and faster imports - Move imports to top level instead of dynamic imports for faster resolution - Show QR code inline in ZapWindow instead of separate dialog - Show recipient name and address when not zapping an event - Make Lightning address clickable in ProfileViewer with icon on left - Use recipientName consistently throughout zap flow This significantly reduces the "Resolving Lightning address..." delay and provides a cleaner, more integrated UX for viewing and paying invoices. * feat: optimize zap UX with better error handling and UI improvements LNURL improvements: - Add 10s timeouts to Lightning address resolution and invoice fetching - Better error messages with more context (response status, error text) - Handle AbortError for timeout scenarios UI improvements: - Bigger amount buttons (default size instead of sm) - Custom amount on separate line for better layout - Disable all zap UI when recipient has no Lightning address - Show clear warning when Lightning address is missing - Only show comment editor when Lightning address is available Toast cleanup: - Remove chatty info toasts ("Resolving...", "Creating...", "Fetching...") - Only show errors and success messages - Cleaner, less noisy UX This addresses common issues with LNURL requests timing out and makes the UI more responsive and informative when zaps cannot be sent. * feat: full-width custom amount and wallet timeout with QR fallback QR code improvements: - Add profile picture overlay in center of QR code (25% size, circular) - Remove redundant "Copy Invoice" button (keep icon button only) - Show "Open in Wallet" as full-width button UI improvements: - Use UserName component everywhere (clickable, styled, shows Grimoire members) - Custom amount now full-width on separate line - Better visual hierarchy Default amounts updated: - Changed from [21, 100, 500, 1000, 5000, 10000] - To [21, 420, 2100, 42000] - More aligned with common zap amounts The profile picture overlay helps users identify who they're zapping while maintaining QR code scannability. UserName component provides consistent styling and clickable profile links. --------- Co-authored-by: Claude <noreply@anthropic.com> |
||
|
|
3408872811 |
feat: add comprehensive NWC wallet viewer with dynamic UI (#135)
* feat: add comprehensive NWC wallet viewer with dynamic UI Implements a full-featured Lightning wallet interface using Nostr Wallet Connect (NWC/NIP-47) with method-based UI that adapts to wallet capabilities. **New Features:** - WalletViewer component with tabbed interface (Overview, Send, Receive, Transactions) - Real-time balance display with manual refresh - Send Lightning payments via BOLT11 invoices - Generate invoices with QR codes for receiving payments - Transaction history viewer (when supported by wallet) - Wallet info and capabilities display - Enhanced useWallet hook with additional NWC methods **Enhanced Methods:** - listTransactions() - View recent payment history - lookupInvoice() - Check invoice status by payment hash - payKeysend() - Direct keysend payments to node pubkeys **UI Features:** - Dynamic tabs based on wallet capabilities - QR code generation for invoices - Copy-to-clipboard for invoices - Error handling with user-friendly messages - Loading states for async operations - Empty states for no wallet connection **Command:** - New `wallet` command to open the wallet viewer **Technical Details:** - Integrates with existing NWC service singleton - Uses reactive balance$ observable for auto-updates - Proper TypeScript types aligned with applesauce-wallet-connect - Follows Grimoire patterns for window system integration - Lazy-loaded component for optimal bundle size All tests passing. Build verified. * refactor: redesign wallet UI to single-view layout with virtualized transactions Converts the tabbed wallet interface to a conventional single-view layout with improved UX and performance optimizations. **Layout Changes:** - Removed tabs in favor of single-page layout - Balance header at top with wallet name and refresh button - Side-by-side Send/Receive cards for quick access - Transaction history below with virtualized scrolling - Disconnect button at bottom of page **New Features:** - Connect Wallet button when no wallet is connected (opens dialog in-app) - Wallet capabilities shown in tooltip on info icon - Virtualized transaction list using react-virtuoso - Batched transaction loading (20 per batch) - Automatic "load more" when scrolling to bottom - Loading states for initial load and pagination - "No more transactions" message when exhausted **Performance Improvements:** - Virtualized list rendering for smooth scrolling with many transactions - Only renders visible transactions in viewport - Lazy loads additional batches on demand - Reduced initial load to 20 transactions instead of 50 **UX Improvements:** - More conventional wallet UI pattern - Send/Receive always visible (no tab switching) - QR code and invoice appear inline when generated - Info icon with tooltip for capabilities (cleaner than full card) - Disconnect option always accessible at bottom **Technical Details:** - Fixed transaction loading race condition with separate useEffect - Proper dependency tracking for loadMoreTransactions callback - Footer component in Virtuoso for loading/end states - Responsive grid layout for Send/Receive cards All tests passing. Build verified. * refactor: redesign wallet UI with ReqViewer-style header and dialogs Implements a cleaner, more consistent wallet UI matching Grimoire patterns. **Header Changes:** - ReqViewer-style compact header (border-b, px-4, py-2, font-mono, text-xs) - Left side: Wallet name · Balance with info tooltip - Right side: Icon-only action buttons (Receive, Send, Refresh) - All actions use tooltips for labels - Consistent spacing and typography with rest of app **Send/Receive as Dialogs:** - Removed always-visible Send/Receive cards - Converted to modal dialogs opened from header icons - Send dialog: Invoice input + optional amount override - Receive dialog: Two-step flow (generate → show QR + invoice) - "Generate Another" button to create multiple invoices without closing - Cleaner main view focused on transaction list **Transaction List Cleanup:** - Removed Card wrapper and extra padding - Direct virtualized list fills viewport - Removed "Transaction History" heading (redundant) - Added flex-shrink-0 to prevent transaction items from shrinking - Improved truncation handling for long descriptions - Hover effect for better interactivity - Footer messages use consistent border-b styling **Disconnect Button:** - Changed to destructive variant (red appearance) - Moved to footer with border-t - Full width for emphasis - Clearer visual indication of destructive action **UX Improvements:** - More screen space for transactions (primary content) - Consistent icon sizing (size-3 for header actions, size-4 for tx icons) - Better visual hierarchy with header actions - Dialog pattern matches other Grimoire components - Receive dialog stays open to show generated invoice **Technical Details:** - Proper dialog state management - Invoice QR with max-height scrolling for long invoices - Reset form state when closing dialogs - Maintained all existing functionality - Optimized for virtualized scrolling performance All tests passing. Build verified. * feat: final wallet UI improvements with prominent balance and enhanced UX Redesigns wallet viewer with cleaner layout and improved user experience. **Layout Changes:** - Big centered balance display (4xl font, prominent) - Large Send/Receive buttons below balance (side by side) - Single-line transaction items with better spacing - Info dropdown next to refresh button in header **Transaction List:** - Single-line compact design (description + time + amount) - No +/- signs on amounts (cleaner look) - Generic "Payment"/"Received" labels when description missing - Time displayed in compact format (HH:MM) - Day markers between days (Today/Yesterday/Jan 15) - Virtualized scrolling with batched loading **Info Dropdown:** - Wallet capabilities shown in dropdown (Info icon + ChevronDown) - Network information - Methods displayed as compact badges - Notifications support **User Menu Integration:** - Wallet option always visible (regardless of account status) - Clicking wallet opens wallet window (not info dialog) - Balance shown inline when connected - "Connect Wallet" option when not connected **Dialog Improvements:** - Send dialog with confirmation step - Receive dialog with payment detection - Auto-close on payment received - QR code with loading overlay during payment check **Visual Hierarchy:** - Header: Wallet name (left) | Info dropdown + Refresh (right) - Big centered balance with "sats" label - Prominent action buttons (Send default, Receive outline) - Clean transaction list with hover states - Destructive disconnect button in footer All tests passing ✅ Build verified ✅ * fix: replace AlertDialog with Dialog for disconnect confirmation - AlertDialog component doesn't exist in UI library - Use regular Dialog with custom footer buttons instead - All 929 tests passing, build successful * refine: wallet UI improvements based on feedback - Remove "sats" text from balance display - Swap send/receive button positions (receive left, send right) - Remove top border from transaction list - Remove timestamps from transaction list items - Add relay link to wallet info dropdown with external link icon - Change disconnect button to destructive color (always red) - Fix imports and remove unused formatTime function * feat: enhance send/receive flows with invoice parsing and auto-confirm Send flow improvements: - Parse BOLT11 invoices using light-bolt11-decoder - Auto-proceed to confirm step when valid invoice is entered - Show parsed amount and description in confirmation dialog - Validate invoice before allowing confirmation Receive flow improvements: - Fix invoice overflow with proper truncate display - Use nested div structure for single-line truncation All changes preserve type safety with proper Section type guards * feat: add Lightning address support and refine auto-confirm behavior Send flow enhancements: - Only auto-proceed to confirm if invoice has an amount (not for zero-amount invoices) - Add Lightning address (LNURL-pay) support with automatic resolution - Fetch invoice from Lightning address with amount validation - Show "Resolving..." loading state when processing Lightning addresses - Update UI labels and placeholders to indicate Lightning address support - Require amount field for Lightning address payments Lightning address flow: 1. Detect @ symbol in input (and not starting with "ln") 2. Validate amount is provided 3. Fetch LNURL-pay endpoint from .well-known/lnurlp/{username} 4. Check min/max sendable amounts 5. Request invoice from callback with specified amount 6. Parse and confirm invoice details Error handling: - Invalid Lightning address format - Failed to fetch Lightning address - Amount out of range (too small/too large) - Failed to generate invoice from callback * fix: UI improvements for wallet viewer and mobile receive flow Confirmation dialog improvements: - Remove yellow warning styles (border, background, icon) - Fix amount calculation: show proper sats conversion with Math.floor - Clean layout with key-value pairs instead of cluttered text - Show either invoice amount OR override amount (not both) Mobile receive flow improvements: - Large prominent "Copy Invoice" button (h-12, full width) - Invoice box now tappable to copy - Better touch targets for mobile users - Clearer label: "Invoice (tap to view)" Connection status: - Show green dot + "Connected" next to wallet name in header - Clear visual feedback that wallet is online Auto-launch wallet: - After successfully connecting wallet, automatically open wallet window - Added onConnected callback to ConnectWalletDialog - Wire up callback in user menu to call openWallet Code cleanup: - Remove unused AlertTriangle import * fix: correct amount handling and mobile invoice display Amount input fixes: - Changed from millisats to sats for user input - Updated label: "Amount (sats, optional)" - Fixed Lightning address resolution: no division, amount is already in sats - Fixed payInvoice: multiply by 1000 to convert sats to millisats for NWC - Fixed confirmation dialog: removed incorrect division by 1000 Before: User enters 1000 (meant as sats) → system treats as 1000000 millisats → sends 1000 sats After: User enters 1000 sats → system converts to 1000000 millisats → sends 1000 sats ✓ Invoice parsing was correct - already converting millisats to sats. The bug was in the confirmation display and amount submission. Mobile receive invoice fix: - Removed nested div with truncate (was causing overflow) - Changed to break-all + line-clamp-2 - Invoice now wraps properly on mobile (2 lines max) - Still tappable to copy * fix: convert sats to millisats when generating invoices Critical bug fix - we were generating nearly amountless invoices. Before: - User enters 1000 sats in UI - We passed 1000 to makeInvoice (thinking it's millisats) - Generated invoice for 1000 millisats = 1 sat After: - User enters 1000 sats in UI - We multiply by 1000 → 1,000,000 millisats - Generated invoice for 1,000,000 millisats = 1000 sats ✓ This matches the send flow where we also convert sats to millisats before passing to NWC protocol. * refactor: production-readiness improvements for WalletViewer Critical fixes: - Wrap loadWalletInfo and loadInitialTransactions in useCallback to prevent infinite loops - Fix dependency arrays in useEffect hooks - Fix early return bug in handleConfirmSend that left sending state stuck - Add async/await error handling to handleCopyInvoice - Change throw new Error instead of early return in Lightning address resolution Performance optimizations: - Removed duplicate function definitions (moved to useCallback hooks) - Proper memoization of wallet loading functions Code quality: - All functions properly handle errors with try/catch - Loading states properly reset in finally blocks - No memory leaks from useEffect dependencies * fix: prevent infinite transaction loading loop in WalletViewer Previously, the transaction list would try to load constantly and fail repeatedly due to a circular dependency in the useEffect hooks. The listTransactions function from useWallet wasn't wrapped in useCallback, causing loadInitialTransactions to be recreated on every render, which triggered the useEffect infinitely. Changes: - Add txLoadAttempted and txLoadFailed flags to prevent repeated attempts - Only attempt to load transactions once on wallet connection - Fail silently on initial load (no toast spam) - Show retry button when transaction loading fails - Reset flags when wallet connects/disconnects or after successful payments - Make transaction list truly optional - wallet still works if loading fails This ensures a better UX when wallets don't support list_transactions or when the method fails for any reason. * fix: remove circular dependency in loadInitialTransactions Removed txLoadFailed from the dependency array of loadInitialTransactions callback, which was causing a circular dependency: - loadInitialTransactions depended on txLoadFailed - Function sets txLoadFailed, triggering recreation - New function reference triggers useEffect again - Infinite loop The txLoadAttempted flag in the useEffect is sufficient to prevent repeated loads. No need to check txLoadFailed inside the callback. * fix: resolve React error #185 by removing callbacks from useEffect dependencies React error #185 occurs when state updates happen during render due to unstable function references in useEffect dependencies. The root cause was that functions from useWallet (getInfo, listTransactions) aren't memoized, so they create new references on every render, causing the useEffects that depend on them to run repeatedly. Changes: - Removed loadWalletInfo and loadInitialTransactions callbacks - Use refs (walletInfoLoadedRef, lastConnectionStateRef) to track state - Call async functions directly in useEffect without depending on them - Created reloadTransactions() helper that just resets flags - Simplified all reload logic to use the helper This ensures: - No circular dependencies in useEffect - Functions only run once when conditions are met - No state updates during render - Clean, predictable loading behavior * fix: properly clear wallet state on disconnect and update copy Changes: - Clear all wallet state when disconnecting (transactions, walletInfo, loading flags) - Previously only cleared state on connect, leaving stale data visible - Remove "Mutiny" mention from connection dialog copy - Update to generic "NWC wallet provider" text Now when you disconnect the wallet with the window open, it properly clears all data and returns to the "No Wallet Connected" state. * fix: prevent wallet from auto-reconnecting after disconnect The bug was in the useWallet hook which automatically restores the wallet if nwcConnection exists in state but the wallet instance is null. When disconnecting, it only cleared the wallet instance but left nwcConnection in state, causing an immediate reconnection. Fix: - Call disconnectNWCFromState() to clear nwcConnection from Grimoire state - Then call disconnect() to clear the wallet service - This prevents the auto-restore logic from triggering Now when you disconnect the wallet, it stays disconnected until you manually reconnect. * security: add critical production-ready security fixes Invoice Validation & Expiry Checks: - Validate BOLT11 invoice format (must start with 'ln') - Check invoice expiry before displaying/processing - Validate amount is reasonable (< 21M BTC) - Surface parse errors to user with toast notifications - Prevent processing of expired invoices Lightning Address Security: - Enforce HTTPS-only for LNURL-pay requests - Add 5-second timeout to all HTTP requests - Validate callback URLs use HTTPS - Proper AbortController cleanup on timeout - Better error messages for network failures Rate Limiting: - Balance refresh: minimum 2 seconds between calls - Transaction reload: minimum 5 seconds between reloads - User-friendly warning messages with countdown - Prevents spam to wallet service providers Storage Security Warning: - Add prominent security notice in ConnectWalletDialog - Warn users about browser storage implications - Advise to only connect on trusted devices Capability Detection: - Hide Send button if wallet doesn't support pay_invoice - Hide Receive button if wallet doesn't support make_invoice - Dynamic button rendering based on wallet capabilities - Prevents errors from unsupported operations Error Handling: - WindowErrorBoundary already wraps all windows (verified) - Proper error propagation with user-friendly messages - No silent failures on critical operations These changes significantly improve security and production-readiness without breaking existing functionality. --------- Co-authored-by: Claude <noreply@anthropic.com> |
||
|
|
b70eb82fea |
feat: add @domain alias for NIP-05 domain directory resolution (#136)
Add support for @domain syntax in req and count commands to query all users from a domain's NIP-05 directory (e.g., @habla.news). Features: - Fetches /.well-known/nostr.json from domain - Extracts all pubkeys from the names object - Works with -a (authors), -p (#p tags), and -P (#P tags) flags - Supports mixed usage with npub, hex, NIP-05, $me, $contacts - 5-minute caching for domain lookups - UI display in ReqViewer query dropdown Implementation: - Added resolveDomainDirectory and resolveDomainDirectoryBatch to nip05.ts - Updated req-parser and count-parser to detect @domain syntax - Updated argParsers in man.ts to resolve domains asynchronously - Updated ReqViewer to display queried domains in dropdown - Added comprehensive tests for domain resolution Examples: - req -k 1 -a @habla.news - req -k 7 -p @nostr.band - count relay.damus.io -k 1 -a @getcurrent.io Co-authored-by: Claude <noreply@anthropic.com> |
||
|
|
7a293bb41b |
feat: COUNT (#105)
* Add COUNT command for NIP-45 event counting
Implements the COUNT verb from NIP-45, allowing users to count events
on relays without fetching them. Features:
- New `count` command requiring at least one relay
- Filter-only flags (excludes --limit, --close-on-eose, --view)
- Single relay shows centered count result
- Multiple relays show per-relay breakdown
- Handles approximate counts, errors, and unsupported relays
- Supports $me/$contacts aliases and NIP-05 resolution
Examples:
count relay.damus.io -k 3 -p npub1...
count nos.lol relay.damus.io -k 1 -a fiatjaf.com
* Fix $me and $contacts alias resolution in CountViewer
- Fetch contact list (kind 3) using useNostrEvent hook
- Extract contacts from p tags to resolve $contacts alias
- Add "Account Required" message when aliases used without active account
- Match ReqViewer pattern for consistent alias resolution
* Refactor: extract FilterSummaryBadges for compact headers
- Create shared FilterSummaryBadges component (nostr/FilterSummaryBadges.tsx)
- Simplify CountViewer header to single compact line
- Use FilterSummaryBadges in both ReqViewer and CountViewer
- Remove verbose collapsible filter section from CountViewer
* Remove 'events' suffix from count result
* Update count synopsis to show relays can appear anywhere
* Refactor CountViewer to use applesauce-relay pool
Replace manual WebSocket connections with the relay pool's
count() method for NIP-45 COUNT requests. This provides:
- Proper connection reuse via the existing relay pool
- Automatic reconnection handling
- Better integration with the rest of the app
Remove the approximate property since applesauce-relay's
CountResponse type doesn't expose it yet.
* Simplify CountViewer with one-shot requests and compact UI
- Use per-relay count requests with firstValueFrom and timeout
instead of pool.count() observable that may not complete
- Replace Collapsible-based header with icon-only DropdownMenus
matching ReqViewer's compact style
- Add raw JSON filter view with syntax highlighting and copy button
- Show relay count and filter in dropdowns instead of expanded sections
- Requests complete after timeout (10s) instead of spinning indefinitely
* Add NIP-45 support detection via NIP-11 relay info
- Check relay's supported_nips via NIP-11 before sending COUNT request
- Return early with "unsupported" status if relay explicitly doesn't support NIP-45
- Differentiate UI between unsupported (yellow Ban icon) and error (red AlertCircle)
- Provide clearer error messages based on whether NIP-11 info was available
- Uses cached relay info when available to avoid redundant requests
* Improve CountViewer header with human-readable filter summary
- Show kinds as badges, authors ("by"), mentions ("@"), hashtags on left
- Move relay status into relay dropdown with per-relay results
- Dropdown shows count per relay, status icons, and error tooltips
- Header now shows "2/3" style relay count trigger with loading state
* Reorder CountViewer header controls and remove redundant mention prefix
- Change control order to: refresh, relays, filter (was: filter, relays, refresh)
- Remove redundant "@" prefix from mentions since UserName with isMention already shows @
* Increase COUNT timeout to 30s and improve window title
- Extend per-relay timeout from 10s to 30s for more reliable results
- Update count window title to show human-readable kind names instead of
command-line format (e.g., "count: Short Note by abc123..." instead of
"count -k 1 -a npub...")
* Add spell support for COUNT commands
- Extend spell system to support both REQ and COUNT commands
- Add detectCommandType() to identify command type from string
- Update encodeSpell to use ["cmd", "COUNT"] tag for count commands
- Update decodeSpell to handle COUNT spells
- Update reconstructCommand to accept cmdType parameter
- Add "Save as spell" option to COUNT windows in WindowToolbar
- Update SpellDialog to handle both REQ and COUNT commands
* Add dynamic window title for COUNT with human-readable filter summary
- Add profile fetching for COUNT authors and tagged users
- Add countTitle useMemo with human-readable kind names, authors, mentions, hashtags, and search
- Use same formatting helpers as REQ titles (getKindName, formatProfileNames, etc.)
- Add countTitle to title priority chain after reqTitle
- Title now shows "Short Note • @alice • #bitcoin" instead of "COUNT"
* Update count command documentation for production
- Add note about automatic NIP-11/NIP-45 support detection
- Mention spell saving capability in description
* Add automatic relay selection with NIP-45 filtering for COUNT
- Make relays optional in count-parser (no longer throws if none specified)
- Add useOutboxRelays for automatic relay selection based on filter criteria
- Filter selected relays by NIP-45 support via NIP-11 before querying
- Show "Selecting relays..." and "Filtering by NIP-45..." loading states
- Fall back to aggregator relays if no NIP-45 relays found
- Update man page: relays now optional, new examples showing auto-selection
* Revert automatic relay selection for COUNT command
Simplify COUNT by requiring explicit relay specification:
- Restore relay requirement validation in count-parser.ts
- Remove useOutboxRelays and NIP-45 auto-filtering from CountViewer
- Update man page documentation to reflect required relays
- Keep NIP-45 support detection for better error messages
This keeps the feature simpler for now; automatic relay selection
can be added later when the UX is better understood.
* Reduce padding and sizing in COUNT single result view
---------
Co-authored-by: Claude <noreply@anthropic.com>
|
||
|
|
9ef1fefd3d |
feat: BLOSSOM (#75)
* Add Blossom blob storage integration - Add blossom-client-sdk dependency for blob storage operations - Create blossom.ts service with upload, list, check, mirror, delete primitives - Add kind 10063 server list fetching and parsing - Create blossom-parser.ts for command argument parsing with subcommands - Add BLOSSOM command to man.ts with subcommands: - servers: Show configured Blossom servers - check: Check server health - upload: Upload files to user's servers - list: List blobs for a user - mirror: Mirror blobs between servers - delete: Delete blobs from servers - Create BlossomViewer component with views for each subcommand - Wire up BlossomViewer in WindowRenderer - Add Blossom servers dropdown to ProfileViewer header - Upload primitives can be called programmatically for use in other components * Enhance Blossom viewer with server selection and blob details - Add server selection checkboxes to upload view for choosing target servers - Add BlobDetailView with media preview (image/video/audio) and metadata display - Add 'blob' subcommand to view individual blob details - Remove unused 'check' subcommand * Add Blossom upload dialog with chat integration - Create BlossomUploadDialog component with file picker, server selection, and preview - Create useBlossomUpload hook for easy integration in any component - Add insertText method to MentionEditor for programmatic text insertion - Integrate upload button (paperclip icon) in chat composer - Supports image, video, and audio uploads with drag-and-drop * Add rich blob attachments with imeta tags for chat - Add BlobAttachment TipTap extension with inline preview (thumbnail for images, icons for video/audio) - Store full blob metadata (sha256, url, mimeType, size, server) in editor nodes - Convert blob nodes to URLs in content with NIP-92 imeta tags when sending - Add insertBlob method to MentionEditor for programmatic blob insertion - Update NIP-29 and NIP-53 adapters to include imeta tags with blob metadata - Pass blob attachments through entire send flow (editor -> ChatViewer -> adapter) * Add fallback public Blossom servers for users without server list - Add well-known public servers as fallbacks (blossom.primal.net, nostr.download, files.v0l.io) - Use fallbacks when user has no kind 10063 server list configured - Show "Public Servers" label with Globe icon when using fallbacks - Inform user that no server list was found - Select first fallback server by default (vs all user servers) * Fix: Don't show fallback servers when not logged in Blossom uploads require signed auth events, so users must be logged in. The 'Account required' message is already shown in this case. * Remove files.v0l.io from fallback servers * Add rich renderer for kind 10063 Blossom server list - Create BlossomServerListRenderer.tsx with feed and detail views - Show user's configured Blossom servers with clickable links - Clicking a server opens the Blossom window with server info - Register renderers for kind 10063 (BUD-03) - Fix lint error by renaming useFallbackServers to applyFallbackServers * Add individual server view and NIP-05 support for blossom commands - Add 'server' subcommand to view info about a specific Blossom server - Update BlossomServerListRenderer to open server view on click - Make blossom parser async to support NIP-05 resolution in 'list' command - Add kind 10063 (Blossom Server List) to EVENT_KINDS constants with BUD-03 reference - Update command examples with NIP-05 identifier support * Add comprehensive tests for blossom-parser - 34 test cases covering all subcommands (servers, server, upload, list, blob, mirror, delete) - Tests for NIP-05 resolution, npub/nprofile decoding, $me alias - Tests for error handling and input validation - Tests for case insensitivity and command aliases (ls, view, rm) --------- Co-authored-by: Claude <noreply@anthropic.com> |
||
|
|
9657ec635f | fix: support other user groups | ||
|
|
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 |
||
|
|
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> |
||
|
|
64212121bd | ui: compact view tweaks | ||
|
|
7d72aec83e |
feat: improve spellbook UX with BookHeart icon and Preview mode
- Update spellbook icon to BookHeart across the app - Implement Preview mode with routing /:actor/:identifier - Add Preview banner in Home component with Apply/Discard actions - Add Preview and Share buttons to Spellbook renderers - Clean up unused imports |
||
|
|
5d9ff3cf56 |
feat: implement Nostr Wallet Connect (NWC)
- Add applesauce-wallet-connect dependency - Create WalletService for managing NWC connection - Create WalletViewer component for UI - Register 'wallet' command - Fix build errors in spell/spellbook components due to applesauce-actions upgrade |
||
|
|
2987a37e65 | feat: spells | ||
|
|
3fba62b316 | ui: simpler streams | ||
|
|
52f39a8073 |
feat: add layout presets system with /layout command
Phase 3 implementation: - Created layout-presets.ts with 3 built-in presets (side-by-side, main-sidebar, grid) - Implemented fillLayoutTemplate() for recursive template filling with window IDs - Added collectWindowIds() for depth-first traversal of layout trees - Created applyPresetToLayout() to reorganize existing windows - Created layout-parser.ts for /layout command argument parsing - Added layout command to man.ts with documentation and examples - Built LayoutViewer component with: * Visual preset gallery with diagrams * Window count validation * Apply preset functionality * Error handling for insufficient windows * Command-line preset specification support - Wired LayoutViewer into WindowRenderer with lazy loading - Added "layout" to AppId type definition - Exposed applyPresetLayout in useGrimoire hook Presets allow users to quickly reorganize multiple windows into common layouts: 50/50 splits, 70/30 main+sidebar, or 2×2 grids. Generated with [Claude Code](https://claude.com/claude-code) |
||
|
|
97c89142ae | wip: live video events | ||
|
|
63121f6233 | feat: add title command line flag | ||
|
|
f4a0d5e669 | feat: -P filter tag | ||
|
|
e5c871617e | chore: cleanup, a11y and state migrations | ||
|
|
6f17415340 | feat: NIPS command | ||
|
|
c287cff413 | refactor: remove unused commands | ||
|
|
6568daf944 | wip: relay pool view and auth | ||
|
|
bdfb41c68f | feat: KINDS command | ||
|
|
f6d490cf26 | feat: highlight your name in orange | ||
|
|
36a9b95695 | feat: isolate crashes, refactor window rendering |