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 / application-lifecycle

Application lifecycle and workspace shell

Teams for Linux is an Electron desktop shell around the Microsoft Teams web app. The main process owns application startup, the desktop window, persistent session data, and the profile views that let several Teams accounts run in one application.

Application boundary

Electron process

The Electron main process is the control point for the application. It reads startup settings, enforces one running instance, registers the msteams protocol, and starts the Teams web experience only after Electron reports that the app is ready.

The renderer displays Teams content. The main process remains responsible for desktop concerns such as windows, session partitions, menus, protocol links, and shutdown. A second launch does not create a second shell; it sends its link or activation request to the existing instance.

References: package.json• L1-5 app/index.js• L77-107 app/index.js• L124-125 app/index.js• L193-201

Workspace session

The workspace session is the persistent browser state used by a Teams view. The default session keeps the existing account signed in across launches. Profile sessions extend this model by giving each configured account its own persistent partition.

This boundary matters because a view is not only a page on screen. Its session contains the cookies and local data that identify the Teams account behind that view. Storage cleanup and profile removal must therefore act on the session that owns the view.

References: app/…/browserWindowManager.js• L40-53 app/…/browserWindowManager.js• L85-111 app/…/index.js• L5-7 app/…/profileViewManager.js• L568-604

Startup sequence

Readiness stages

Startup moves from process setup to shell creation and then to workspace services. Configuration is loaded before the app-ready handler so command-line switches and feature gates can affect the rest of the launch.

The main window is created before profile views, authentication helpers, and services that need a live Teams session. When multi-account mode is enabled, the profile manager is initialized and the profile view manager is attached only after the main window exists.

This diagram shows the order from a new process to a usable workspace shell.

flowchart TD
    A[Electron process starts] --> B[Load startup settings]
    B --> C[Claim single-instance lock]
    C --> D{App ready}
    D --> E[Create main Teams window]
    E --> F[Load Teams in the default session]
    F --> G{Multi-account enabled?}
    G -- No --> H[Show the default workspace]
    G -- Yes --> I[Initialize profile state]
    I --> J[Create profile views]
    J --> K[Select the active workspace]
    K --> L[Show the workspace shell]

References: app/index.js• L82-107 app/index.js• L198-234 app/index.js• L661-745 app/…/index.js• L675-846

Single-instance handoff

The first process owns the desktop shell. A later process exits after it sends its command-line arguments to the first process through Electron's second-instance event.

The existing shell restores itself and handles a Teams link in that window. This keeps account state, menus, and profile views under one main-process owner.

References: app/index.js• L124-125 app/index.js• L198-201 app/index.js• L344-347 app/…/index.js• L884-905

Shutdown boundary

Closing the main window ends the application rather than leaving a hidden workspace process behind. The shell closes related preview content first, and the main process disconnects optional services during the quit path.

Renderer failure uses the same clean-exit goal when the Teams page can no longer provide a usable surface. Network-related errors are treated as recoverable signals, while an unrecoverable renderer process causes the app to quit.

References: app/…/index.js• L1340-1354 app/index.js• L54-75 app/index.js• L202-209 app/index.js• L422-427

Desktop shell

Main window

The main window is the stable desktop surface for the default Teams workspace. It restores its last size and position, starts hidden until its setup is complete, and loads the Teams URL with the configured browser identity and preload boundary.

The shell attaches navigation, link, call, screen-share, notification, and authentication behavior to this window. These services do not replace Teams; they make the web app behave as a desktop client.

References: app/…/browserWindowManager.js• L40-71 app/…/browserWindowManager.js• L85-111 app/…/index.js• L716-846 app/…/index.js• L1356-1402

Desktop state

The shell preserves the parts of a desktop app that users expect around a web workspace. It can restore window state, follow the system theme, expose browser history controls, show or hide the window through the tray, and keep the screen awake during calls.

These behaviors are tied to the main window lifecycle. A call or navigation event changes shell state through the main process, so the same policy applies whether the active content is the default workspace or a profile view.

References: app/…/index.js• L845-846 app/…/index.js• L1019-1033 app/…/index.js• L1052-1060 app/…/browserWindowManager.js• L149-192 app/…/browserWindowManager.js• L251-272

Child window handling

Teams opens child surfaces for authentication, meetings, links, and other web actions. The shell decides whether a request stays in the app, opens in a controlled child window, or goes to the system browser.

Profile views use the same idea with an important ownership rule: a link opened by a profile must load in that originating profile. The detailed window rules and deep-link cases are covered in Desktop window management and navigation.

References: app/…/index.js• L59-70 app/…/index.js• L1280-1326 app/…/index.js• L1453-1477 app/…/profileViewManager.js• L505-546

Deep-link entry

The application accepts Teams HTTPS launcher links and msteams protocol links. A link can arrive at first launch or through a later launch while the application is already running.

The shell converts supported protocol forms to a Teams URL, brings the window forward, and sends the target to the active desktop surface. The protocol registration in the packaged app connects operating-system links to this flow.

References: app/index.js• L193-196 app/…/index.js• L1062-1097 package.json• L80-90

In-page routing

When the Teams single-page app is already loaded, the shell first tries to let that page resolve the launcher route. This avoids replacing the whole page and gives the user a faster path to a chat, channel, or meeting.

