Fix live detector empty state (#190)

* Fix live detector empty state

* Fix live detector stale scan results
This commit is contained in:
Abdul Wahab
2026-06-01 14:44:45 -07:00
committed by GitHub
parent 3f8d002b76
commit 69b5f3af49
44 changed files with 853 additions and 224 deletions
+25 -2
View File
@@ -6088,6 +6088,10 @@ void main() {
let steerFocusRecoverTimer = null;
const STEER_PAGE_FOCUS_PAUSE_MS = 500;
let detectActive = false;
let detectScanSeq = 0;
let activeDetectScanId = null;
let pendingDetectScanId = null;
const DETECT_EMPTY_MESSAGE = 'No detector issues found.';
const PICK_PREFS_KEY = 'impeccable-live-pick';
const INTERACTION_PREFS_KEY = 'impeccable-live-interaction';
const PLACEHOLDER_DEFAULT_HEIGHT = 80;
@@ -7601,6 +7605,17 @@ void main() {
let detectReady = false; // true once detect script posts 'impeccable-ready'
let detectPendingScan = false; // scan requested before script was ready
function requestDetectScan() {
const scanId = String(++detectScanSeq);
activeDetectScanId = scanId;
pendingDetectScanId = scanId;
window.postMessage({
source: 'impeccable-command',
action: 'scan',
config: { scanId },
}, '*');
}
function toggleDetect() {
if (pendingApplyInFlight) { showManualApplyBusyToast(); return; }
detectActive = !detectActive;
@@ -7611,12 +7626,14 @@ void main() {
detectPendingScan = true;
loadDetectScript();
} else if (detectReady) {
window.postMessage({ source: 'impeccable-command', action: 'scan' }, '*');
requestDetectScan();
} else {
detectPendingScan = true;
}
} else {
window.postMessage({ source: 'impeccable-command', action: 'remove' }, '*');
activeDetectScanId = null;
pendingDetectScanId = null;
detectCount = 0;
updateGlobalBarState();
}
@@ -7686,12 +7703,18 @@ void main() {
detectReady = true;
if (detectPendingScan && detectActive) {
detectPendingScan = false;
window.postMessage({ source: 'impeccable-command', action: 'scan' }, '*');
requestDetectScan();
}
}
// Scan results arrived
if (e.data.source === 'impeccable-results') {
if (!detectActive) return;
if (activeDetectScanId && e.data.scanId !== activeDetectScanId) return;
detectCount = e.data.count || 0;
if (detectActive && pendingDetectScanId && detectCount === 0) {
showToast(DETECT_EMPTY_MESSAGE, 3200);
}
pendingDetectScanId = null;
updateGlobalBarState();
}
}