mirror of
https://github.com/purrgrammer/grimoire.git
synced 2026-04-11 16:07:15 +02:00
ae460883334288d77a1f40141410db78e819e7c4
This commit fixes two critical issues preventing live message delivery in self-chat and other NIP-17 conversations: **Issue 1: applesauce-actions relay hint bug (PATCHED IN NODE_MODULES)** - Root cause: Action used gift wrap's random ephemeral pubkey to look up inbox relays, but the map was keyed by real recipient pubkeys - Result: inboxRelays.get(giftWrap.pubkey) returned undefined - publishEvent received no relay hints and failed with "No relays found" - Messages never published **Issue 2: Relay URL normalization mismatch** - Root cause: Inbox relays from kind 10050 not normalized (kept raw format) - Result: URLs with/without trailing slashes treated as different relays Example: wss://relay.com/ vs wss://relay.com - Published to: wss://frens.nostr1.com/ (with slash) - Subscribed to: wss://frens.nostr1.com (without slash) - Messages sent but subscription never received them (different relay!) - User had to click "Sync" to manually fetch from all relay variations **Changes:** 1. src/services/gift-wrap.ts: * Added normalizeRelayURL import * Normalize all inbox relay URLs when loading from kind 10050 event * Ensures consistent URL format for subscription matching 2. src/services/hub.ts: * Added normalizeRelayURL import * Normalize relay hints before publishing * Ensures sent messages go to same normalized relay as subscription 3. node_modules/applesauce-actions/dist/actions/wrapped-messages.js: * PATCHED: Track recipient pubkey alongside gift wrap * Use recipientPubkey (real user) instead of giftWrap.pubkey (ephemeral) * Ensures correct inbox relay lookup * NOTE: This is a temporary patch until fix is merged upstream * TODO: Remove patch after applesauce-actions >5.0.2 is released **Expected Behavior After Fix:** 1. User sends self-chat message 2. Action looks up inbox relays using recipient pubkey (FIXED) 3. publishEvent receives relay hints: ['wss://relay.com/'] (WORKING) 4. Relay hints normalized: ['wss://relay.com/'] (NEW) 5. Gift wrap published to normalized relays (WORKING) 6. Subscription listening on normalized relays receives message (FIXED) 7. Message appears live in UI without manual sync (~200-500ms latency) **Testing:** Self-chat test: - Send message to self - Console should show: * [Publish] Using provided relay hints * [Publish] Persisted encrypted content for gift wrap * Match: true (relay alignment) - Message should appear within 500ms - Reload page - message persists - Send another message - both visible, no duplicates **Note on node_modules patch:** The applesauce-actions patch will be lost on npm install. Options: 1. Use patch-package to persist the patch 2. Wait for upstream fix and update to applesauce-actions >5.0.2 3. Create local fork until upstream merge For now, if you run npm install, you'll need to reapply the patch. Co-Authored-By: Claude Sonnet 4.5 <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%