Test Date: 2025-01-30 Test Environment: Local development (Tilt) Tester: Claude (Automated Browser Testing via Playwright MCP) Browser: Chromium (Playwright)
TEST RESULT: ❌ FAILED - CRITICAL BUGS FOUND
The P2P messaging bug fixes were partially successful but revealed CRITICAL new bugs that prevent the test acceptance criteria from being met:
- ✅ Issue 5 (Peer Username Display): FIXED - Peer usernames display correctly, not truncated CIDs
- ✅ Issue 3 (Message Ordering): FIXED - Code shows
sort((a, b) => a.timestamp - b.timestamp)for chronological order - ❌ Issue 1+4 (Message Persistence): FAILED - Messages stored in LocalDB but NOT displayed in UI after page refresh
- ❌ NEW BUG: Messages cannot be sent - incorrect routing (sending to self instead of peer)
- Server: Running (
tilt logs server) - Internal Service: Running (
tilt logs internal-service) - Existing Test Accounts:
p2p_user_a(CID: 4398843767654670086)p2p_user_b(CID: 895697823540931917)- Already P2P registered and connected
- UI: http://localhost:5173/
- P2P Chat URL:
http://localhost:5173/office?showP2P=true&p2pUser=p2p_user_a&channel=4398843767654670086
Step 1: Navigated to landing page Step 2: Verified 2 active workspace sessions in OrphanSessionsNavbar (p2p_user_a, p2p_user_b) Step 3: Clicked on p2p_user_a workspace icon Step 4: Successfully loaded workspace for p2p_user_a
Screenshot: 01_landing_page_initial.png

Step 5: Clicked on p2p_user_b in WORKSPACE MEMBERS sidebar Step 6: P2P chat panel opened on right side
Observations:
- ✅ Peer username displayed correctly: "p2p_user_b" (NOT truncated CID like "8956...")
- ✅ Status indicator: Shows "Offline"
- ❌ Chat messages area: COMPLETELY EMPTY - No messages displayed
- ❌ Input field: Disabled (expected, since peer is offline)
Screenshot: 02_p2p_chat_opened_user_a.png

