micz / ThunderAI

ThunderAI is a Thunderbird Addon that uses the capabilities of ChatGPT or Ollama to enhance email management.
https://micz.it/thunderbird-addon-thunderai/
GNU General Public License v3.0
36 stars 10 forks source link

Error opening the chat window in NixOS/Hyprland #137

Closed ehula closed 1 month ago

ehula commented 2 months ago

The problem

I am getting this error even though I have a paid plan:

*Information*
Attempting to connect to OpenAI ChatGPT using the API key provided and model "gpt-4o-mini"...

*You*
<Prompt>

*Chat GPT - Error*
You exceeded your current quota, please check your plan and billing details. For more information on this error, read the docs: https://platform.openai.com/docs/guides/error-codes/api-errors.

Which Operative System are you using?

Linux

Which version of Thunderbird are you using?

128.1.1esr

Which version of ThunderAI has the issue?

2.1.4

Which integration are you using?

OpenAI ChatGPT API

Anything in the Thunderbird console logs that might be useful?

No response

Additional information

No response

micz commented 2 months ago

Having a paid plan to use the ChatGPT web interface doesn't give you any credit to use the API. Sadly it's a different plan and it's pay per use: https://platform.openai.com/settings/organization/billing/overview

ehula commented 2 months ago

OK. Thanks for the reply.

So now I am trying to use the web interface (I assume this is the free version), but when I select an option like "Reply to this", it looks like a window tries to open, but it is immediately closed.

micz commented 2 months ago

May you activate the debug option, try again and post the log from Thunderbird? Open the console with CTRL+SHIFT+J. Thank you.

ehula commented 2 months ago

Sure. Here you go.

[ThunderAI Logger | mzta-background] [ThunderAI] Prompt length: 355 mzta-logger.js:35:44
sizeToContent() is deprecated and will be removed in the future. ext-mail.js:1581:18
Content-Security-Policy: Couldn’t process unknown directive ‘report-to’ chatgpt.com
XrayWrapper denied access to property "length" (reason: object is not safely Xrayable). See https://developer.mozilla.org/en-US/docs/Xray_vision for more information. Note that only the first denied property access from a given global object will be reported. index.js:6380:21
Content-Security-Policy: The page’s settings blocked an inline script (script-src-elem) from being executed because it violates the following directive: “script-src-elem 'self' 'nonce-d6ffe229-52b6-449d-8ad6-025ca506fc1c' 'sha256-eMuh8xiwcX72rRYNAGENurQBAcH7kLlAUQcoOri3BIo=' https://auth0.openai.com https://challenges.cloudflare.com https://chatgpt.com/ces https://*.chatgpt.com https://*.chatgpt.com/ https://*.oaistatic.com https://apis.google.com https://chat.openai.com https://chatgpt.com https://chatgpt.com/ https://chatgpt.com/backend-anon https://chatgpt.com/backend-api https://chatgpt.com/backend/se https://chatgpt.com/graphql https://chatgpt.com/public-api https://chatgpt.com/voice https://docs.google.com https://js.live.net/v7.2/OneDrive.js https://oaistatic.com https://snc.apps.openai.com https://tcr9i.chat.openai.com https://tcr9i.chatgpt.com/ https://www-onepick-opensocial.googleusercontent.com wss://*.chatgpt.com wss://*.chatgpt.com/” index.js:6167:27
The resource at “https://browser-intake-datadoghq.com/api/v2/logs?dd-api-key=pub1f79f8ac903a5872ae5f53026d20a77c&dd-evp-origin=content-security-policy&ddsource=csp-report&ddtags=version%3Achatgpt-csp-new” was blocked by OpaqueResponseBlocking. Reason: “nosniff is true and mimeType is an opaque-blocklisted MIME type or its essence is 'text/plain'”.
A resource is blocked by OpaqueResponseBlocking, please check browser console for details. logs
Some cookies are misusing the recommended “SameSite“ attribute 2
Ignoring unsupported entryTypes: layout-shift. kx5kvg0igqglf8xo.js:463:24092
Ignoring unsupported entryTypes: longtask. kx5kvg0igqglf8xo.js:463:24249
Error: Minified React error #418; visit https://reactjs.org/docs/error-decoder.html?invariant=418 for the full message or use the non-minified dev environment for full errors and additional helpful warnings.
    RA https://cdn.oaistatic.com/assets/kx5kvg0igqglf8xo.js:39
    F8 https://cdn.oaistatic.com/assets/kx5kvg0igqglf8xo.js:41
    N8 https://cdn.oaistatic.com/assets/kx5kvg0igqglf8xo.js:41
    Fee https://cdn.oaistatic.com/assets/kx5kvg0igqglf8xo.js:41
    P8 https://cdn.oaistatic.com/assets/kx5kvg0igqglf8xo.js:41
    S https://cdn.oaistatic.com/assets/kx5kvg0igqglf8xo.js:26
    k https://cdn.oaistatic.com/assets/kx5kvg0igqglf8xo.js:26
