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.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({
@ -393,7 +381,7 @@ async function clearCacheForMessages(idsInput) {
(info.messageId ? [info.messageId] : []);
await clearCacheForMessages(ids);
} 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; }
const url = `${browser.runtime.getURL("details.html")}?mid=${header.id}`;

View file

@ -1,22 +1,21 @@
document.addEventListener('DOMContentLoaded', async () => {
const logger = (await import(browser.runtime.getURL('logger.js'))).aiLog;
document.addEventListener("DOMContentLoaded", async () => {
const aiLog = (await import(browser.runtime.getURL("logger.js"))).aiLog;
const midParam = new URLSearchParams(location.search).get('mid');
const messageId = parseInt(midParam, 10);
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');
const qMid = parseInt(new URLSearchParams(location.search).get("mid"), 10);
if (!isNaN(qMid)) {
loadMessage(qMid);
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);
return;
} else {
aiLog("Details popup: no displayed message found");
}
loadMessage(messageId);
});
async function loadMessage(id) {

View file

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