mirror of
https://github.com/permissionlesstech/bitchat.git
synced 2026-07-24 23:45:18 +00:00
- Add detailed logging to track read receipt generation - Handle messages that don't have delivery status (older messages) - Send read receipts for all unread messages when opening chat
2.5 KiB
2.5 KiB
Delivery Confirmation Feature Summary
Overview
This branch implements a complete delivery confirmation system for bitchat, providing visual feedback for message delivery status and read receipts.
Key Components Implemented
1. Delivery Status Tracking
- DeliveryTracker.swift: Core service managing delivery confirmations
- Tracks pending deliveries with timeouts (30s for private, 60s for rooms)
- Handles retries for favorite peers (up to 3 attempts)
- Thread-safe implementation with proper lock management
2. Protocol Updates
- BitchatProtocol.swift:
- Added
DeliveryStatusenum with states: sending, sent, delivered, read, failed - Added
DeliveryAckstructure for acknowledgments - Added
ReadReceiptstructure for read confirmations - New message types:
.deliveryAckand.readReceipt
- Added
3. UI Implementation
- ContentView.swift:
- Added
DeliveryStatusViewcomponent showing:- Gray circle (○) for sending
- Gray checkmark (✓) for sent
- Green double checkmarks (✓✓) for delivered
- Blue double checkmarks (✓✓) for read
- Red triangle (⚠) for failed
- Proper vertical alignment with message text
- Added
4. Message Flow
- BluetoothMeshService.swift:
- Added ACK generation and sending
- Added read receipt generation when viewing chats
- Encrypted ACKs for privacy
- Proper message ID handling
5. Critical Bug Fixes
Deadlock Fix
- Issue: macOS app freeze when sending private messages
- Cause: Nested lock acquisition in DeliveryTracker
- Fix: Restructured code to release locks before calling methods that acquire the same lock
Message ID Preservation
- Issue: ACKs referenced wrong message IDs
- Cause: BinaryProtocol was reading but discarding ID with
let _ = - Fix: Changed to
let id =and passed ID to BitchatMessage constructor
Technical Details
Privacy Considerations
- ACKs and read receipts are encrypted end-to-end
- Only the original sender can decrypt and process them
- No message content is included in confirmations
Performance
- Debounced UI updates (100ms)
- Efficient lock usage to prevent deadlocks
- Automatic cleanup of old delivery data
Error Handling
- Graceful timeout handling
- Retry logic for favorites
- Clear failure messages
Testing
See test_delivery_confirmation.md for comprehensive test plan.
Future Enhancements
- Group read receipts (show who read in rooms)
- Delivery timestamps in UI
- Persistent delivery status across app restarts
- Network quality indicators