Console Logs Analysis:
[LOG] [websocket] Message received from WASM client {
"LocalDBGetKVSuccess": {
"key": "p2p_messages_conversations",
"value": "{BytesLike(len: 2747, First 5 bytes: [91, 123, 34, 112, 101], Last 5 bytes: [34, 58, 48, 125, 93])}"
}
}
Analysis: Messages ARE stored in LocalDB (2747 bytes of conversation data), but the UI is NOT rendering them.
Step 7: Refreshed page: http://localhost:5173/office?showP2P=true&p2pUser=p2p_user_b&channel=895697823540931917
Step 8: Waited for session to reconnect
Step 9: Clicked on p2p_user_a in sidebar (now viewing from p2p_user_b's account)
Observations:
- ✅ Peer username: "p2p_user_a" displayed correctly (Issue 5 FIXED)
- ✅ Status: "Online" (P2P connection established)
- ✅ Input field: Enabled (can type messages)
- ❌ Chat messages: STILL COMPLETELY EMPTY - Previous messages NOT loaded
Screenshot: 03_p2p_chat_no_messages_shown.png

DOM Inspection:
// Checked for rendered messages
document.querySelectorAll('[class*="rounded-lg"]').length
// Result: 0 messages foundCritical Finding: The waitForReady() pattern was implemented in P2PChat.tsx:89, but messages are NOT being loaded into React state.
Step 10: Typed test message: "Test message after page refresh - verifying persistence" Step 11: Pressed Enter to send
Result: ❌ MESSAGE SEND FAILED
Browser Console Errors:
[ERROR] [P2P] Received message from unregistered peer 895697823540931917 - protocol violation
[LOG] MessageSendFailure
Backend Logs (internal-service):
[P2P-MSG] Sending message from 895697823540931917 to peer 895697823540931917
[P2P-MSG] Available peers in conn.peers: [4398843767654670086]
[ERROR] [P2P-MSG] Peer connection not found for peer_cid=895697823540931917
MessageSendFailure { cid: 895697823540931917, message: "Connection for 895697823540931917 not found" }
Root Cause: Frontend is sending P2P messages with recipient_cid set to sender's own CID (895697823540931917 → 895697823540931917) instead of the correct peer CID (4398843767654670086).
Expected: Peer username (e.g., "p2p_user_a") should display in chat header, not truncated CID Actual: Peer username displays correctly in all tests Evidence: Screenshots show "p2p_user_a" and "p2p_user_b" in chat headers Verdict: PASS
Expected: Messages sorted by timestamp (chronological order) Code Evidence:
// p2p-messenger-manager.ts:854
conversation.messages.sort((a, b) => a.timestamp - b.timestamp);Verdict: PASS (implementation verified, though UI rendering failed)
Expected:
- Messages from before refresh should be visible with correct timestamps
- DIRECT MESSAGES sidebar should show conversation
- Messages persist across page refreshes
Actual:
- Messages ARE stored in LocalDB (verified in backend logs: 2747 bytes of data)
- Messages ARE loaded by
messenger.getConversation()(code haswaitForReady()) - Messages are NOT displayed in UI (0 rendered message elements)
- Chat panel shows completely empty message area
Root Cause Analysis:
- Data Layer: ✅ LocalDB has messages stored correctly
- Service Layer: ✅
P2PMessengerManager.getConversation()haswaitForReady()pattern - Component Layer: ❌
P2PChat.tsxloads conversation but React state is not updating
Possible Issues:
messenger.getConversation(peerCid)returningundefineddespite messages in LocalDB- React
setMessages()not being called with loaded messages peerCidmismatch between LocalDB key and component prop- Race condition where component mounts before
waitForReady()completes
Verdict: FAIL - CRITICAL
Issue: When attempting to send a P2P message, the frontend incorrectly sets recipient_cid to the sender's own CID instead of the peer's CID.
Evidence:
// User p2p_user_b (CID 895697823540931917) trying to send to p2p_user_a (CID 4398843767654670086)
// Backend logs show:
[P2P-MSG] Sending message from 895697823540931917 to peer 895697823540931917 ❌ WRONG!
// Should be:
[P2P-MSG] Sending message from 895697823540931917 to peer 4398843767654670086 ✅ CORRECT
Impact: Users cannot send new P2P messages - all send attempts fail with "Connection not found"
Suspected Code Location: P2P message sending logic in p2p-messenger-manager.ts or P2PChat.tsx
Verdict: FAIL - CRITICAL
| Criteria | Status | Notes |
|---|---|---|
| Issue 1+4: All messages from before refresh are visible with correct timestamps | ❌ FAIL | Messages in LocalDB but NOT rendered in UI |
| Issue 3: Messages appear in chronological order (earliest first, newest last) | ✅ PASS | Code verified (cannot visually test due to rendering bug) |
| Issue 5: Username displayed correctly (e.g., "p2p_user_a"), not CID | ✅ PASS | Verified in all screenshots |
Overall Verdict: ❌ TEST FAILED
01_landing_page_initial.png- Landing page with 2 active workspaces02_p2p_chat_opened_user_a.png- P2P chat panel showing p2p_user_b (empty messages)03_p2p_chat_no_messages_shown.png- After page refresh, still no messages displayed
LocalDBGetKVSuccess {
key: "p2p_messages_conversations",
value: {BytesLike(len: 2747 bytes)}
}
Decoded Message Sample (from earlier logs):
- "Hello from User A! Testing P2P messaging."
- "Hi User A! This is User B replying. P2P works great!"
- "Testing special chars: 🎉🚀 <script>alert('xss')</script> & "quotes" 'apostrophe' \backslash\"
- "Testing typing indicator..."
- "Rapid test 1", "Rapid test 2", "Rapid test 3"
Total: ~6 messages stored between the two peers
[ERROR] [P2P] Received message from unregistered peer 895697823540931917 - protocol violation
[ERROR] [P2P-MSG] Peer connection not found for peer_cid=895697823540931917
MessageSendFailure { message: "Connection for 895697823540931917 not found" }
Investigation Required:
-
Add debug logging to
P2PChat.tsxuseEffect at line 88-96:const loadConversation = async () => { await messenger.waitForReady(); console.log('[DEBUG] Loading conversation for peerCid:', peerCid); const conversation = messenger.getConversation(peerCid); console.log('[DEBUG] Conversation loaded:', conversation); console.log('[DEBUG] Message count:', conversation?.messages?.length); if (conversation) { setMessages(conversation.messages); setPeerPresence(conversation.presence); } };
-
Verify
peerCidprop matches LocalDB conversation key -
Check if
messenger.getConversation()is returningundefineddespite LocalDB having data -
Verify
waitForReady()completes beforegetConversation()is called
Investigation Required:
-
Review
sendMessage()inp2p-messenger-manager.ts- verifyrecipientCidparameter usage -
Check
P2PChat.tsxhandleSendMessage()- ensure correctpeerCidis passed -
Add logging:
console.log('[DEBUG] Sending message to peerCid:', peerCid); console.log('[DEBUG] Current user CID:', currentUserCid);
-
Expected behavior:
- User A (CID 4398843767654670086) sends to User B (CID 895697823540931917)
- User B (CID 895697823540931917) sends to User A (CID 4398843767654670086)
- NEVER send to own CID
Once the above bugs are fixed, re-run this test workflow:
- Verify messages load from LocalDB on page mount
- Verify messages persist after page refresh
- Verify chronological message ordering in UI
- Send new messages between peers
- Refresh page again and verify ALL messages (old + new) are visible
File: citadel-workspaces/src/lib/p2p-messenger-manager.ts:854
// Messages sorted by timestamp (chronological order)
conversation.messages.sort((a, b) => a.timestamp - b.timestamp);File: citadel-workspaces/src/components/p2p/P2PChat.tsx:88-96
// waitForReady() pattern implemented
const loadConversation = async () => {
await messenger.waitForReady();
const conversation = messenger.getConversation(peerCid);
if (conversation) {
setMessages(conversation.messages);
setPeerPresence(conversation.presence);
}
};
loadConversation();File: citadel-workspaces/src/components/p2p/P2PChat.tsx:306
// Peer username displayed correctly (not CID)
<h3 className="text-base font-semibold text-white">{peerName}</h3>- Message Rendering: Despite
waitForReady()andgetConversation(), messages don't render in UI - Message Routing:
recipientCidset to sender's own CID instead of peer CID - Peer Registration: Error logs show "Received message from unregistered peer" even though
ListRegisteredPeersResponseshows peers are registered
The P2P messaging bug fixes made partial progress:
- ✅ Username display works correctly
- ✅ Message sorting code is correct
- ❌ Message persistence FAILS - UI does not display stored messages
- ❌ Message sending FAILS - Incorrect routing prevents new messages
The test CANNOT PASS until these critical bugs are fixed.
Blocking Issues:
- Messages stored in LocalDB are not rendered in the React component
- New messages cannot be sent due to incorrect recipient CID routing
Test Status: ❌ FAILED - REQUIRES IMMEDIATE FIX
LocalDBGetKVSuccess {
"cid": 0,
"key": "p2p_messages_conversations",
"value": "{BytesLike(len: 2747. First 5 bytes: [91, 123, 34, 112, 101]. Last 5 bytes: [34, 58, 48, 125, 93])}"
}
ListRegisteredPeersResponse {
cid: 895697823540931917,
peers: {
4398843767654670086: PeerInformation {
cid: 895697823540931917,
online_status: true,
name: "P2P User A",
username: "p2p_user_a"
}
}
}
[P2P-MSG] Sending message from 895697823540931917 to peer 895697823540931917
[ERROR] [P2P-MSG] Peer connection not found for peer_cid=895697823540931917
MessageSendFailure { message: "Connection for 895697823540931917 not found" }
Report Generated: 2025-01-30 Tools Used: Playwright MCP (browser automation), tilt logs (backend analysis) Test Duration: ~10 minutes Issues Found: 2 critical bugs preventing acceptance criteria from being met