From fed850fe13b555519a61525ccc4d98a3ae531ff8 Mon Sep 17 00:00:00 2001 From: Jordan Wages Date: Wed, 25 Jun 2025 15:10:30 -0500 Subject: [PATCH] Update menu context for message display --- README.md | 2 +- background.js | 14 +++++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index f07ee24..6550542 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ message meets a specified criterion. - **Advanced parameters** – tune generation settings like temperature, top‑p and more from the options page. - **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. -- **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. - **Packaging script** – `build-xpi.ps1` builds an XPI ready for installation. diff --git a/background.js b/background.js index 57ee75b..576fc9e 100644 --- a/background.js +++ b/background.js @@ -126,9 +126,21 @@ async function applyAiRules(idsInput) { browser.menus.create({ id: "apply-ai-rules-display", 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 => { if (info.menuItemId === "apply-ai-rules-list" || info.menuItemId === "apply-ai-rules-display") { const ids = info.selectedMessages?.ids || (info.messageId ? [info.messageId] : []);