Merge pull request #56 from wagesj45/codex/add-maintenance-tab-to-options-page
Add maintenance tab
This commit is contained in:
commit
82c6d86046
4 changed files with 36 additions and 2 deletions
|
@ -24,6 +24,7 @@ message meets a specified criterion.
|
|||
- **Context menu** – apply AI rules from the message list or the message display action button.
|
||||
- **Status icons** – toolbar icons show when classification is in progress and briefly display success or error states.
|
||||
- **Packaging script** – `build-xpi.ps1` builds an XPI ready for installation.
|
||||
- **Maintenance tab** – view rule counts, cache entries and clear cached results from the options page.
|
||||
|
||||
### Cache Storage
|
||||
|
||||
|
|
|
@ -312,6 +312,17 @@ async function removeCacheEntries(keys = []) {
|
|||
}
|
||||
}
|
||||
|
||||
async function clearCache() {
|
||||
if (!gCacheLoaded) {
|
||||
await loadCache();
|
||||
}
|
||||
if (gCache.size > 0) {
|
||||
gCache.clear();
|
||||
await saveCache();
|
||||
aiLog(`[AiClassifier] Cleared cache`, {debug: true});
|
||||
}
|
||||
}
|
||||
|
||||
function classifyTextSync(text, criterion, cacheKey = null) {
|
||||
if (!Services?.tm?.spinEventLoopUntil) {
|
||||
throw new Error("classifyTextSync requires Services");
|
||||
|
@ -396,4 +407,4 @@ async function init() {
|
|||
await loadCache();
|
||||
}
|
||||
|
||||
export { classifyText, classifyTextSync, setConfig, removeCacheEntries, getReason, getCachedResult, buildCacheKey, buildCacheKeySync, init };
|
||||
export { classifyText, classifyTextSync, setConfig, removeCacheEntries, clearCache, getReason, getCachedResult, buildCacheKey, buildCacheKeySync, init };
|
||||
|
|
|
@ -46,6 +46,7 @@
|
|||
<ul>
|
||||
<li class="is-active" data-tab="settings"><a>Settings</a></li>
|
||||
<li data-tab="rules"><a>Rules</a></li>
|
||||
<li data-tab="maintenance"><a>Maintenance</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -171,6 +172,17 @@
|
|||
<div id="rules-container"></div>
|
||||
<button class="button is-link" id="add-rule" type="button">Add Rule</button>
|
||||
</div>
|
||||
|
||||
<div id="maintenance-tab" class="tab-content is-hidden">
|
||||
<h2 class="title is-4">Maintenance</h2>
|
||||
<table class="table is-fullwidth">
|
||||
<tbody>
|
||||
<tr><th>Rule count</th><td id="rule-count"></td></tr>
|
||||
<tr><th>Cache entries</th><td id="cache-count"></td></tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<button class="button is-danger" id="clear-cache" type="button">Clear Cache</button>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<script src="options.js"></script>
|
||||
|
|
|
@ -9,7 +9,8 @@ document.addEventListener('DOMContentLoaded', async () => {
|
|||
'customSystemPrompt',
|
||||
'aiParams',
|
||||
'debugLogging',
|
||||
'aiRules'
|
||||
'aiRules',
|
||||
'aiCache'
|
||||
]);
|
||||
const tabButtons = document.querySelectorAll('#main-tabs li');
|
||||
const tabs = document.querySelectorAll('.tab-content');
|
||||
|
@ -300,6 +301,15 @@ document.addEventListener('DOMContentLoaded', async () => {
|
|||
if (r.stopProcessing) rule.stopProcessing = true;
|
||||
return rule;
|
||||
}));
|
||||
|
||||
const ruleCountEl = document.getElementById('rule-count');
|
||||
const cacheCountEl = document.getElementById('cache-count');
|
||||
ruleCountEl.textContent = (defaults.aiRules || []).length;
|
||||
cacheCountEl.textContent = defaults.aiCache ? Object.keys(defaults.aiCache).length : 0;
|
||||
document.getElementById('clear-cache').addEventListener('click', async () => {
|
||||
await AiClassifier.clearCache();
|
||||
cacheCountEl.textContent = '0';
|
||||
});
|
||||
initialized = true;
|
||||
|
||||
document.getElementById('save').addEventListener('click', async () => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue