From d2c9797e1605280ef7a33979126d6f9594264330 Mon Sep 17 00:00:00 2001 From: mic Date: Wed, 4 Mar 2026 21:29:04 +0100 Subject: [PATCH 1/4] race condition fixed --- mzta-background.js | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/mzta-background.js b/mzta-background.js index 18cfea21..b2a8155e 100644 --- a/mzta-background.js +++ b/mzta-background.js @@ -113,25 +113,6 @@ messenger.messageDisplayScripts.register({ js: [{ file: "js/mzta-compose-script.js" }], }); -// Inject script and CSS in all already open message tabs. -let openTabs = await messenger.tabs.query(); -let messageTabs = openTabs.filter( - tab => ["mail", "messageDisplay"].includes(tab.type) -); -for (let messageTab of messageTabs) { - if((messageTab.url == undefined) || (["start.thunderbird.net","about:blank"].some(blockedUrl => messageTab.url.includes(blockedUrl)))) { - continue; - } - try { - await browser.tabs.executeScript(messageTab.id, { - file: "js/mzta-compose-script.js" - }) - } catch (error) { - console.error("[ThunderAI] Error injecting message display script:", error); - console.error("[ThunderAI] Message tab:", messageTab.url); - } -} - browser.contentScripts.register({ matches: ["https://*.chatgpt.com/*"], js: [{file: "js/mzta-chatgpt-loader.js"}], @@ -1343,4 +1324,23 @@ async function processEmails(args) { taWorkingStatus.stopWorking(); } -browser.messages.onNewMailReceived.addListener(newEmailListener, !prefs_init.add_tags_auto_only_inbox); \ No newline at end of file +browser.messages.onNewMailReceived.addListener(newEmailListener, !prefs_init.add_tags_auto_only_inbox); + +// Inject script and CSS in all already open message tabs. +let openTabs = await messenger.tabs.query(); +let messageTabs = openTabs.filter( + tab => ["mail", "messageDisplay"].includes(tab.type) +); +for (let messageTab of messageTabs) { + if((messageTab.url == undefined) || (["start.thunderbird.net","about:blank"].some(blockedUrl => messageTab.url.includes(blockedUrl)))) { + continue; + } + try { + await browser.tabs.executeScript(messageTab.id, { + file: "js/mzta-compose-script.js" + }) + } catch (error) { + console.error("[ThunderAI] Error injecting message display script:", error); + console.error("[ThunderAI] Message tab:", messageTab.url); + } +} \ No newline at end of file From 2485611f1fccc1bf4fdecad10ee5c973f7cfe94f Mon Sep 17 00:00:00 2001 From: mic Date: Wed, 4 Mar 2026 21:34:04 +0100 Subject: [PATCH 2/4] ... added to prompt name when asking for additional text --- _locales/en/messages.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_locales/en/messages.json b/_locales/en/messages.json index bfc1d731..da8f0df4 100644 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -20,7 +20,7 @@ "description": "" }, "prompt_reply_custom_command": { - "message": "Reply with command", + "message": "Reply with command...", "description": "" }, "prompt_rewrite_polite": { From a4016268050856ded5d857143a0e2aa2ef5a30c6 Mon Sep 17 00:00:00 2001 From: mic Date: Wed, 4 Mar 2026 21:35:06 +0100 Subject: [PATCH 3/4] version set to 4.0.2 --- CHANGELOG.md | 4 ++++ manifest.json | 2 +- options/mzta-release-notes.html | 4 ++++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 96f06d2f..42c63b17 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,10 @@ +

Version 4.0.2 - ??/??/2026

+
    +
  • ...
  • +

Version 4.0.1 - 27/02/2026

  • Fix: Correctly handling additional text without a placeholder [#681].
  • diff --git a/manifest.json b/manifest.json index 03ea26aa..bf606c7f 100644 --- a/manifest.json +++ b/manifest.json @@ -2,7 +2,7 @@ "manifest_version": 2, "name": "ThunderAI", "description": "__MSG_extensionDescription__", - "version": "4.0.1", + "version": "4.0.2", "author": "Mic (m@micz.it)", "homepage_url": "https://micz.it/thunderbird-addon-thunderai/", "browser_specific_settings": { diff --git a/options/mzta-release-notes.html b/options/mzta-release-notes.html index 4bbe64a7..f79f933c 100644 --- a/options/mzta-release-notes.html +++ b/options/mzta-release-notes.html @@ -7,6 +7,10 @@

    ThunderAI Release Notes

    +

    Version 4.0.2 - ??/??/2026

    +
      +
    • ...
    • +

    Version 4.0.1 - 27/02/2026

    • Fix: Correctly handling additional text without a placeholder [#681].
    • From 83a147fdeaf316bf034a228c9f8532fdd1e0ca64 Mon Sep 17 00:00:00 2001 From: mic Date: Wed, 4 Mar 2026 21:38:38 +0100 Subject: [PATCH 4/4] var name fixed --- mzta-background.js | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/mzta-background.js b/mzta-background.js index b2a8155e..a2ca3e5e 100644 --- a/mzta-background.js +++ b/mzta-background.js @@ -732,13 +732,13 @@ async function openChatGPT(promptText, action, curr_tabId, prompt_name = '', do_ { // We are using the Anthropic API - let rand_call_id5 = '_anthropic_' + generateCallID(); + let rand_call_id6 = '_anthropic_' + generateCallID(); - const listener5 = (message, sender, sendResponse) => { + const listener6 = (message, sender, sendResponse) => { function handleAnthropicApi(createdTab) { - let mailMessageId5 = -1; - if(mailMessage) mailMessageId5 = mailMessage.id; + let mailMessageId6 = -1; + if(mailMessage) mailMessageId6 = mailMessage.id; // check if the config is present, or give a message error if (prefs.anthropic_api_key == '') { @@ -754,32 +754,32 @@ async function openChatGPT(promptText, action, curr_tabId, prompt_name = '', do_ return; } //console.log(">>>>>>>>>> sender: " + JSON.stringify(sender)); - browser.tabs.sendMessage(createdTab.id, { command: "api_send", prompt: promptText, action: action, tabId: curr_tabId, mailMessageId: mailMessageId5, do_custom_text: do_custom_text, prompt_info: prompt_info}); + browser.tabs.sendMessage(createdTab.id, { command: "api_send", prompt: promptText, action: action, tabId: curr_tabId, mailMessageId: mailMessageId6, do_custom_text: do_custom_text, prompt_info: prompt_info}); taLog.log('[OpenAI ChatGPT] Connection succeded!'); - browser.runtime.onMessage.removeListener(listener5); + browser.runtime.onMessage.removeListener(listener6); } - if (message.command === "anthropic_api_ready_"+rand_call_id5) { + if (message.command === "anthropic_api_ready_"+rand_call_id6) { return handleAnthropicApi(sender.tab); } return false; } - browser.runtime.onMessage.addListener(listener5); + browser.runtime.onMessage.addListener(listener6); - let win_options5 = { - url: browser.runtime.getURL('api_webchat/index.html?llm='+prefs.connection_type+'&call_id='+rand_call_id5+'&ph_def_val='+(prefs.placeholders_use_default_value?'1':'0')+'&prompt_id='+encodeURIComponent(prompt_info.id) + '&prompt_name=' + encodeURIComponent(i18nConditionalGet(prompt_info.name))), + let win_options6 = { + url: browser.runtime.getURL('api_webchat/index.html?llm='+prefs.connection_type+'&call_id='+rand_call_id6+'&ph_def_val='+(prefs.placeholders_use_default_value?'1':'0')+'&prompt_id='+encodeURIComponent(prompt_info.id) + '&prompt_name=' + encodeURIComponent(i18nConditionalGet(prompt_info.name))), type: "popup", } taLog.log("[chatgpt_api] prefs.chatgpt_win_width: " + prefs.chatgpt_win_width + ", prefs.chatgpt_win_height: " + prefs.chatgpt_win_height); if((prefs.chatgpt_win_width != '') && (prefs.chatgpt_win_height != '') && (prefs.chatgpt_win_width != 0) && (prefs.chatgpt_win_height != 0)){ - win_options5.width = prefs.chatgpt_win_width, - win_options5.height = prefs.chatgpt_win_height + win_options6.width = prefs.chatgpt_win_width, + win_options6.height = prefs.chatgpt_win_height } - await browser.windows.create(win_options5); + await browser.windows.create(win_options6); } break; // anthropic_api - END