Introducing a new way to review your PRs.

Read the announcement

ismaelmartinez / teams-for-linux

Unofficial Microsoft Teams for Linux client

View on GitHub

23 documents · Updated Nov 23, 2026

docs / profile-unread-status

Profile unread status and tray badging

Profile unread status combines the unread count reported by each primary account view into one desktop attention signal. The main process owns the total and sends it to the application badge and native tray, while a live profile renderer supplies the composited tray image. This page extends Application lifecycle and relates to Desktop window management, User profiles and workspaces, and Desktop integration and menus.

Unread status model

Each profile view reports the unread number shown in its page title. The system keeps one unread bucket per profile, then derives the desktop state from all buckets instead of allowing the last reporting view to replace the others.

The model produces these shared signals:

SignalMeaning
Application badgeSum of the unread counts for all known buckets
Tray tooltipApplication title and total count, plus up to three named profiles when several profiles have unread items
Tray flashActive when any unread bucket requests attention
Tray imageThe single profile image when one profile is unread, or a newly composited aggregate image when several are unread

Profile attribution

The system maps each IPC sender to the profile view that owns it. The root application window represents the legacy account, while profile views and their child surfaces resolve to their owning profile; an unknown sender remains an unattributed bucket rather than being discarded. This mapping lets the main process combine updates from separate account surfaces and prevents a popup from replacing the count reported by its primary profile view. References: app/…/senderProfileMap.js• L1-27, app/…/profileViewManager.js• L411-444, app/…/index.js• L38-47

Primary profile surfaces

Only the root window and live profile views can change a profile bucket. Popups and embedded child surfaces can report their own page state, but the system ignores those reports because they do not represent the profile's main Teams view. References: app/…/profileViewManager.js• L428-444, app/…/index.js• L79-87

Unread reporting flow

The reporting flow turns a page-title count into a profile bucket and then into desktop state. The renderer watches title changes so the count follows Teams page updates without requiring a separate account-specific API.

flowchart LR
    A[Profile page title] --> B[Unread count event]
    B --> C[Renderer tray and badge IPC]
    C --> D[Sender-to-profile attribution]
    D --> E[Per-profile unread bucket]
    E --> F[Aggregate total, tooltip, flash, and icon]
    F --> G[Application badge]
    F --> H[Native tray]

The title observer reads a leading numeric count and emits only changes. The tray renderer turns that event into both a tray update and an application badge update; in multi-account mode, the main process receives both reports and uses the profile identity from the IPC sender. References: app/…/mutationTitle.js• L60-95, app/…/trayIconRenderer.js• L17-20, app/…/trayIconRenderer.js• L53-117, app/…/preload.js• L135-145

Bucket aggregation

The aggregator updates a bucket from tray details and badge-count events. A count of zero removes that profile from the unread set, while a profile removal or view teardown removes its bucket so a deleted or closed account cannot keep the desktop badge inflated.

The aggregate has these rules:

  • Counts are summed across buckets.
  • Flash state uses an OR rule across unread buckets.
  • Named profile lines are sorted by count and limited to the top three.
  • Unattributed buckets affect the total but do not add a profile name line.
  • A sender that becomes attributable replaces its temporary sender bucket so its count is not counted twice.

References: app/…/index.js• L59-118 app/…/index.js• L120-133 app/index.js• L935-942

Native tray and application badge

The main process applies the aggregate to the native tray and to the operating-system application badge. The tray keeps the base icon when no unread items remain, uses the profile's own icon for one unread profile, and uses a renderer-created aggregate icon for several unread profiles.

The application badge follows the same total. On Linux, the system also sends the count through the launcher-entry path because Electron's normal badge call may not reach the desktop dock. References: app/index.js• L861-891, app/…/tray.js• L42-64, app/…/tray.js• L96-107

Aggregate icon rendering

The main process cannot draw the tray badge itself, so it asks the active profile renderer to compose the total onto the base icon. The reply includes a request identity and sender identity, has a short timeout, and is checked before the main process accepts it; a failed request returns no icon to the aggregator, which then uses a safe existing icon when possible. References: app/…/badgeRenderBridge.js• L1-75, app/…/trayIconRenderer.js• L24-40, app/…/trayIconRenderer.js• L119-184, app/…/ipcValidator.js• L174-181

Update ordering

Unread updates can arrive while an icon is being drawn. The renderer tracks the newest requested count, and the aggregator accepts only the newest aggregate render, so a slow old render cannot restore an earlier badge or tray image. References: app/…/trayIconRenderer.js• L56-105, app/…/index.js• L147-186

Feature boundary

The profile-aware aggregation path is enabled only when multi-account support is enabled. With that feature off, the existing single-surface tray and badge path remains in use; with it on, the tray defers to the main-process aggregator rather than applying each profile update directly. References: app/index.js• L274-284, app/index.js• L894-949, app/…/tray.js• L18-39

Change checklist

When these files or sections are changed, remember to consider these:

  • Keep sender attribution aligned with the lifetime of profile views, the root account, and their child surfaces. A stale mapping can assign one account's unread count to another.
  • Keep the tray update payload and badge-count path compatible with both the renderer and the main-process aggregator. A missing count can preserve an old total by design.
  • Keep aggregate render request and reply validation aligned. The request id and renderer identity protect the tray from late or unrelated icon replies.
  • Keep profile removal and view-destruction callbacks connected to bucket removal. Otherwise a closed account can continue to affect the badge.
  • Keep the multi-account feature gate around both aggregation setup and aggregate-render IPC so the single-account path does not depend on profile services.

Important failure modes

TriggerConsequenceGuard
A popup sends a zero unread countIt could clear the real profile countOnly primary profile surfaces can update buckets
A profile view is removed without removing its bucketThe total and tray tooltip stay too highProfile removal and view-gone events call removeProfile
An aggregate render reply arrives from a different senderAn unrelated or unsafe image could reach the trayReplies must match both request id and sender id, then pass image checks
A slow older render finishes after a newer updateThe tray could show stale unread stateRenderer sequence tokens and aggregator render tokens discard stale work
The renderer cannot render an aggregate iconThe tray could lose its badged imageThe aggregator falls back to the strongest current or last badged icon
Linux ignores the normal application badge callThe dock does not show the totalThe main process also emits launcher-entry badge state

Key files

FileWhy to read it
app/…/index.jsDefines the per-profile buckets and the aggregate tray and badge rules.
app/…/badgeRenderBridge.jsShows how main-process aggregate icon requests cross to a renderer and return safely.
app/…/profileViewManager.jsDefines which profile surfaces are primary and how sender ownership is resolved.
app/…/senderProfileMap.jsExplains the fast mapping from renderer sender to profile identity.
app/…/mutationTitle.jsShows how page-title unread state becomes a renderer event.
app/…/trayIconRenderer.jsConnects renderer unread events to tray updates, badge updates, and icon composition.
app/…/tray.jsApplies the final aggregate image, flash state, and tooltip to the native tray.
app/index.jsWires aggregation into application badge handling and profile lifecycle events.