Closed Bug 1702957 Opened 3 years ago Closed 3 years ago

Recipients not restored when re-opening/editing a draft message [Add-on API: set/getComposeDetails]

Categories

(Thunderbird :: Add-Ons: Extensions API, defect)

Thunderbird 89
defect

Tracking

(thunderbird_esr78 wontfix, thunderbird89 fixed)

RESOLVED FIXED
90 Branch
Tracking Status
thunderbird_esr78 --- wontfix
thunderbird89 --- fixed

People

(Reporter: git, Assigned: TbSync)

References

Details

(Whiteboard: [affects add-ons only])

Attachments

(1 file)

User Agent: Mozilla/5.0 (X11; Linux x86_64; rv:87.0) Gecko/20100101 Firefox/87.0

Steps to reproduce:

As reported by a SignatureSwitch-user:
https://github.com/4ch1m/mozext/issues/43

  • open a new mail
  • enter recipient (, subject, text)
  • save as draft
  • re-edit the draft

Actual results:

The previously entered recipient from the draft doesn't get restored.

Expected results:

The previously entered recipient from the draft should get restored.

This is probably yet another side-effect of the recently introduced pillification (see bug 1696765).

Status: UNCONFIRMED → RESOLVED
Closed: 3 years ago
Resolution: --- → DUPLICATE

Alfred, first of all, big thank you for looking into bugs!
In cases like this sometimes better to forward-duplicate. This bug was filed only 2 days after bug 1702852, but this one has much clearer steps and starts out with the right hints, namely the involvement of SignatureSwitch Add-on. Moreover, it was filed by the addon-author himself, claiming that it's a bug in Thunderbird. We'll look into that in the next comments.

Resolution: DUPLICATE → INVALID
Summary: Recipients not restored when opening a draft message → Recipients not restored when re-opening/editing a draft message [Caused by SignatureSwitch Add-on]
Whiteboard: [Addon: Signature Switch]

Hi Achim,

sorry for nagging, but using your STR on 89.0b3, this bug...

  • ... does not occur without your SignatureSwitch Add-on
  • ... does occur with SignatureSwitch Add-on

So it looks like bug caused by add-on, no?
I'm failing to understand then why you seem to suggest that this is a bug in Thunderbird?
Is Thunderbird serving you wrong data? Any details why your addon would touch regular recipient headers?
Maybe I'm overlooking something.

(In reply to Achim Seufert from duplicate Bug 1702852 Comment 7)

