Merge pull request #34 from wagesj45/codex/fix-error-in-add-on-loading

Fix message display context for menu
This commit is contained in:
Jordan Wages 2025-06-25 15:12:13 -05:00 committed by GitHub
commit a154029320
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 14 additions and 2 deletions

View file

@ -20,7 +20,7 @@ message meets a specified criterion.
- **Advanced parameters** tune generation settings like temperature, topp and more from the options page. - **Advanced parameters** tune generation settings like temperature, topp and more from the options page.
- **Debug logging** optional colorized logs help troubleshoot interactions with the AI service. - **Debug logging** optional colorized logs help troubleshoot interactions with the AI service.
- **Automatic rules** create rules that tag or move new messages based on AI classification. - **Automatic rules** create rules that tag or move new messages based on AI classification.
- **Context menu** apply AI rules to selected messages from the message list or display. - **Context menu** apply AI rules from the message list or the message display action button.
- **Status icons** toolbar icons indicate when messages are queued or being classified. - **Status icons** toolbar icons indicate when messages are queued or being classified.
- **Packaging script** `build-xpi.ps1` builds an XPI ready for installation. - **Packaging script** `build-xpi.ps1` builds an XPI ready for installation.

View file

@ -126,9 +126,21 @@ async function applyAiRules(idsInput) {
browser.menus.create({ browser.menus.create({
id: "apply-ai-rules-display", id: "apply-ai-rules-display",
title: "Apply AI Rules", title: "Apply AI Rules",
contexts: ["message_display"], contexts: ["message_display_action"],
}); });
if (browser.messageDisplayAction) {
browser.messageDisplayAction.onClicked.addListener(async (tab) => {
try {
const msgs = await browser.messageDisplay.getDisplayedMessages(tab.id);
const ids = msgs.map(m => m.id);
await applyAiRules(ids);
} catch (e) {
logger.aiLog("failed to apply AI rules from action", { level: 'error' }, e);
}
});
}
browser.menus.onClicked.addListener(async info => { browser.menus.onClicked.addListener(async info => {
if (info.menuItemId === "apply-ai-rules-list" || info.menuItemId === "apply-ai-rules-display") { if (info.menuItemId === "apply-ai-rules-list" || info.menuItemId === "apply-ai-rules-display") {
const ids = info.selectedMessages?.ids || (info.messageId ? [info.messageId] : []); const ids = info.selectedMessages?.ids || (info.messageId ? [info.messageId] : []);