Adding labels to the side bar


I am trying to create a plug-in that adds a label to the side bar.
Like Starred, Unread, …, or Sent Mail, when click this label it shows a list of mails that contain that label.
So, I successfully create a plug in that adds an entry to the side bar using by creating a class extending MailboxPerspective. And, add it using ExtensionRegistry.AccountSidebar.register.

However, in the method thread(), I could not create a query that find a list of threads that contains the label.
When I looked at Thread.attributes.labels, I see that the attribute is not queryable.
Does anyone know any work-around for this problem.

Or has anyone every tried to create a similar plug-in like this before?

Any help would be appreciated :slight_smile:

Thank you,