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.
|
- **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.
|
- **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.
|
- **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
|
### 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) {
|
function classifyTextSync(text, criterion, cacheKey = null) {
|
||||||
if (!Services?.tm?.spinEventLoopUntil) {
|
if (!Services?.tm?.spinEventLoopUntil) {
|
||||||
throw new Error("classifyTextSync requires Services");
|
throw new Error("classifyTextSync requires Services");
|
||||||
|
@ -396,4 +407,4 @@ async function init() {
|
||||||
await loadCache();
|
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>
|
<ul>
|
||||||
<li class="is-active" data-tab="settings"><a>Settings</a></li>
|
<li class="is-active" data-tab="settings"><a>Settings</a></li>
|
||||||
<li data-tab="rules"><a>Rules</a></li>
|
<li data-tab="rules"><a>Rules</a></li>
|
||||||
|
<li data-tab="maintenance"><a>Maintenance</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -171,6 +172,17 @@
|
||||||
<div id="rules-container"></div>
|
<div id="rules-container"></div>
|
||||||
<button class="button is-link" id="add-rule" type="button">Add Rule</button>
|
<button class="button is-link" id="add-rule" type="button">Add Rule</button>
|
||||||
</div>
|
</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>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
<script src="options.js"></script>
|
<script src="options.js"></script>
|
||||||
|
|
|
@ -9,7 +9,8 @@ document.addEventListener('DOMContentLoaded', async () => {
|
||||||
'customSystemPrompt',
|
'customSystemPrompt',
|
||||||
'aiParams',
|
'aiParams',
|
||||||
'debugLogging',
|
'debugLogging',
|
||||||
'aiRules'
|
'aiRules',
|
||||||
|
'aiCache'
|
||||||
]);
|
]);
|
||||||
const tabButtons = document.querySelectorAll('#main-tabs li');
|
const tabButtons = document.querySelectorAll('#main-tabs li');
|
||||||
const tabs = document.querySelectorAll('.tab-content');
|
const tabs = document.querySelectorAll('.tab-content');
|
||||||
|
@ -300,6 +301,15 @@ document.addEventListener('DOMContentLoaded', async () => {
|
||||||
if (r.stopProcessing) rule.stopProcessing = true;
|
if (r.stopProcessing) rule.stopProcessing = true;
|
||||||
return rule;
|
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;
|
initialized = true;
|
||||||
|
|
||||||
document.getElementById('save').addEventListener('click', async () => {
|
document.getElementById('save').addEventListener('click', async () => {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue