From c5aa576229d2ea7a82052383228e39fc0bc740ee Mon Sep 17 00:00:00 2001 From: mic Date: Mon, 2 Mar 2026 21:52:59 +0100 Subject: [PATCH 01/10] version set to 4.0.1_issue685 --- manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.json b/manifest.json index 03ea26aa..4dc62b2e 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.1_issue685", "author": "Mic (m@micz.it)", "homepage_url": "https://micz.it/thunderbird-addon-thunderai/", "browser_specific_settings": { From af6927c012ed72e822a37e40aaa8e0bf8147697f Mon Sep 17 00:00:00 2001 From: mic Date: Mon, 2 Mar 2026 21:55:50 +0100 Subject: [PATCH 02/10] ai win position options added --- options/mzta-options-default.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/options/mzta-options-default.js b/options/mzta-options-default.js index f2b5eb83..3bb812dc 100644 --- a/options/mzta-options-default.js +++ b/options/mzta-options-default.js @@ -99,6 +99,9 @@ export const prefs_default = { do_debug: false, chatgpt_win_height: 800, chatgpt_win_width: 700, + chatgpt_win_top: 0, + chatgpt_win_left: 0, + chatgpt_win_save_position: true, default_chatgpt_lang: '', default_sign_name: '', reply_type: 'reply_all', From a90b20052aa6c68932fa49a099ed43572543c6ce Mon Sep 17 00:00:00 2001 From: mic Date: Mon, 2 Mar 2026 22:05:05 +0100 Subject: [PATCH 03/10] saving and using windows positions. see #685 --- mzta-background.js | 45 +++++++++++++++++++++++++++++++++++---------- 1 file changed, 35 insertions(+), 10 deletions(-) diff --git a/mzta-background.js b/mzta-background.js index 18cfea21..d32fc69c 100644 --- a/mzta-background.js +++ b/mzta-background.js @@ -238,14 +238,24 @@ messenger.runtime.onMessage.addListener((message, sender, sendResponse) => { // openChatGPT(message.prompt,message.action,message.tabId); // return true; case 'chatgpt_close': - browser.windows.remove(message.window_id).then(() => { - taLog.log("ChatGPT window closed successfully."); - return true; - }).catch((error) => { - taLog.error("Error closing ChatGPT window:", error); - return false; - }); - break; + async function _closeChatGptWindow(window_id) { + let prefs_close = await browser.storage.sync.get({chatgpt_win_save_position: prefs_default.chatgpt_win_save_position}); + if(prefs_close.chatgpt_win_save_position){ + try { + let winInfo = await browser.windows.get(window_id); + await browser.storage.sync.set({chatgpt_win_top: winInfo.top, chatgpt_win_left: winInfo.left}); + taLog.log("Window position saved: top=" + winInfo.top + ", left=" + winInfo.left); + } catch(e) { + taLog.error("Error saving window position: " + e); + } + } + return browser.windows.remove(window_id).then(() => { + taLog.log("ChatGPT window closed successfully."); + }).catch((error) => { + taLog.error("Error closing ChatGPT window:", error); + }); + } + return _closeChatGptWindow(message.window_id); case 'chatgpt_replaceSelectedText': async function _replaceSelectedText(tabId, text) { //console.log('chatgpt_replaceSelectedText: [' + tabId +'] ' + text) @@ -477,6 +487,7 @@ async function openChatGPT(promptText, action, curr_tabId, prompt_name = '', do_ win_options.width = prefs.chatgpt_win_width, win_options.height = prefs.chatgpt_win_height } + applyWindowPosition(win_options, prefs); const listener = (message, sender, sendResponse) => { async function handleChatGptWeb(createdTab) { @@ -580,6 +591,7 @@ async function openChatGPT(promptText, action, curr_tabId, prompt_name = '', do_ win_options2.width = prefs.chatgpt_win_width, win_options2.height = prefs.chatgpt_win_height } + applyWindowPosition(win_options2, prefs); await browser.windows.create(win_options2); } @@ -631,6 +643,7 @@ async function openChatGPT(promptText, action, curr_tabId, prompt_name = '', do_ win_options5.width = prefs.chatgpt_win_width, win_options5.height = prefs.chatgpt_win_height } + applyWindowPosition(win_options5, prefs); await browser.windows.create(win_options5); } @@ -689,6 +702,7 @@ async function openChatGPT(promptText, action, curr_tabId, prompt_name = '', do_ win_options3.width = prefs.chatgpt_win_width, win_options3.height = prefs.chatgpt_win_height } + applyWindowPosition(win_options3, prefs); await browser.windows.create(win_options3); @@ -742,7 +756,8 @@ async function openChatGPT(promptText, action, curr_tabId, prompt_name = '', do_ win_options4.width = prefs.chatgpt_win_width, win_options4.height = prefs.chatgpt_win_height } - + applyWindowPosition(win_options4, prefs); + await browser.windows.create(win_options4); } break; // openai_comp_api - END @@ -797,6 +812,7 @@ async function openChatGPT(promptText, action, curr_tabId, prompt_name = '', do_ win_options5.width = prefs.chatgpt_win_width, win_options5.height = prefs.chatgpt_win_height } + applyWindowPosition(win_options5, prefs); await browser.windows.create(win_options5); } @@ -814,10 +830,19 @@ function checkScreenDimensions(prefs){ if(prefs.chatgpt_win_height > height) prefs.chatgpt_win_height = height - 50; if(prefs.chatgpt_win_width > width) prefs.chatgpt_win_width = width - 50; - + return prefs; } +function applyWindowPosition(win_options, prefs){ + if(prefs.chatgpt_win_save_position && (prefs.chatgpt_win_top != 0) && (prefs.chatgpt_win_left != 0)){ + win_options.top = prefs.chatgpt_win_top; + win_options.left = prefs.chatgpt_win_left; + taLog.log("Applying saved window position: top=" + prefs.chatgpt_win_top + ", left=" + prefs.chatgpt_win_left); + } + return win_options; +} + function doGetSparkFeature(spark_feature_active) { if(spark_feature_active) { return (_sparks_presence == 1); From 79712957a35768a6a8b58f0b7ffe71065bc6de28 Mon Sep 17 00:00:00 2001 From: mic Date: Tue, 3 Mar 2026 21:24:57 +0100 Subject: [PATCH 04/10] applyWindowPosition renamed to applyWindowPositionAndSize --- mzta-background.js | 55 ++++++++++------------------------------------ 1 file changed, 12 insertions(+), 43 deletions(-) diff --git a/mzta-background.js b/mzta-background.js index d32fc69c..f458868b 100644 --- a/mzta-background.js +++ b/mzta-background.js @@ -481,13 +481,7 @@ async function openChatGPT(promptText, action, curr_tabId, prompt_name = '', do_ type: "popup", } - taLog.log("[chatgpt_web] 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_options.width = prefs.chatgpt_win_width, - win_options.height = prefs.chatgpt_win_height - } - applyWindowPosition(win_options, prefs); + applyWindowPositionAndSize(win_options, prefs); const listener = (message, sender, sendResponse) => { async function handleChatGptWeb(createdTab) { @@ -585,13 +579,7 @@ async function openChatGPT(promptText, action, curr_tabId, prompt_name = '', do_ 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_options2.width = prefs.chatgpt_win_width, - win_options2.height = prefs.chatgpt_win_height - } - applyWindowPosition(win_options2, prefs); + applyWindowPositionAndSize(win_options2, prefs); await browser.windows.create(win_options2); } @@ -637,13 +625,7 @@ async function openChatGPT(promptText, action, curr_tabId, prompt_name = '', do_ type: "popup", } - taLog.log("[google_gemini_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 - } - applyWindowPosition(win_options5, prefs); + applyWindowPositionAndSize(win_options5, prefs); await browser.windows.create(win_options5); } @@ -696,13 +678,7 @@ async function openChatGPT(promptText, action, curr_tabId, prompt_name = '', do_ type: "popup", } - taLog.log("[ollama_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_options3.width = prefs.chatgpt_win_width, - win_options3.height = prefs.chatgpt_win_height - } - applyWindowPosition(win_options3, prefs); + applyWindowPositionAndSize(win_options3, prefs); await browser.windows.create(win_options3); @@ -750,13 +726,7 @@ async function openChatGPT(promptText, action, curr_tabId, prompt_name = '', do_ type: "popup", } - taLog.log("[openai_comp_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_options4.width = prefs.chatgpt_win_width, - win_options4.height = prefs.chatgpt_win_height - } - applyWindowPosition(win_options4, prefs); + applyWindowPositionAndSize(win_options4, prefs); await browser.windows.create(win_options4); } @@ -806,13 +776,7 @@ async function openChatGPT(promptText, action, curr_tabId, prompt_name = '', do_ 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 - } - applyWindowPosition(win_options5, prefs); + applyWindowPositionAndSize(win_options5, prefs); await browser.windows.create(win_options5); } @@ -834,7 +798,12 @@ function checkScreenDimensions(prefs){ return prefs; } -function applyWindowPosition(win_options, prefs){ +function applyWindowPositionAndSize(win_options, prefs){ + if((prefs.chatgpt_win_width != '') && (prefs.chatgpt_win_height != '') && (prefs.chatgpt_win_width != 0) && (prefs.chatgpt_win_height != 0)){ + win_options.width = prefs.chatgpt_win_width; + win_options.height = prefs.chatgpt_win_height; + taLog.log("Applying saved window dimensions: width=" + prefs.chatgpt_win_width + ", height=" + prefs.chatgpt_win_height); + } if(prefs.chatgpt_win_save_position && (prefs.chatgpt_win_top != 0) && (prefs.chatgpt_win_left != 0)){ win_options.top = prefs.chatgpt_win_top; win_options.left = prefs.chatgpt_win_left; From 60d4425f9b30c7b188e20ae9f3f4f796e41cea1e Mon Sep 17 00:00:00 2001 From: mic Date: Tue, 3 Mar 2026 21:25:35 +0100 Subject: [PATCH 05/10] top and left are blank by default --- mzta-background.js | 2 +- options/mzta-options-default.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/mzta-background.js b/mzta-background.js index f458868b..dd82c479 100644 --- a/mzta-background.js +++ b/mzta-background.js @@ -804,7 +804,7 @@ function applyWindowPositionAndSize(win_options, prefs){ win_options.height = prefs.chatgpt_win_height; taLog.log("Applying saved window dimensions: width=" + prefs.chatgpt_win_width + ", height=" + prefs.chatgpt_win_height); } - if(prefs.chatgpt_win_save_position && (prefs.chatgpt_win_top != 0) && (prefs.chatgpt_win_left != 0)){ + if(prefs.chatgpt_win_save_position && (prefs.chatgpt_win_top != '') && (prefs.chatgpt_win_left != '')){ win_options.top = prefs.chatgpt_win_top; win_options.left = prefs.chatgpt_win_left; taLog.log("Applying saved window position: top=" + prefs.chatgpt_win_top + ", left=" + prefs.chatgpt_win_left); diff --git a/options/mzta-options-default.js b/options/mzta-options-default.js index 3bb812dc..50b1b226 100644 --- a/options/mzta-options-default.js +++ b/options/mzta-options-default.js @@ -99,8 +99,8 @@ export const prefs_default = { do_debug: false, chatgpt_win_height: 800, chatgpt_win_width: 700, - chatgpt_win_top: 0, - chatgpt_win_left: 0, + chatgpt_win_top: '', + chatgpt_win_left: '', chatgpt_win_save_position: true, default_chatgpt_lang: '', default_sign_name: '', From eadc69d7551a33c7f6377744a690b35e1f31e6e8 Mon Sep 17 00:00:00 2001 From: mic Date: Tue, 3 Mar 2026 23:30:14 +0100 Subject: [PATCH 06/10] ai win positions options added to the prefs page. see #685 --- _locales/en/messages.json | 20 ++++++++++++++++++++ options/mzta-options.css | 6 +----- options/mzta-options.html | 27 +++++++++++++++++++++++++-- 3 files changed, 46 insertions(+), 7 deletions(-) diff --git a/_locales/en/messages.json b/_locales/en/messages.json index bfc1d731..4a1b7ace 100644 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -1908,5 +1908,25 @@ "prefs_THStats_2": { "message": "Click here! Try ThunderStats!", "description": "" + }, + "prefs_OptionText_chatgpt_win_pos_text":{ + "message": "AI chat window position", + "description": "" + }, + "prefs_OptionText_chatgpt_win_top":{ + "message": "Top", + "description": "" + }, + "prefs_OptionText_chatgpt_win_left":{ + "message": "Left", + "description": "" + }, + "prefs_chatgpt_win_save_position": { + "message": "Automatically save the window position when using the close button.", + "description": "" + }, + "prefs_chatgpt_win_position_info":{ + "message": "Leave empty to use the default position.", + "description": "" } } diff --git a/options/mzta-options.css b/options/mzta-options.css index 37b55c20..4db12b2f 100644 --- a/options/mzta-options.css +++ b/options/mzta-options.css @@ -69,11 +69,7 @@ div#miczDescription p{ margin-top: 0px; } -input#chatgpt_win_width{ - width: 100px; -} - -input#chatgpt_win_height{ +input.win_prop{ width: 100px; } diff --git a/options/mzta-options.html b/options/mzta-options.html index 449d4320..3e8be70c 100644 --- a/options/mzta-options.html +++ b/options/mzta-options.html @@ -28,7 +28,7 @@ @@ -36,7 +36,30 @@ __MSG_prefs_OptionText_chatgpt_win_dims_info__ __MSG_prefs_OptionText_chatgpt_win_width__ - + + + + + __MSG_prefs_OptionText_chatgpt_win_pos_text__ + + + + + + __MSG_prefs_chatgpt_win_position_info__ + + __MSG_prefs_OptionText_chatgpt_win_left__ + + + + +   + + + __MSG_prefs_chatgpt_win_save_position__ From 7176880589d07be9bdf607f1e8fe262b3d53182b Mon Sep 17 00:00:00 2001 From: mic Date: Tue, 3 Mar 2026 23:30:35 +0100 Subject: [PATCH 07/10] version set to 4.0.1_issue685_rev2 --- manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.json b/manifest.json index 4dc62b2e..936a44da 100644 --- a/manifest.json +++ b/manifest.json @@ -2,7 +2,7 @@ "manifest_version": 2, "name": "ThunderAI", "description": "__MSG_extensionDescription__", - "version": "4.0.1_issue685", + "version": "4.0.1_issue685_rev2", "author": "Mic (m@micz.it)", "homepage_url": "https://micz.it/thunderbird-addon-thunderai/", "browser_specific_settings": { From 17572a573f8e67336a1b23b7ecf7854bda15cea8 Mon Sep 17 00:00:00 2001 From: mic Date: Wed, 4 Mar 2026 21:41:02 +0100 Subject: [PATCH 08/10] default value changed for chatgpt_win_save_position. see #685 --- options/mzta-options-default.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/options/mzta-options-default.js b/options/mzta-options-default.js index 50b1b226..571599c4 100644 --- a/options/mzta-options-default.js +++ b/options/mzta-options-default.js @@ -101,7 +101,7 @@ export const prefs_default = { chatgpt_win_width: 700, chatgpt_win_top: '', chatgpt_win_left: '', - chatgpt_win_save_position: true, + chatgpt_win_save_position: false, default_chatgpt_lang: '', default_sign_name: '', reply_type: 'reply_all', From 9fcfd2dad0d30bd7b2b5f1ec7cebc6ae80798c8e Mon Sep 17 00:00:00 2001 From: mic Date: Wed, 4 Mar 2026 21:44:23 +0100 Subject: [PATCH 09/10] correctly using the chatgpt_win_save_position pref. see #685 --- mzta-background.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mzta-background.js b/mzta-background.js index dd82c479..b7beef8b 100644 --- a/mzta-background.js +++ b/mzta-background.js @@ -804,7 +804,7 @@ function applyWindowPositionAndSize(win_options, prefs){ win_options.height = prefs.chatgpt_win_height; taLog.log("Applying saved window dimensions: width=" + prefs.chatgpt_win_width + ", height=" + prefs.chatgpt_win_height); } - if(prefs.chatgpt_win_save_position && (prefs.chatgpt_win_top != '') && (prefs.chatgpt_win_left != '')){ + if((prefs.chatgpt_win_top != '') && (prefs.chatgpt_win_left != '')){ win_options.top = prefs.chatgpt_win_top; win_options.left = prefs.chatgpt_win_left; taLog.log("Applying saved window position: top=" + prefs.chatgpt_win_top + ", left=" + prefs.chatgpt_win_left); @@ -836,6 +836,7 @@ async function reload_pref_init(){ spamfilter_threshold: prefs_default.spamfilter_threshold, spamfilter_show_msg_panel: prefs_default.spamfilter_show_msg_panel, dynamic_menu_force_enter: prefs_default.dynamic_menu_force_enter, + chatgpt_win_save_position: prefs_default.chatgpt_win_save_position, ...getDynamicSettingsDefaults(['use_specific_integration', 'connection_type']) }); _process_incoming = prefs_init.add_tags_auto || prefs_init.spamfilter; From 19c2258e698aa8b114fcd2cb256cfc8325780690 Mon Sep 17 00:00:00 2001 From: mic Date: Wed, 4 Mar 2026 21:48:37 +0100 Subject: [PATCH 10/10] added boundary check. see #685 --- mzta-background.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/mzta-background.js b/mzta-background.js index b7beef8b..549fcd59 100644 --- a/mzta-background.js +++ b/mzta-background.js @@ -805,8 +805,18 @@ function applyWindowPositionAndSize(win_options, prefs){ taLog.log("Applying saved window dimensions: width=" + prefs.chatgpt_win_width + ", height=" + prefs.chatgpt_win_height); } if((prefs.chatgpt_win_top != '') && (prefs.chatgpt_win_left != '')){ - win_options.top = prefs.chatgpt_win_top; - win_options.left = prefs.chatgpt_win_left; + // Check if the saved position is within the current screen bounds (supports multiple monitors) + let isWithinBounds = ( + prefs.chatgpt_win_left >= window.screen.availLeft && + prefs.chatgpt_win_top >= window.screen.availTop && + prefs.chatgpt_win_left < (window.screen.availLeft + window.screen.availWidth) && + prefs.chatgpt_win_top < (window.screen.availTop + window.screen.availHeight) + ); + + if (isWithinBounds) { + win_options.top = prefs.chatgpt_win_top; + win_options.left = prefs.chatgpt_win_left; + } taLog.log("Applying saved window position: top=" + prefs.chatgpt_win_top + ", left=" + prefs.chatgpt_win_left); } return win_options;