Closed Bug 2004961 Opened 4 months ago Closed 8 hours ago

Stale unread count may persist in folder ARIA label/tooltip after messages are read or deleted

Categories

(Thunderbird :: Disability Access, defect)

Thunderbird 115
defect

Tracking

(Not tracked)

RESOLVED FIXED
152 Branch

People

(Reporter: cwendling, Assigned: welpy-cw)

References

Details

Attachments

(4 files)

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

Steps to reproduce:

Delete all unread messages in a subfolder (e.g. INBOX/subfolder)

Actual results:

The unread count badge for that directory in the accounts list properly updated (the badge disappeared as there are no more unread messages) but the a11y description of the row kept the previous value ("INBOX/subfolder, 42 unread messages" -- or so, reverse-translating from French).

Expected results:

The a11y description should update properly, even when dropping to no unread messages, and even in subfolders.


In the attached capture, you can see that the a11y treeitem node for folder Courrier entrant/debian (translating to Inbox/debian) still has a previous name value, while it's properly updated in the UI (hidden badge)

I am not entirely sure if this has to happen in a subfolder or if it's partly random, but I've been experiencing it there. I just tested with Daily 148.0a1 (2025-12-09) (64 bits) under Debian testing, but it's been like that for months at least.

Right, looks like aria-label isn't updated for 0 unread, leaving the old value there.
https://searchfox.org/comm-central/rev/b3656e2549ad7bf5b5c167eb5dc538c2fbf29448/mail/base/content/widgets/folder-tree-row.mjs#208

Status: UNCONFIRMED → NEW
Ever confirmed: true
Keywords: good-first-bug

@mkmelin thanks for looking into this!

Without knowing this code though, are you sure that's where lies the issue? It looks to me like the aria label is always updated with the promise pieces (L227), and that L208 just avoids adding the unread label to the promise.

At a glance, I'd be wondering whether this.readCount could still be at an old value when #updateAriaLabel() is fetching it? Or if there could be promise ordering issues as all of unreadCount, totalCount and folderSize will be updating it pretty much all at the same time? I hope not because that sounds awful to debug :)

I hope I'm wrong and just missed something though :)

I didn't try coding it so there is a chance my analysis is wrong.

While the visible row in the folder pane is changed immediately (https://searchfox.org/comm-central/rev/7f4bed3d3e3105bc10a41a0fa7c0327a21f6f59c/mail/base/content/widgets/folder-tree-row.mjs#150-161), the aria label is localized asynchronously (https://searchfox.org/comm-central/rev/7f4bed3d3e3105bc10a41a0fa7c0327a21f6f59c/mail/base/content/widgets/folder-tree-row.mjs#227-234).

You say this happened when you deleted all unread messages, so maybe automatic compacting of the folder might kick in right afterwards, delaying the fluent localization for the aria label. Does the label eventually get updated on its own? By the way, you can easily check this by hovering the mouse and having the tooltip displayed.

Does the label eventually get updated on its own? By the way, you can easily check this by hovering the mouse and having the tooltip displayed.

Flags: needinfo?(cwendling)

You say this happened when you deleted all unread messages, so maybe automatic compacting of the folder might kick in right afterwards, delaying the fluent localization for the aria label. Does the label eventually get updated on its own?

It doesn't seem so no, it also happens removing a single email (although it's the only unread), and waiting a few minutes doesn't seem to help. Also, there's no visible mention of compacting going on.

By the way, you can easily check this by hovering the mouse and having the tooltip displayed.

Ah yeah good point, the tooltips are wrong as well, still include how many unread there was before deletion.

Flags: needinfo?(cwendling)
Attached image tb-noread-1.png

Showing 1 shadow unread mail on the Inbox (in French)

Attached image tb-noread2.png

Showing 13 shadow unread mails on a subfolder (in French)

Keywords: good-first-bug
See Also: → 1952666
See Also: → 1945307
See Also: 1945307

This commit addresses several performance and state management issues within the FolderTreeRow component:

  • Decoupled State: Migrated unreadCount, totalCount, and folderSize from
    reading directly from the DOM (textContent) to using private class fields
    as the single source of truth. Added early-exit equality checks to setters to
    prevent unnecessary DOM work.
  • Race Condition Fix: Implemented an AbortController inside #updateAriaLabel
    to ensure older, delayed localization promises do not overwrite newer state
    updates.
  • Performance/Debouncing: Added #scheduleAriaLabelUpdate to batch rapid,
    sequential property updates (e.g., during an email sync) into a single 50ms
    delayed localization call.
  • Layout Optimization: Centralized the nodeValue update logic into
    #updateTextNode to successfully bypass the childList MutationObserver
    across all folder labels, preventing unnecessary layout recalculations.
  • Documentation: Corrected JSDoc for folderSize to accurately reflect its
    string return type.
Assignee: nobody → h.w.forms
Status: NEW → ASSIGNED
Severity: -- → S3
Depends on: 1825870
Summary: Unread count not properly updated for a11y → Stale unread count may persist in folder ARIA label/tooltip after messages are read or deleted
Version: Thunderbird 148 → Thunderbird 115
Attachment #9568918 - Attachment description: Bug 2004961 - Refactor FolderTreeRow state management and fix ARIA label race condition. r=#thunderbird-reviewers → Bug 2004961 - Refactor FolderTreeRow state management and fix ARIA label race condition. r=darktrojan,#thunderbird-front-end-reviewers
Target Milestone: --- → 152 Branch

Pushed by geoff@darktrojan.net:
https://hg.mozilla.org/comm-central/rev/79cfa268c280
Refactor FolderTreeRow state management and fix ARIA label race condition. r=darktrojan,aleca

Status: ASSIGNED → RESOLVED
Closed: 1 day ago
Resolution: --- → FIXED

We had to back-out this patch, because it introduced intermittent test fails for mac:
https://treeherder.mozilla.org/jobs?repo=try-comm-central&revision=631b14e88444c4bec341531356be100ba9eb0fbb&group_state=expanded&selectedTaskRun=PTGbLsOWTQqYihi3wAwmHA.0

We have run a try without it and could not trigger the same failure:
https://treeherder.mozilla.org/jobs?repo=try-comm-central&revision=756f740c90555ccfb20bb3668b65d12afed53801

Geoff did some investigations, but could not find what might be causing it.

@welpy-cw : Do you have an idea?

Status: RESOLVED → REOPENED
Resolution: FIXED → ---
Backout by john@thunderbird.net: https://hg.mozilla.org/comm-central/rev/fa300c65cf72 Backed out changeset 79cfa268c280 for potential test fails. r=me
Depends on: 1962967

(In reply to John Bieling from comment #11)

We had to back-out this patch, because it introduced intermittent test fails for mac:
https://treeherder.mozilla.org/jobs?repo=try-comm-central&revision=631b14e88444c4bec341531356be100ba9eb0fbb&group_state=expanded&selectedTaskRun=PTGbLsOWTQqYihi3wAwmHA.0

We have run a try without it and could not trigger the same failure:
https://treeherder.mozilla.org/jobs?repo=try-comm-central&revision=756f740c90555ccfb20bb3668b65d12afed53801

Geoff did some investigations, but could not find what might be causing it.

@welpy-cw : Do you have an idea?

Yes, I have a fix for bug 1962967 that should resolve this. But we have to wait until Treeherder is working again to be sure…

Pushed by geoff@darktrojan.net:
https://hg.mozilla.org/comm-central/rev/b72fa3cfa74b
Refactor FolderTreeRow state management and fix ARIA label race condition. r=aleca,darktrojan

Status: REOPENED → RESOLVED
Closed: 1 day ago8 hours ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: