Files
grimoire/src
Alejandro Gómez b6d03a1644 fix: Use persistent subscription instead of request for real-time DMs
CRITICAL FIX: Changed from pool.request() to pool.subscription() to keep
the relay connection open after EOSE. This was the root cause of why
received messages didn't appear automatically.

**Root Cause:**

1. pool.request() fetches historical events and CLOSES after EOSE
2. After EOSE, relay subscription is terminated
3. New gift wraps sent after that aren't received from relay
4. EventStore timeline subscription only fires when events are added
5. Result: Only locally-sent messages appeared (added to EventStore),
   but remotely-received messages were invisible until manual sync

**Solution:**

Use pool.subscription() which keeps the WebSocket connection OPEN after
EOSE, allowing real-time message delivery.

**Changes:**

src/services/gift-wrap.ts:
* Changed pool.request() to pool.subscription()
* Added detailed logging for EVENT and EOSE responses
* Properly stores relay subscription in subscriptions array for cleanup
* Connection stays open indefinitely for real-time updates

**Expected Behavior:**

After EOSE:
-  Relay connection stays open (WebSocket active)
-  New gift wraps received in real-time from relay
-  EventStore.add() called automatically (via eventStore option)
-  Timeline subscription fires
-  Message appears in UI within 500ms

Console logs should show:
1. 'Opening subscription to X relays for real-time gift wraps'
2. '✓ EOSE from wss://relay... (subscription stays open)'
3. '📨 Received gift wrap xxxxxx from relay' (when message arrives)
4. '📬 Timeline subscription fired with X gift wraps'
5. '💬 Updated conversations: X conversations, X total rumors'

**Testing:**

1. Login and open self-chat
2. Send message from another client/device
3. Message should appear automatically within 500ms
4. No manual sync needed
5. Works for both self-chat and regular DMs

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-01-16 14:34:25 +01:00
..
2026-01-15 16:13:50 +01:00
2025-12-22 22:38:52 +01:00
2026-01-14 19:24:37 +01:00
2026-01-14 19:24:37 +01:00
2026-01-14 19:24:37 +01:00
👶
2025-12-09 16:26:31 +01:00