kx5kvg0igqglf8xo.js:463:5179
Uncaught Error: Minified React error #418; visit https://reactjs.org/docs/error-decoder.html?invariant=418 for the full message or use the non-minified dev environment for full errors and additional helpful warnings.
    RA https://cdn.oaistatic.com/assets/kx5kvg0igqglf8xo.js:39
    F8 https://cdn.oaistatic.com/assets/kx5kvg0igqglf8xo.js:41
    N8 https://cdn.oaistatic.com/assets/kx5kvg0igqglf8xo.js:41
    Fee https://cdn.oaistatic.com/assets/kx5kvg0igqglf8xo.js:41
    P8 https://cdn.oaistatic.com/assets/kx5kvg0igqglf8xo.js:41
    S https://cdn.oaistatic.com/assets/kx5kvg0igqglf8xo.js:26
    k https://cdn.oaistatic.com/assets/kx5kvg0igqglf8xo.js:26
22 kx5kvg0igqglf8xo.js:39:4820
Uncaught Error: Minified React error #423; visit https://reactjs.org/docs/error-decoder.html?invariant=423 for the full message or use the non-minified dev environment for full errors and additional helpful warnings.
    F8 https://cdn.oaistatic.com/assets/kx5kvg0igqglf8xo.js:41
    N8 https://cdn.oaistatic.com/assets/kx5kvg0igqglf8xo.js:41
    $ee https://cdn.oaistatic.com/assets/kx5kvg0igqglf8xo.js:41
    _E https://cdn.oaistatic.com/assets/kx5kvg0igqglf8xo.js:41
    BA https://cdn.oaistatic.com/assets/kx5kvg0igqglf8xo.js:41
    P8 https://cdn.oaistatic.com/assets/kx5kvg0igqglf8xo.js:41
    S https://cdn.oaistatic.com/assets/kx5kvg0igqglf8xo.js:26
    k https://cdn.oaistatic.com/assets/kx5kvg0igqglf8xo.js:26
kx5kvg0igqglf8xo.js:41:45333
WebExtensions: Window manager refused to set window to state 3. ext-mail.js:1619​
micz commented 2 months ago

The problem is only in the last line. I checked the Thunderbird code referenced by that error. It seems that your windows manager is refusing to let Thunderbird set the popup window. Which distro and windows manager are you using?

ehula commented 2 months ago

I am running NixOS and the hyprland compositor/window manager.

micz commented 2 months ago

It's not the first time this has happened. Please take a look here to see if you find anything useful: https://github.com/micz/ThunderAI/issues/90.

I have another question. When using the OpenAI API, does the popup window stay open? But with the web interface, does it close? Have you changed the window dimensions in the options?

ehula commented 2 months ago

I looked at the link you supplied, but there was nothing that helped.

I can't get a window to open using the API option or the web option. I was able to once, which is how I was able to provide the original error message, but I can't get a window to open now using either option. The window always immediately closes.

I have not changed the window dimensions in the options.

micz commented 2 months ago

The problem seems to be related to Thunderbird and NixOS/Hyprland, I filed this bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1920523.

If I release a test version that prevents the new window from resizing and attach it here, would you be willing to try it?

ehula commented 2 months ago

Thanks for following up. Sure, I would test it for you.

micz commented 2 months ago

You can find here version 2.1.5_nixos_rev1. Please follow this steps:

  1. Download the file thunderai-v2.1.5_nixos_rev1.zip
  2. Rename it from .zip to .xpi
  3. Backup your custom prompts if you have any
  4. Install this version
  5. Try to run a prompt using the ChatGPT Web Interface (I have modified only this one)

