feat: add comprehensive logging for UI refresh and capture JS console logs

- Add detailed logging to loadPluginStatus() with [UI Refresh] prefix
- Add detailed logging to checkNotificationDelivery() with [Poll] prefix
- Log status check results, change detection, and refresh triggers
- Log nextNotificationTime comparisons to debug rollover detection
- Include Capacitor/Console in logcat capture pattern to capture JS logs
- Log notification delivery detection and time calculations
- Log when rollover is detected and UI refresh is triggered

This enables debugging of UI auto-refresh mechanism and visibility
into JavaScript console logs in captured logcat output.
This commit is contained in:
Matthew Raymer
2025-12-29 10:22:36 +00:00
parent a85f8b2f52
commit dced4b49e1
2 changed files with 62 additions and 4 deletions

View File

@@ -799,7 +799,8 @@ main() {
# Capture post-rollover state # Capture post-rollover state
capture_alarms "test0_after_rollover" capture_alarms "test0_after_rollover"
# Look for rollover logs: DN|RESCHEDULE, DN|DISPLAY, DN|RECEIVE, ROLLOVER_ON_FIRE, etc. # Look for rollover logs: DN|RESCHEDULE, DN|DISPLAY, DN|RECEIVE, ROLLOVER_ON_FIRE, etc.
capture_logcat "test0_after_rollover" "DN|RESCHEDULE|DN|DISPLAY|DN|RECEIVE|ROLLOVER|DNP-SCHEDULE" 200 # Also capture JavaScript console logs (Capacitor/Console) for UI debugging
capture_logcat "test0_after_rollover" "DN|RESCHEDULE|DN|DISPLAY|DN|RECEIVE|ROLLOVER|DNP-SCHEDULE|Capacitor/Console" 200
capture_screenshot "test0_after_rollover" capture_screenshot "test0_after_rollover"
step_pass "p1_t0_s4" "Post-rollover evidence captured" step_pass "p1_t0_s4" "Post-rollover evidence captured"

View File

@@ -182,32 +182,52 @@
} }
function loadPluginStatus() { function loadPluginStatus() {
console.log('loadPluginStatus called'); console.log('[UI Refresh] loadPluginStatus called');
const pluginStatusContent = document.getElementById('pluginStatusContent'); const pluginStatusContent = document.getElementById('pluginStatusContent');
const statusCard = document.getElementById('statusCard'); const statusCard = document.getElementById('statusCard');
try { try {
if (!window.DailyNotification) { if (!window.DailyNotification) {
console.warn('[UI Refresh] DailyNotification plugin not available');
pluginStatusContent.innerHTML = '❌ DailyNotification plugin not available'; pluginStatusContent.innerHTML = '❌ DailyNotification plugin not available';
statusCard.style.background = 'rgba(255, 0, 0, 0.3)'; // Red background statusCard.style.background = 'rgba(255, 0, 0, 0.3)'; // Red background
return; return;
} }
console.log('[UI Refresh] Calling getNotificationStatus()...');
window.DailyNotification.getNotificationStatus() window.DailyNotification.getNotificationStatus()
.then(result => { .then(result => {
console.log('[UI Refresh] getNotificationStatus result:', {
nextNotificationTime: result.nextNotificationTime,
isEnabled: result.isEnabled,
pending: result.pending,
lastNotificationTime: result.lastNotificationTime
});
const nextTime = formatDateTimeNormalized(result.nextNotificationTime); const nextTime = formatDateTimeNormalized(result.nextNotificationTime);
const hasSchedules = result.isEnabled || (result.pending && result.pending > 0); const hasSchedules = result.isEnabled || (result.pending && result.pending > 0);
const statusIcon = hasSchedules ? '✅' : '⏸️'; const statusIcon = hasSchedules ? '✅' : '⏸️';
console.log('[UI Refresh] Updating UI:', {
nextTime: nextTime,
hasSchedules: hasSchedules,
statusIcon: statusIcon
});
pluginStatusContent.innerHTML = `${statusIcon} Active Schedules: ${hasSchedules ? 'Yes' : 'No'}<br> pluginStatusContent.innerHTML = `${statusIcon} Active Schedules: ${hasSchedules ? 'Yes' : 'No'}<br>
📅 Next Notification: ${nextTime}<br> 📅 Next Notification: ${nextTime}<br>
⏳ Pending: ${result.pending || 0}`; ⏳ Pending: ${result.pending || 0}`;
statusCard.style.background = hasSchedules ? statusCard.style.background = hasSchedules ?
'rgba(0, 255, 0, 0.15)' : 'rgba(255, 255, 255, 0.1)'; // Green if active, light gray if none 'rgba(0, 255, 0, 0.15)' : 'rgba(255, 255, 255, 0.1)'; // Green if active, light gray if none
console.log('[UI Refresh] UI updated successfully');
}) })
.catch(error => { .catch(error => {
console.error('[UI Refresh] getNotificationStatus failed:', error);
pluginStatusContent.innerHTML = `⚠️ Status check failed: ${error.message}`; pluginStatusContent.innerHTML = `⚠️ Status check failed: ${error.message}`;
statusCard.style.background = 'rgba(255, 0, 0, 0.3)'; // Red background statusCard.style.background = 'rgba(255, 0, 0, 0.3)'; // Red background
}); });
} catch (error) { } catch (error) {
console.error('[UI Refresh] loadPluginStatus exception:', error);
pluginStatusContent.innerHTML = `⚠️ Status check failed: ${error.message}`; pluginStatusContent.innerHTML = `⚠️ Status check failed: ${error.message}`;
statusCard.style.background = 'rgba(255, 0, 0, 0.3)'; // Red background statusCard.style.background = 'rgba(255, 0, 0, 0.3)'; // Red background
} }
@@ -444,18 +464,36 @@
// Check for notification delivery and status updates periodically // Check for notification delivery and status updates periodically
function checkNotificationDelivery() { function checkNotificationDelivery() {
if (!window.DailyNotification) return; if (!window.DailyNotification) {
console.log('[Poll] DailyNotification not available, skipping check');
return;
}
console.log('[Poll] checkNotificationDelivery called');
window.DailyNotification.getNotificationStatus() window.DailyNotification.getNotificationStatus()
.then(result => { .then(result => {
console.log('[Poll] Status check result:', {
nextNotificationTime: result.nextNotificationTime,
lastNotificationTime: result.lastNotificationTime,
lastKnownNextNotificationTime: lastKnownNextNotificationTime
});
// Check for notification delivery // Check for notification delivery
if (result.lastNotificationTime) { if (result.lastNotificationTime) {
const lastTime = new Date(result.lastNotificationTime); const lastTime = new Date(result.lastNotificationTime);
const now = new Date(); const now = new Date();
const timeDiff = now - lastTime; const timeDiff = now - lastTime;
console.log('[Poll] Notification delivery check:', {
lastTime: lastTime.toISOString(),
now: now.toISOString(),
timeDiff: timeDiff,
withinWindow: timeDiff > 0 && timeDiff < 120000
});
// If notification was received in the last 2 minutes, show indicator // If notification was received in the last 2 minutes, show indicator
if (timeDiff > 0 && timeDiff < 120000) { if (timeDiff > 0 && timeDiff < 120000) {
console.log('[Poll] Notification received recently, showing indicator');
const indicator = document.getElementById('notificationReceivedIndicator'); const indicator = document.getElementById('notificationReceivedIndicator');
const timeSpan = document.getElementById('notificationReceivedTime'); const timeSpan = document.getElementById('notificationReceivedTime');
@@ -471,7 +509,9 @@
}, 30000); }, 30000);
// Force immediate refresh when notification is received (rollover may have occurred) // Force immediate refresh when notification is received (rollover may have occurred)
console.log('[Poll] Scheduling UI refresh in 1 second (waiting for rollover)...');
setTimeout(() => { setTimeout(() => {
console.log('[Poll] Triggering UI refresh after notification received');
loadPluginStatus(); loadPluginStatus();
}, 1000); // Wait 1 second for rollover to complete }, 1000); // Wait 1 second for rollover to complete
} }
@@ -480,20 +520,37 @@
// Detect if nextNotificationTime changed (rollover occurred) // Detect if nextNotificationTime changed (rollover occurred)
const currentNextTime = result.nextNotificationTime; const currentNextTime = result.nextNotificationTime;
console.log('[Poll] Comparing nextNotificationTime:', {
current: currentNextTime,
lastKnown: lastKnownNextNotificationTime,
changed: currentNextTime && currentNextTime !== lastKnownNextNotificationTime
});
if (currentNextTime && currentNextTime !== lastKnownNextNotificationTime) { if (currentNextTime && currentNextTime !== lastKnownNextNotificationTime) {
if (lastKnownNextNotificationTime !== null) { if (lastKnownNextNotificationTime !== null) {
console.log('Next notification time changed - rollover detected!'); console.log('[Poll] ⚠️ Next notification time changed - rollover detected!', {
old: lastKnownNextNotificationTime,
new: currentNextTime,
oldDate: new Date(lastKnownNextNotificationTime).toISOString(),
newDate: new Date(currentNextTime).toISOString()
});
// Force immediate refresh // Force immediate refresh
loadPluginStatus(); loadPluginStatus();
} else {
console.log('[Poll] Initializing lastKnownNextNotificationTime:', currentNextTime);
} }
lastKnownNextNotificationTime = currentNextTime; lastKnownNextNotificationTime = currentNextTime;
} else {
console.log('[Poll] No change detected in nextNotificationTime');
} }
// Auto-refresh plugin status periodically to show updated next notification time after rollover // Auto-refresh plugin status periodically to show updated next notification time after rollover
// This ensures the UI updates when the plugin reschedules the notification // This ensures the UI updates when the plugin reschedules the notification
console.log('[Poll] Triggering periodic UI refresh');
loadPluginStatus(); loadPluginStatus();
}) })
.catch(error => { .catch(error => {
console.error('[Poll] Status check failed:', error);
// Silently fail - this is just for visual feedback // Silently fail - this is just for visual feedback
}); });
} }