Merge pull request #71 from wagesj45/codex/update-thunderbird-panel-and-background.js

Restore automatic panel popup
This commit is contained in:
Jordan Wages 2025-07-06 02:36:52 -05:00 committed by GitHub
commit 713a75eaae
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 17 additions and 29 deletions

View file

@ -334,18 +334,6 @@ async function clearCacheForMessages(idsInput) {
browser.messageDisplayAction.setLabel({ label: "Details" }); browser.messageDisplayAction.setLabel({ label: "Details" });
} }
browser.messageDisplayAction.onClicked.addListener(async (tab) => {
const header = await browser.messageDisplay.getDisplayedMessage(tab.id);
if (!header) {
console.warn("[Sortana] no displayed message in tab", tab.id);
return;
}
const popupUrl = `${browser.runtime.getURL("details.html")}?mid=${header.id}`;
await browser.messageDisplayAction.setPopup({ tabId: tab.id, popup: popupUrl });
await browser.messageDisplayAction.openPopup({ tabId: tab.id });
});
} }
browser.menus.create({ browser.menus.create({
@ -393,7 +381,7 @@ async function clearCacheForMessages(idsInput) {
(info.messageId ? [info.messageId] : []); (info.messageId ? [info.messageId] : []);
await clearCacheForMessages(ids); await clearCacheForMessages(ids);
} else if (info.menuItemId === "view-ai-reason-list" || info.menuItemId === "view-ai-reason-display") { } else if (info.menuItemId === "view-ai-reason-list" || info.menuItemId === "view-ai-reason-display") {
const header = await browser.messageDisplay.getDisplayedMessage(tab.id); const [header] = await browser.messageDisplay.getDisplayedMessages(tab.id);
if (!header) { return; } if (!header) { return; }
const url = `${browser.runtime.getURL("details.html")}?mid=${header.id}`; const url = `${browser.runtime.getURL("details.html")}?mid=${header.id}`;

View file

@ -1,22 +1,21 @@
document.addEventListener('DOMContentLoaded', async () => { document.addEventListener("DOMContentLoaded", async () => {
const logger = (await import(browser.runtime.getURL('logger.js'))).aiLog; const aiLog = (await import(browser.runtime.getURL("logger.js"))).aiLog;
const midParam = new URLSearchParams(location.search).get('mid'); const qMid = parseInt(new URLSearchParams(location.search).get("mid"), 10);
const messageId = parseInt(midParam, 10); if (!isNaN(qMid)) {
loadMessage(qMid);
if (!messageId) {
logger('no ?mid → trying displayedMessage fallback');
const openerTabId = (await browser.tabs.getCurrent()).openerTabId;
const header = await browser.messageDisplay.getDisplayedMessage(openerTabId);
if (!header) {
logger('still no message aborting');
return; return;
} }
const thisTab = await browser.tabs.getCurrent();
const baseTabId = thisTab.openerTabId ?? thisTab.id;
const [header] = await browser.messageDisplay.getDisplayedMessages(baseTabId);
if (header) {
loadMessage(header.id); loadMessage(header.id);
return; } else {
aiLog("Details popup: no displayed message found");
} }
loadMessage(messageId);
}); });
async function loadMessage(id) { async function loadMessage(id) {

View file

@ -24,7 +24,8 @@
"message_display_action": { "message_display_action": {
"default_icon": "resources/img/brain.png", "default_icon": "resources/img/brain.png",
"default_title": "Details", "default_title": "Details",
"default_label": "Details" "default_label": "Details",
"default_popup": "details.html"
}, },
"background": { "scripts": [ "background.js" ] }, "background": { "scripts": [ "background.js" ] },
"options_ui": { "options_ui": {