(In reply to Thomas D. (:thomas8) from comment #6)

We have seen somewhat similar problems with SignatureSwitch add-on in Bug 1696765.
Achim (addon-author), could you comment?

Sure.

As John already stated:

Yes, requested by add-on developers getComposeDetails should contain partially entered values, which needed an enforced pillification. Hm. Achim is not doing something illegal. How do we solve this? Lets move this discussion over to bug 1681008.

Achim, could you reference the comment with John's quote? Context will be helpful.

I understand the need for getComposeDetails to return partially entered / non-pillified recipient values in some way, but afasics this bug does not involve those, so I don't see how John's comment wrt partial values could apply here. Furthermore, Bug 1696765 seems to have been mitigated somehow, so even with the addon installed, it does no longer happen for me.

The add-on is using pure WebExtension/MailExtension APIs... no experiments or other "hacky code" (imho).

The sourcecode can be found here:
https://github.com/4ch1m/mozext/tree/master/signatureswitch-me

I haven't yet found the time to investigate which parts of the base code are broken or lead to the described behaviour.

Flags: needinfo?(git)

^^ John, fyi: comment 4.

Found it.

Achim has triggered "something" which I was coincidently looking at this morning by myself.

Thanks for finding this, sorry for it being there in the first place!

To quick-fix this in the add-on, add a small delay here:

function addWindowCreateListener() {
    browser.windows.onCreated.addListener(window => {
        if (window.type === WINDOW_TYPE_MESSAGE_COMPOSE) {
            browser.tabs.query({windowId: window.id}).then(async tabs => {
                let tabId = tabs[0].id;

                let storage = await browser.storage.local.get();
                await new Promise(resolve => window.setTimeout(resolve, 500));  // <-- wait here
                let details = await browser.compose.getComposeDetails(tabId);

getComposeDetails is called to early (the window is ready after onCreated has fired, but not the composer). I keep digging.

I have a fix. Will create bug and patch later today.

Edit: Fix needs some more time. It is complicated.

Status: RESOLVED → REOPENED
Ever confirmed: true
Resolution: INVALID → ---
Assignee: nobody → john

(In reply to John Bieling (:TbSync) from comment #6)

Found it.

Nice. [thumbsup]

Achim has triggered "something" which I was coincidently looking at this morning by myself.

Thanks for finding this, sorry for it being there in the first place!

Seems that I'm getting infamous or at least I'm about to start buildung a certain reputation with all those bug-titles claiming that SignatureSwitch breaks Thunderbird. ;-)

To quick-fix this in the add-on, add a small delay here:

function addWindowCreateListener() {
    browser.windows.onCreated.addListener(window => {
        if (window.type === WINDOW_TYPE_MESSAGE_COMPOSE) {
            browser.tabs.query({windowId: window.id}).then(async tabs => {
                let tabId = tabs[0].id;

                let storage = await browser.storage.local.get();
                await new Promise(resolve => window.setTimeout(resolve, 500));  // <-- wait here
                let details = await browser.compose.getComposeDetails(tabId);

Thanks for taking the time to provide a workaround.
However, this doesn't reliably solve the issues on my end.
(Even with this fix in place, it works only 8 out of 10 times. Maybe 500ms is not enough in some cases?!)

What's even more confusing:
It always works then opening a draft directly after starting Thunderbird.
In other words: If it is the very first time a composer-window is opened; then it will work.
Only after subsequent openings of a compose-window/draft it is broken.
Hmmm.

Flags: needinfo?(git)

Comment on attachment 9221393 [details]
Bug 1702957 - Wait for compose window being ready before using set/getComposeDetails. r=mkmelin

[Approval Request Comment]
Regression caused by (bug #):
User impact if declined:
API clears recipient field of re-opened drafts, which is a serious/annoying bug.

Testing completed (on c-c, etc.):
https://treeherder.mozilla.org/#/jobs?repo=try-comm-central&revision=f4f6e7f75116908053e3237b7ee72e3fde3a65c5

Risk to taking this patch (and alternatives if risky):
Low.

Attachment #9221393 - Flags: approval-comm-beta?

Comment on attachment 9221393 [details]
Bug 1702957 - Wait for compose window being ready before using set/getComposeDetails. r=mkmelin

[Triage Comment]
Approved for beta

Attachment #9221393 - Flags: approval-comm-beta? → approval-comm-beta+
Target Milestone: --- → 90 Branch

Pushed by mkmelin@iki.fi:
https://hg.mozilla.org/comm-central/rev/cc70e22232d7
Wait for compose window being ready before using set/getComposeDetails. r=mkmelin

Status: REOPENED → RESOLVED
Closed: 3 years ago3 years ago
Resolution: --- → FIXED

The current Daily includes the patch. Can you confirm it is fixed? Beta89.0b4 should be fixed as well.

(In reply to Achim Seufert from comment #8)

(In reply to John Bieling (:TbSync) from comment #6)

Achim has triggered "something" which I was coincidently looking at this morning by myself.
Thanks for finding this, sorry for it being there in the first place!
Seems that I'm getting infamous or at least I'm about to start building a certain reputation with all those bug-titles claiming that SignatureSwitch breaks Thunderbird. ;-)

Sorry Achim, my mistake, no offense meant - I have removed the erroneous blame from the summary of this bug 1702957 and duplicate bug 1702852 - that's it, right? I've found this set of bugs pretty confusing, but with your help and following my invitation of John (our add-on expert) in comment 5, at least we have been able to figure this out, thank you! I've learned something new here about bugs involving add-ons, that even though the bug only appears with add-ons, it might still be a Thunderbird around the API...

So FTR: SignatureSwitch is a highly popular add-on and it does NOT break Thunderbird! :-)

Component: Message Compose Window → Add-Ons: Extensions API
Summary: Recipients not restored when re-opening/editing a draft message [Caused by SignatureSwitch Add-on] → Recipients not restored when re-opening/editing a draft message [Add-on API: set/getComposeDetails]
Whiteboard: [Addon: Signature Switch] → [affects add-ons only]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: