Display total number of threads in folder pane?

User Help for Mozilla Thunderbird
Post Reply
kswartz
Posts: 85
Joined: August 18th, 2004, 4:54 pm

Display total number of threads in folder pane?

Post by kswartz »

Does anyone know of an addon that will add an option to display the number of total threads per folder in the folder pane, instead of the number of messages? (I would also settle for something that displays the thread count in a bar of the message pane.)

Right now, the only way I can find this information is to collapse all threads in a folder, and then select them all. I'm hoping for something a bit more static than that.

Thanks,
Keith
- Keith
Software & Compliance Architect
User avatar
tanstaafl
Moderator
Posts: 49647
Joined: July 30th, 2003, 5:06 pm

Re: Display total number of threads in folder pane?

Post by tanstaafl »

Nope. Though it appears that the ThreadVis add-on lets you "Jump back and forth between messages in a thread, regardless of folder location. Don't be forced to keep all messages in a single folder to display the thread hierarchy, sort messages any way you like and still make sense of the context the mails were sent in." I don't know how practical that is (since it seems you do that using colored dots in a graph in the header of the message you are reading), but it makes me wonder if you might want to dedicate a folder to contain just the latest message in each thread, and use message filters to file the preceding messages elsewhere. That way that folders message count would be the count of the number of active conversations/threads you have. If you did that you might use the inbox only to store relatively new messages that are not in a thread.

https://addons.mozilla.org/en-US/thunde ... is/?src=ss
https://threadvis.github.io

Why do you want to do this? Sometimes knowing that helps somebody suggest a different way to solve the problem.
kswartz
Posts: 85
Joined: August 18th, 2004, 4:54 pm

Re: Display total number of threads in folder pane?

Post by kswartz »

The latter solution doesn't work -- we have much too much activity, and filing/refiling the latest would be too time consuming.

The requirement has to do with metrics in our group. We measure workload (with measurements taken at least every day, sometimes 2x a day) with a number of variables, one of which is the size of our active "queue" (Inbox). We used to measure by number of messages, but found this was unfairly skewing the metrics by over-weighing conversations that were highly active, or had a longer history that needed to tracked. (For instance, lots of older replies with attachments that needed to be preserved). So now we measure by number of conversations/threads.

The only way to get that now is to select all and look at the total. I figure if TB can report that total, there must be a way to get it without having to actively select, and display it somewhere.

I actually think even having it in the status bar would be sufficient (although it may not work with TB 60+). It already lists Unread and Total there -- and the Lightning extension adds Invitations there. So the capability is definitely there. (Alas, these days, I lack the free time to build something myself.)

Thanks for the quick reply.
- Keith
Software & Compliance Architect
User avatar
tanstaafl
Moderator
Posts: 49647
Joined: July 30th, 2003, 5:06 pm

Re: Display total number of threads in folder pane?

Post by tanstaafl »

I suggest you try contacting the author of one of the thread-centric add-ons and see if you can interest them in adding your feature. I'd normally recommend Paolo "Kaosmos" (author of ImportExportTools etc.) as he has a history of adding features (or even creating a new add-on in some cases) upon request but he has put his add-on development on hold until the direction of Thunderbird add-ons clears up. If you already use the Thunderbird Conversations add-on perhaps contact it's author?

Another solution might be to write a script file that counts the number of threads in a folder, displaying the count when it ends. The advantage of that is you might be able to schedule it running using Windows Task Scheduler and also have it submit the count somewhere, totally getting the user out of the loop.

http://kb.mozillazine.org/Stop_threading_by_subject
https://www.commandlinefu.com/commands/ ... -mbox-file
https://lifehacker.com/179514/geek-to-l ... win-part-i
https://stackoverflow.com/questions/123 ... es-in-unix

Thunderbird stores the messages for each folder in a different mbox file. Its a flat plain text file named after the mail folder, with no file extension. i.e. "inbox." is the mbox file for the inbox folder. Ignore "inbox.msf" (a cache of the folder listing).

If you assume each thread uses a unique References: header you could create a script that counts the number of unique Reference headers in the mbox file. That would not be as convenient as displaying the thread count in the status bar, but would automate the process. There are lots of scripts in python, perl and javascript to parse mbox files that you can find as a starting point. Or you could use command line utilities such as this example of how to sort and count subjects of emails stuck in Exim queue. Cygwin probably has the text processing utilities that you'd need.

grep -R Subject /var/spool/exim/input/ | sed s/^.*Subject:\ // | sort | uniq -c | sort -n > ~/email_sort.$(date +%m.%d.%y).txt
morat
Posts: 6403
Joined: February 3rd, 2009, 6:29 pm

Re: Display total number of threads in folder pane?

Post by morat »

Do you want an alert dialog to show the total number of threads for the selected folder using the Keyconfig extension?

Code: Select all

var totalThreads = 0;
var threadTree = document.getElementById("threadTree");
for (var i = 0; i < threadTree.treeBoxObject.view.rowCount; i++) {
  if (threadTree.treeBoxObject.view.getLevel(i) === 0) {
    totalThreads = totalThreads + 1;
  }
}
var folder = gFolderDisplay.displayedFolder;
var title = "Folder Stats";
var description = "Unread: " + folder.getNumUnread(false) +
  ", Total: " + folder.getTotalMessages(false) +
  ", Threads: " + totalThreads;
Services.prompt.alert(window, title, description);
Keyconfig
http://addons.mozilla.org/thunderbird/addon/602486

P.S.

Here is the code to select all threads.

Code: Select all

goDoCommand("cmd_selectAll");
goDoCommand("cmd_collapseAllThreads");
goDoCommand("cmd_expandAllThreads");
User avatar
tanstaafl
Moderator
Posts: 49647
Joined: July 30th, 2003, 5:06 pm

Re: Display total number of threads in folder pane?

Post by tanstaafl »

I'm embarrassed I didn't think of that possibility :)
kswartz
Posts: 85
Joined: August 18th, 2004, 4:54 pm

Re: Display total number of threads in folder pane?

Post by kswartz »

Interesting - I like the keyconfig alert (I already use keyconfig, too). I think if I can change from an alert to having it display that information in the status bar, next to the unread/total numbers, I'd have something very usable and unintrusive. (And then, in theory, couldn't I run that script in a loop with a timer?)

-Keith
- Keith
Software & Compliance Architect
morat
Posts: 6403
Joined: February 3rd, 2009, 6:29 pm

Re: Display total number of threads in folder pane?

Post by morat »

It would be too much trouble to show the total threads for all folders in the folder pane because there isn't a method for total threads like there is for total messages. It is possible to show the total threads for the selected folder in the status bar with a legacy extension. I guess I would hack the UpdateStatusMessageCounts function.

nsIMsgFolder getTotalMessages
http://developer.mozilla.org/en-US/docs ... ages.28.29

UpdateStatusMessageCounts
http://dxr.mozilla.org/comm-esr52/searc ... sageCounts

@tanstaafl

Luckily, Jonathan is still supporting the Keyconfig extension.
morat
Posts: 6403
Joined: February 3rd, 2009, 6:29 pm

Re: Display total number of threads in folder pane?

Post by morat »

*** for advanced users only ***

Try this:

Code: Select all

/* Thunderbird userChrome.js */

(function () {

if (location == "chrome://messenger/content/messenger.xul") {

  setTimeout(function () {

    UpdateStatusMessageCounts = function (folder) {
      var unreadElement = document.getElementById("unreadMessageCount");
      var totalElement = document.getElementById("totalMessageCount");
      if (folder && !folder.isServer && unreadElement && totalElement) {
        var numSelected = gFolderDisplay.selectedCount;
        var bundle = document.getElementById("bundle_messenger");
        var numUnread = (numSelected > 1) ?
          bundle.getFormattedString("selectedMsgStatus", [numSelected]) :
          bundle.getFormattedString("unreadMsgStatus", [folder.getNumUnread(false)]);
        var numTotal = bundle.getFormattedString("totalMsgStatus", [folder.getTotalMessages(false)]);
        var totalThreads = 0;
        var threadTree = document.getElementById("threadTree");
        for (var i = 0; i < threadTree.treeBoxObject.view.rowCount; i++) {
          if (threadTree.treeBoxObject.view.getLevel(i) === 0) {
            totalThreads = totalThreads + 1;
          }
        }
        unreadElement.setAttribute("label", numUnread);
        totalElement.setAttribute("label", numTotal + " or " + totalThreads);
        unreadElement.hidden = false;
        totalElement.hidden = false;
      }
    }

  }, 1000);

}

if (location == "chrome://messenger/content/messageWindow.xul") {}
if (location == "chrome://messenger/content/messengercompose/messengercompose.xul") {}

})();
Instructions:

* install userChromeJS extension
* close email client
* create or edit the userChrome.js file in the chrome folder
* open email client with the -purgecaches command line option

i.e.

thunderbird.exe -purgecaches
ThunderbirdPortable.exe -purgecaches

You have to purge the javascript caches only after creating or editing the userChrome.js file.

http://userchromejs.mozdev.org/
http://userchromejs.mozdev.org/faq.html

userChromeJS 2.0 is signed by Mozilla.

Extension Signing
http://wiki.mozilla.org/Add-ons/Extension_Signing

If I try to install an unsigned extension like userChromeJS 1.7 in Firefox ESR 52, then I get the following error message.
This add-on could not be installed because it has not been verified.
Thunderbird does not require extensions to be signed, but I would trust signed extensions that work in Firefox.

MD5, SHA1, SHA256 for userchromejs-2.0-sm+tb+fx.xpi file:

371759c10b3553e8b04a11c5e43a9a3a
3cccc21f3c5798c4f663ae1d754143ad0a446b8a
c72bdf4c4d815ee29bacaab54368ffc242d0e970f8ca9ff21f2d5901f1d891ac

Also, I believe userChromeJS 2.0 has a bug in Thunderbird 57 and above.

More info: http://forums.mozillazine.org/viewtopic ... #p14783122

userChromeJS 2.0 (signed)
Thunderbird 52.8.0
Windows 7 SP1 32-bit

Thunderbird 78: http://forums.mozillazine.org/viewtopic ... #p14883972
Last edited by morat on January 26th, 2021, 7:09 am, edited 1 time in total.
kswartz
Posts: 85
Joined: August 18th, 2004, 4:54 pm

Re: Display total number of threads in folder pane?

Post by kswartz »

This community is awesome. Thank you SO much for these suggestions. Morat -- I'm going to give your solution a shot, right after I make a few backups. :)

Now I have to keep my fingers crossed that this all won't go to crap if TB drops legacy extensions in 60+. (I've already started moving over to Basilisk in Firefox because of it. Too many things I've built and become too attached to over the years, and no time/motivation to rewrite them.)
- Keith
Software & Compliance Architect
kswartz
Posts: 85
Joined: August 18th, 2004, 4:54 pm

Re: Display total number of threads in folder pane?

Post by kswartz »

Just a followup to note that morat's suggestion works perfectly. And it's FAST, even in a folder with over 28000 messages. Maybe someday I'll see if I can tackle putting this into the folder pane, just for kicks, but this meets all my requirements today.

Thank you all!
- Keith
Software & Compliance Architect
morat
Posts: 6403
Joined: February 3rd, 2009, 6:29 pm

Re: Display total number of threads in folder pane?

Post by morat »

You're welcome.
Post Reply