debug: add comprehensive logging for flight mode detection

- Add detailed logs with [HIGHLIGHT-PUBLISH] prefix for publication process
- Add detailed logs with [HIGHLIGHT-UI] prefix for UI rendering
- Log relay responses, success/failure analysis, and flight mode reasoning
- Log icon decision making process in UI component
- This will help debug why airplane icon isn't showing in flight mode
This commit is contained in:
Gigi
2025-10-30 20:42:02 +01:00
parent 9379475d1c
commit 1f6a904717
2 changed files with 46 additions and 7 deletions

View File

@@ -309,16 +309,32 @@ export const HighlightItem: React.FC<HighlightItemProps> = ({
// Check if this highlight was only published to local relays // Check if this highlight was only published to local relays
const isLocalOnly = highlight.isLocalOnly const isLocalOnly = highlight.isLocalOnly
console.log('🎯 [HIGHLIGHT-UI] Rendering highlight relay indicator:', {
highlightId: highlight.id,
isLocalOnly,
publishedRelays: highlight.publishedRelays,
willShowAirplaneIcon: isLocalOnly
})
// Show highlighter icon with relay info if available // Show highlighter icon with relay info if available
if (highlight.publishedRelays && highlight.publishedRelays.length > 0) { if (highlight.publishedRelays && highlight.publishedRelays.length > 0) {
const relayNames = highlight.publishedRelays.map(url => const relayNames = highlight.publishedRelays.map(url =>
url.replace(/^wss?:\/\//, '').replace(/\/$/, '') url.replace(/^wss?:\/\//, '').replace(/\/$/, '')
) )
return { const iconInfo = {
icon: isLocalOnly ? faPlane : faHighlighter, icon: isLocalOnly ? faPlane : faHighlighter,
tooltip: isLocalOnly ? 'Local relays only - will sync when remote relays available' : relayNames.join('\n'), tooltip: isLocalOnly ? 'Local relays only - will sync when remote relays available' : relayNames.join('\n'),
spin: false spin: false
} }
console.log('🔍 [HIGHLIGHT-UI] Icon decision made:', {
highlightId: highlight.id,
isLocalOnly,
iconType: isLocalOnly ? 'airplane' : 'highlighter',
tooltip: iconInfo.tooltip
})
return iconInfo
} }
if (highlight.seenOnRelays && highlight.seenOnRelays.length > 0) { if (highlight.seenOnRelays && highlight.seenOnRelays.length > 0) {

View File

@@ -125,40 +125,63 @@ export async function createHighlight(
let publishResponses: { ok: boolean; message?: string; from: string }[] = [] let publishResponses: { ok: boolean; message?: string; from: string }[] = []
let isLocalOnly = false let isLocalOnly = false
console.log('🚀 [HIGHLIGHT-PUBLISH] Starting highlight publication process', {
eventId: signedEvent.id,
allRelays,
relayCount: allRelays.length
})
try { try {
// Publish to all relays and wait for responses // Publish to all relays and wait for responses
console.log('📡 [HIGHLIGHT-PUBLISH] Publishing to all relays...')
publishResponses = await relayPool.publish(allRelays, signedEvent) publishResponses = await relayPool.publish(allRelays, signedEvent)
console.log('📨 [HIGHLIGHT-PUBLISH] Received responses from relays:', publishResponses)
// Determine which relays successfully accepted the event // Determine which relays successfully accepted the event
const successfulRelays = publishResponses const successfulRelays = publishResponses
.filter(response => response.ok) .filter(response => response.ok)
.map(response => response.from) .map(response => response.from)
const failedRelays = publishResponses
.filter(response => !response.ok)
.map(response => ({ from: response.from, message: response.message }))
const successfulLocalRelays = successfulRelays.filter(url => isLocalRelay(url)) const successfulLocalRelays = successfulRelays.filter(url => isLocalRelay(url))
const successfulRemoteRelays = successfulRelays.filter(url => !isLocalRelay(url)) const successfulRemoteRelays = successfulRelays.filter(url => !isLocalRelay(url))
// isLocalOnly is true if only local relays accepted the event // isLocalOnly is true if only local relays accepted the event
isLocalOnly = successfulLocalRelays.length > 0 && successfulRemoteRelays.length === 0 isLocalOnly = successfulLocalRelays.length > 0 && successfulRemoteRelays.length === 0
console.log('🔍 Highlight creation debug:', { console.log('✅ [HIGHLIGHT-PUBLISH] Publishing analysis:', {
allRelays, totalRelays: allRelays.length,
publishResponses, successfulRelays: successfulRelays.length,
successfulRelays, failedRelays: failedRelays.length,
successfulLocalRelays, successfulLocalRelays,
successfulRemoteRelays, successfulRemoteRelays,
isLocalOnly failedRelays,
isLocalOnly,
flightModeReason: isLocalOnly
? 'Only local relays accepted the event'
: successfulRemoteRelays.length > 0
? 'Remote relays also accepted the event'
: 'No relays accepted the event'
}) })
// Mark for offline sync if we're in local-only mode // Mark for offline sync if we're in local-only mode
if (isLocalOnly) { if (isLocalOnly) {
console.log('✈️ [HIGHLIGHT-PUBLISH] Marking event for offline sync (flight mode)')
const { markEventAsOfflineCreated } = await import('./offlineSyncService') const { markEventAsOfflineCreated } = await import('./offlineSyncService')
markEventAsOfflineCreated(signedEvent.id) markEventAsOfflineCreated(signedEvent.id)
} else {
console.log('🌐 [HIGHLIGHT-PUBLISH] Event published to remote relays, no offline sync needed')
} }
} catch (error) { } catch (error) {
console.warn('⚠️ Failed to publish highlight to relays:', error) console.error('❌ [HIGHLIGHT-PUBLISH] Failed to publish highlight to relays:', error)
// If publishing fails completely, assume local-only mode // If publishing fails completely, assume local-only mode
isLocalOnly = true isLocalOnly = true
console.log('✈️ [HIGHLIGHT-PUBLISH] Publishing failed, marking for offline sync (flight mode)')
const { markEventAsOfflineCreated } = await import('./offlineSyncService') const { markEventAsOfflineCreated } = await import('./offlineSyncService')
markEventAsOfflineCreated(signedEvent.id) markEventAsOfflineCreated(signedEvent.id)
} }