This version does not set the dimensions when opening the new window.

ehula commented 2 months ago

Perfect! That worked!

micz commented 2 months ago

Ok, thank you for the feedback. I need to add that conditionally in the code.

If you can, I'll ask you to test the final pre-release of version 2.2.0 to make sure everything is correct. I'll followup here. Thank you.

ehula commented 2 months ago

Of course. No problem. Thanks for making a great and useful extension.

ehula commented 2 months ago

Each time ThunderAI calls OpenAI, a new chat is created.

Is it possible to have the chat be deleted manually or automatically either with an option in the Preferences: Automatically delete chat when done [ ]

Or with the following buttons depending on context: Close & Delete Chat Use the selected answer & Delete Chat

micz commented 2 months ago

What you are describing is what should happen. When you click the close button and the chat window remains open, could you check the logs for any errors?

ehula commented 2 months ago

When I click the Close button, the chat window does close. I am talking about the "chat" item in my ChatGPT account that remains and creates unnecessary and useless clutter. Because it is a transitory one-time action, I would like that chat item to be deleted when I click Close. Is that possible?

micz commented 2 months ago

Because it is a transitory one-time action, I would like that chat item to be deleted when I click Close. Is that possible?

I'm sorry, there is no way to do this.

micz commented 2 months ago

I've released version 2.2.0pre4, which should work. Get it from here: https://github.com/micz/ThunderAI/releases/tag/v2.2.0pre4

You need to set the dimensions to 0 on the options page. Let me know if this works. Thank you.

ehula commented 2 months ago

With v2.2.0pre4, I cannot see any items in the AI drop down menu. The menu is just all black. For reference, the More menu beside the AI menu works just fine.

micz commented 2 months ago

May you post a screenshot? In the log there is an error? Are you using the default dark theme or another theme? What happens if you open the menu with the shortcut and then press 1 and enter? Thank you.

Mikilio commented 2 months ago

Original author of #90 here. I also filed a bug at Hyprland for this. @ehula it would be nice if you could link your Mozilla issue over there, so the maintainers take it more seriously. https://github.com/hyprwm/Hyprland/issues/6965 These issues tend to become stale otherwise because the story isn't clear and especially with Hyprland people will just assume bad configuration before anything else.

micz commented 1 month ago

@Mikilio I was waiting for positive feedback on this issue before contacting you on #90 to update you about the workaround.

@ehula, could you provide feedback on the questions mentioned in this comment? I tried to install NixOS on VirtualBox to replicate the error, but Hyprland keeps crashing.

ehula commented 1 month ago

I can't take a screenshot. Once I invoke a screenshot command (grimblast), the menu closes.

The menu looks like it is getting drawn properly. The border and background are the correct colours, but there is not text in the menu. When I hover my mouse over the menu, it changes to a finger cursor indicating something that can be clicked, but only for what seems might be two of a possible 5-6 menu items.

>>>>>>>> menus.shortcutMenu: [{"id":"prompt_classify","label":"Classify","type":"0"},{"id":"prompt_reply","label":"Reply to this","type":"1"},{"id":"prompt_rewrite_formal","label":"Rewrite formal","type":"2"},{"id":"prompt_rewrite_polite","label":"Rewrite polite","type":"2"},{"id":"prompt_summarize_this","label":"Summarize this","type":"0"},{"id":"prompt_this","label":"Prompt this","type":"2"},{"id":"prompt_translate_this","label":"Translate this","type":"0"}] mzta-background.js:110:13
[ThunderAI Logger | mzta-popup] _prompts_data: [{"id":"prompt_classify","label":"Classify","type":"0"},{"id":"prompt_reply","label":"Reply to this","type":"1"},{"id":"prompt_rewrite_formal","label":"Rewrite formal","type":"2"},{"id":"prompt_rewrite_polite","label":"Rewrite polite","type":"2"},{"id":"prompt_summarize_this","label":"Summarize this","type":"0"},{"id":"prompt_this","label":"Prompt this","type":"2"},{"id":"prompt_translate_this","label":"Translate this","type":"0"}] mzta-logger.js:35:44
[ThunderAI Logger | mzta-popup] active_prompts: [{"id":"prompt_classify","label":"Classify","type":"0"},{"id":"prompt_reply","label":"Reply to this","type":"1"},{"id":"prompt_summarize_this","label":"Summarize this","type":"0"},{"id":"prompt_translate_this","label":"Translate this","type":"0"}] mzta-logger.js:35:44
[ThunderAI Logger | mzta-popup] tabType: mail mzta-logger.js:35:44
[ThunderAI Logger | mzta-popup] filteredData: [{"id":"prompt_classify","label":"Classify","type":"0"},{"id":"prompt_reply","label":"Reply to this","type":"1"},{"id":"prompt_summarize_this","label":"Summarize this","type":"0"},{"id":"prompt_translate_this","label":"Translate this","type":"0"}] mzta-logger.js:35:44