If the loaded page is not the Teams origin or does not consume the route, the shell falls back to a full navigation. Unsupported or incomplete routes also use this fallback, so the deep link is not silently lost.

References: app/…/index.js• L907-926 app/…/deepLinkRouter.js• L13-17 app/…/deepLinkRouter.js• L33-55 app/…/deepLinkRouter.js• L85-147

Profile-backed workspaces

Profile state

A profile is the saved identity and workspace record for one Teams account. The profile manager stores the list of profiles and the active profile, then emits changes so the shell can keep its visible views and menus in sync.

The legacy session is represented as Profile 0 when multi-account mode adopts an existing installation. This preserves a user's current Teams login instead of forcing that account into a new session.

References: app/…/index.js• L32-47 app/…/index.js• L57-85 app/…/index.js• L88-117 app/…/index.js• L151-187

View ownership

The default workspace lives in the root window. Each additional profile gets a full-window view backed by its own persistent session. Switching profiles hides all other profile views and shows the selected one above the root content.

The profile switcher is a small shell surface above the active workspace. It reads profile state from the main process and remains visible while the active Teams content changes.

This diagram shows how profile state becomes a visible workspace.

flowchart LR
    A[Saved profile records] --> B[Profile manager]
    B --> C[Profile view manager]
    C --> D[Root workspace or profile view]
    B --> E[Profile switcher]
    E --> B
    D --> F[Teams session for that profile]

References: app/…/profileViewManager.js• L58-79 app/…/profileViewManager.js• L141-241 app/…/profileViewManager.js• L431-488 app/…/profileViewManager.js• L612-635 app/…/profileViewManager.js• L721-733

Workspace identity

The shell tracks which profile owns each Teams surface. This includes a profile view and the popups or embedded web content that it creates. The mapping lets main-process actions resolve the account behind an event without treating unrelated shell dialogs as a profile.

When a profile is removed, its view, child surfaces, ownership mapping, and stored session data are torn down together. This prevents a deleted account from remaining active in a hidden window.

References: app/…/profileViewManager.js• L361-387 app/…/profileViewManager.js• L505-565 app/…/profileViewManager.js• L568-610

Profile bootstrap

Profile 0 is created when the legacy session reaches a signed-in Teams page and has the expected auth cookies. The check runs during startup and again after Teams navigation, because a new user may finish sign-in after the first startup check.

The bootstrap is safe to repeat and does not replace a profile that already represents the legacy session. Once the record exists, the profile manager can expose it to the switcher and attribute the root window to the correct account.

References: app/…/profileViewManager.js• L18-56 app/…/profileViewManager.js• L245-315 app/…/profileViewManager.js• L191-220

Authentication boundary

Authentication is part of the workspace lifecycle because Teams may need a login window, SSO credentials, or a fresh session before a profile can become usable. The main window handles the web login challenge and the login service provides a short-lived modal form when configured SSO cannot answer it automatically.

Each web content owner tracks its own first login attempt. This keeps one profile's failed auth challenge from changing another profile's session. Detailed login, SSO, WebAuthn, and client-certificate behavior is covered in Authentication and single sign-on.

References: app/…/index.js• L5-10 app/…/index.js• L19-59 app/…/index.js• L61-93 app/…/index.js• L787-843

Child pages

Change checklist

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

  • Changes to the startup order must preserve the dependency between a ready main window, its session, profile view creation, and services that bind to those sessions.
  • Changes to the legacy partition or profile record shape must preserve Profile 0 bootstrap and the mapping between saved profile state and the root window.
  • Changes to protocol patterns or command-line handling must cover both first-launch links and second-instance links, including the in-page routing fallback.
  • Changes to profile view ownership must keep popup attribution, window-open policy, screen-share session binding, and profile removal teardown aligned.
  • Changes to storage clearing must include every persistent profile partition, not only the default workspace session.

Important failure modes

TriggerConsequenceGuard
A second process starts while the first process owns the lockA new desktop shell is not created, and the new link can be lost if the handoff path does not restore and route the existing windowSingle-instance handoff through second-instance and onAppSecondInstance
Profile 0 is not registered after a user completes first loginThe existing signed-in workspace is not shown in the profile switcherTeams-host bootstrap on navigation with an auth-cookie check
A deep link is sent to a background profile without activating itThe link may load while the user still sees another accountProfile window-open handling activates the originating profile
A profile is removed without clearing its partitionA later user of the same installation can see the removed account's stored Teams stateProfile teardown clears the saved partition and closes descendant surfaces
The Teams renderer process becomes unusableThe application can remain open with a blank or unresponsive workspaceRenderer-gone handling quits so the app can restart cleanly

Key files

FileWhy to read it
package.jsonDefines the Electron entry point, run commands, and packaged msteams protocol.
app/index.jsShows process startup, single-instance ownership, app-ready ordering, and top-level shutdown.
app/…/index.jsCoordinates the main window, Teams navigation, deep links, auth hooks, and shell events.
app/…/browserWindowManager.jsDefines the main desktop window and its persistent default session.
app/…/index.jsDefines saved profile state, active-profile changes, and legacy Profile 0 bootstrap data.
app/…/profileViewManager.jsConnects profile records to visible workspace views and owns profile view teardown.
app/…/deepLinkRouter.jsDefines the fast in-page deep-link attempt and its full-navigation fallback.
app/…/index.jsShows how the main window and short-lived login dialog participate in authentication.