From 8c03ad008e67833c7a2c954deaa2fce440541162 Mon Sep 17 00:00:00 2001 From: Jordan Wages Date: Sun, 29 Jun 2025 03:16:12 -0500 Subject: [PATCH] Add queue count stat to maintenance page --- background.js | 2 ++ options/options.html | 1 + options/options.js | 14 ++++++++++++++ 3 files changed, 17 insertions(+) diff --git a/background.js b/background.js index b49e691..781b9df 100644 --- a/background.js +++ b/background.js @@ -388,6 +388,8 @@ async function clearCacheForMessages(idsInput) { logger.aiLog("failed to clear cache for message", { level: 'error' }, e); return { ok: false }; } + } else if (msg?.type === "sortana:getQueueCount") { + return { count: queuedCount + (processing ? 1 : 0) }; } else { logger.aiLog("Unknown message type, ignoring", {level: 'warn'}, msg?.type); } diff --git a/options/options.html b/options/options.html index f776fa2..6ddefa7 100644 --- a/options/options.html +++ b/options/options.html @@ -179,6 +179,7 @@ Rule count Cache entries + Queue items diff --git a/options/options.js b/options/options.js index 5536ad5..7c1e595 100644 --- a/options/options.js +++ b/options/options.js @@ -304,8 +304,22 @@ document.addEventListener('DOMContentLoaded', async () => { const ruleCountEl = document.getElementById('rule-count'); const cacheCountEl = document.getElementById('cache-count'); + const queueCountEl = document.getElementById('queue-count'); ruleCountEl.textContent = (defaults.aiRules || []).length; cacheCountEl.textContent = defaults.aiCache ? Object.keys(defaults.aiCache).length : 0; + + async function refreshQueueCount() { + try { + const { count } = await browser.runtime.sendMessage({ type: 'sortana:getQueueCount' }); + queueCountEl.textContent = count; + } catch (e) { + queueCountEl.textContent = '?'; + } + } + + refreshQueueCount(); + setInterval(refreshQueueCount, 2000); + document.getElementById('clear-cache').addEventListener('click', async () => { await AiClassifier.clearCache(); cacheCountEl.textContent = '0';