I was using a theme that I downloaded. I have also tried all the built-in themes (Light, Dark, System). I restarted Thunderbird each time.

Opening the menu, typing '1' and 'Enter' properly opens a window and runs the 'Classify' prompt.

micz commented 1 month ago

It seems to be just a visualization issue. Could you try using version 2.2.0pre4_hyprland_rev1 by renaming the file to .xpi as you did last time?

thunderai-v2.2.0pre4_hyprland_rev1.zip

I've explicitly defined all the colors and background colors in the CSS for the menu.

ehula commented 1 month ago

I tried the above version but still get the same result.

micz commented 1 month ago

I'm sorry, I don't know what else to try. NixOS with KDE shows it correctly, but Hyprland doesn't want to startup.

ehula commented 1 month ago

Is it working for @Mikilio ?

OK. A bit more information.

The very first time I ran the new version, I did get the menu to display when I clicked the AI button. But just once. Every other time, the contents wouldn't display.

For kicks, I tried CTRL-ALT-A, and the menu contents were displayed, the first time only. After that, no contents.

Mikilio commented 1 month ago

The settings interface was a bit buggy and crashed, but otherwise everything seems fine on my end. The AI button works as expected. As far as this issue goes, I can't reproduce it anymore, and it's solved for me.

ehula commented 1 month ago

@Mikilio Did you try version 2.2.0pre4_hyprland_rev1? That's the one that broke the drop-down menu for me.

micz commented 1 month ago

@Mikilio Did you try version 2.2.0pre4_hyprland_rev1? That's the one that broke the drop-down menu for me.

You had problems also with 2.2.0pre4?

ehula commented 1 month ago

@Mikilio Did you try version 2.2.0pre4_hyprland_rev1? That's the one that broke the drop-down menu for me.

You had problems also with 2.2.0pre4?

Yes I did. Neither is displaying the contents of the menu.

Mikilio commented 1 month ago

You can check out my dotfiles to see if I'm doing something different. @ehula

micz commented 1 month ago

I've rewritten the code that opens the menu. It should be faster and it could avoid some race conditions in loading data. Since I'm not able to replicate the issue, I can't test it. May you help me?

thunderai-v2.2.0pre5_i137_v1.zip

Thank you.

ehula commented 1 month ago

I am still having the same issue. Nothing is shown inside the menu.

micz commented 1 month ago

@ehula may you post the log, with the add-on debug option active? Please, clear the console before opening the menu.

May you also make a video? If you don't want to link it here, may you send it to m@micz.it? I'd like to be sure it's really something about rendering in hyprland. Thank you.

micz commented 1 month ago

I've released version 2.2.0, which addresses the original error, so I'm going to close this issue. If you have time to provide more details about the menu error, feel free to post them here or open a new issue, whichever you prefer. Thank you.

micz commented 1 month ago

@ehula are you using Wayland? It seems to be a Thunderbird issue on Wayland. You can find more information here: https://bugzilla.mozilla.org/show_bug.cgi?id=1905622

micz commented 1 month ago

When I click the Close button, the chat window does close. I am talking about the "chat" item in my ChatGPT account that remains and creates unnecessary and useless clutter. Because it is a transitory one-time action, I would like that chat item to be deleted when I click Close. Is that possible?

In issue #169 you could find a workaround, see this comment: https://github.com/micz/ThunderAI/issues/169#issuecomment-2427153924

ehula commented 1 month ago

That's great! I look forward to trying it, although I still can't see the content of the menu. Yes, I am using wayland, which is becoming the default on many distros, so not a niche problem.

micz commented 1 month ago

I hope they will fix it soon. In the meanwhile, may you try this https://github.com/micz/ThunderAI/issues/151#issuecomment-2429021299?