Embedded browser integration and tools
The embedded browser layer adapts the Teams web experience to desktop behavior. The preload layer provides a narrow bridge to desktop services, while browser-side tools observe or adjust the Teams page for notifications, calls, media, navigation, display, and system status.
This page is part of Platform services and focuses on the browser-facing side of those services.
Browser integration boundary
The main application loads Teams in an Electron browser window and attaches home/…/preload.js as the preload layer. This layer runs before the page and gives Teams-compatible page code access to approved desktop actions through electronAPI, such as notifications, zoom, navigation, screen sharing, status changes, and selected Graph operations.
The bridge keeps desktop work in the main process. Page-facing code sends requests over IPC, and the main process performs the system action or returns state. Channel checks in app/…/ipcValidator.js provide the matching security boundary; see Security and web APIs for the wider IPC and web API model.
Preload responsibilities
The preload layer performs three related jobs:
- It exposes desktop capabilities to the Teams page without enabling normal Node integration.
- It restores browser behavior that Teams expects, such as file paths on files dropped or pasted from the operating system. This repair is limited to approved Teams hosts.
- It starts configured browser tools after the page loads and passes them the current configuration and, where needed, the IPC bridge.
The tools are loaded as independent units. A failure in one tool is logged and does not prevent the other tools from starting, so a Teams page change normally reduces one feature instead of stopping the whole desktop adaptation layer.
References: app/…/preload.js• L1-15 app/…/preload.js• L91-215 app/…/preload.js• L411-489 app/…/browserWindowManager.js• L85-110
IPC capability groups
The preload API groups actions by the desktop effect they produce. This makes the browser page a client of platform services rather than the owner of native resources.
| Capability group | Desktop outcome |
|---|---|
| Notifications | Shows native notifications, plays sounds, sends custom toasts, and updates badges or tray state. |
| Calls and media | Chooses screen sources, reports sharing state, and coordinates call or wake-lock state. |
| Display and navigation | Persists zoom, follows navigation state, and provides back or forward actions. |
| Account and service data | Reads selected configuration and requests approved Graph data. |
| User and system state | Reports user status and receives theme changes from the host. |
References: app/…/preload.js• L92-214 app/…/ipcValidator.js• L8-100
Browser notifications
Teams uses the web Notification interface, but the desktop host supports several notification paths. The preload layer replaces that interface with a compatibility factory that selects a web notification, an Electron notification, or the custom in-app toast path from configuration.
Notification paths
The notification method controls where the user sees the alert. The browser path keeps the normal page notification object and asks the host to play the configured sound. The Electron path uses a native system notification and a page-side stub so Teams can keep its normal notification life cycle. The custom path sends a compact toast record to the host notification window.
All paths preserve the page contract that Teams needs: notification objects can register click and close handlers, can close, and can report that they were shown. A disabled notification setting still returns a harmless object so Teams does not stop producing later notifications.
References: app/…/preload.js• L217-295 app/…/preload.js• L304-407 app/…/service.js• L38-89 app/…/index.js• L1-21
Notification life cycle
The Electron path gives each notification an opaque identifier. The main process uses that identifier to send click and close events back to the renderer that created the notification. The bridge then invokes the matching Teams handler, which lets a click open the related conversation and lets a system dismissal complete Teams' own state machine.
The bridge keeps a bounded set of recent entries. Closing is idempotent, and an entry can still receive a click after close because the native notification may remain clickable. This prevents duplicate close events, listener growth, and lost clicks.
This diagram shows how a Teams notification request becomes a native alert and returns lifecycle events to the page.
sequenceDiagram
participant Teams as Teams page
participant Preload as Browser preload
participant Main as Main notification service
participant OS as Desktop notification system
Teams->>Preload: Create Notification
Preload->>Main: show-notification with opaque id
Main->>OS: Show native notification
OS-->>Main: Click or close
Main-->>Preload: notification-clicked or notification-closed
Preload-->>Teams: Invoke matching page handler
References: app/…/preload.js• L229-320 app/…/notificationBridge.js• L20-75 app/…/service.js• L91-151
Activity and unread signals
The browser layer turns Teams activity into desktop signals. activityHub watches supported Teams activity events such as incoming calls, call connection changes, and meeting starts. activityManager forwards call events to the main process and applies host idle state to Teams presence behavior.
Unread activity follows a separate page signal. The title watcher reads the unread number from the Teams document title and emits an unread-count event. The tray renderer turns that event into a tray icon and badge update, while protecting newer counts from being overwritten by slow earlier renders.
References: app/…/activityManager.js• L4-52 app/…/activityManager.js• L55-115 app/…/activityHub.js• L1-10 app/…/activityHub.js• L200-240 app/…/mutationTitle.js• L52-113 app/…/trayIconRenderer.js• L17-99
Browser-side tools
The tools are small, configuration-driven adapters that run beside the Teams page. They use page events, DOM observation, or browser API wrappers to fill gaps between the web client and a desktop application.
User interface tools
UI tools add desktop-like controls without replacing Teams' main interface. They support persistent zoom, system theme changes, navigation buttons, frameless-window adjustments, timestamp copying, custom stickers, and tray or dock rendering.
These tools are resilient to Teams re-renders where possible. For example, navigation controls can be re-created when Teams removes their host element, and theme changes update Teams preferences when the host reports a new system theme. Their purpose is to keep desktop controls aligned with the live web page rather than to own a second UI.
References: app/…/README.md• L121-150 app/…/zoom.js• L15-75 app/…/theme.js• L3-27 app/…/navigationButtons.js• L23-59
Media and meeting tools
Media tools adjust the browser APIs that Teams uses for meetings. They can change microphone processing, ignore the page's reflection of system mute, adjust camera resolution or aspect ratio, prevent unwanted device switching, and show speaking or meeting state. The host can also keep the system awake while a call is active.
These changes affect the local browser media path. They do not replace Teams' meeting service or change the state of remote participants. Meeting and call signals flow through activityHub and then into main-process services such as incoming-call handling and screen-lock control.
References: app/…/README.md• L25-62 app/…/README.md• L64-123 app/…/activityManager.js• L55-115 app/…/browserWindowManager.js• L149-192 app/…/browserWindowManager.js• L251-271
Authentication and service tools
Some tools adapt browser APIs that Teams needs but that the Linux desktop host does not provide in the required form. The WebAuthn tool can route hardware security-key ceremonies through the main process, while preserving browser credential shapes for Teams. It also supports approved login subframes through an origin-checked message relay.
Other tools expose selected Teams state to platform services. Status monitoring can publish presence changes through IPC, and meeting-start detection can emit a fact-only signal for MQTT automation. These tools avoid sending matched meeting text because it can contain personal data.
References: app/…/webauthnOverride.js• L18-163 app/…/mqttStatusMonitor.js• L1-150 app/…/meetingStartDetector.js• L87-138 app/…/meetingStartDetector.js• L243-289
Configuration and lifecycle
The preload loads configuration before it initializes the tool set. Tools that only change page behavior receive configuration; tools that communicate with the host also receive ipcRenderer. Configuration changes are sent to the running page so settings such as icons and notification behavior can take effect without rebuilding the browser window.
The tool set is intentionally best effort. It checks feature flags, browser API support, and expected Teams structures before acting. This matters because Teams is an external web application and can change its DOM or internal React state without notice.
References: app/…/preload.js• L411-489 app/…/README.md• L204-254 tests/…/preloadModules.test.js• L8-63
Cross-process flows
The embedded-browser layer sits between three owners: Teams owns the page state, preload owns the page-facing compatibility surface, and the main process owns native effects. A useful rule is that page observation stays in browser tools while native work, persistence, and external service access cross IPC.
This diagram shows the normal direction of data through the integration layer.
flowchart LR
Teams[Teams web experience]
Tools[Browser-side tools]
Preload[Preload bridge]
Main[Electron main process]
Desktop[Desktop services]
External[Approved external services]
Teams --> Tools
Tools --> Preload
Preload <--> Main
Main --> Desktop
Main --> External
Desktop --> Main
Main --> Preload
Preload --> Teams
The same boundary applies to navigation and menus. Browser tools request a desktop action through electronAPI, while the main process decides how to carry it out. See Desktop integration and menus for the host-side controls that complement this page.
References: app/…/preload.js• L92-214 app/…/navigationButtons.js• L149-200 app/…/browserWindowManager.js• L100-112 app/…/ipcValidator.js• L41-100
Change checklist
When these files or sections are changed, remember to consider these:
- Keep every IPC capability used by app/…/preload.js and the registered tools aligned with the channel allowlist in app/…/ipcValidator.js.
- When changing the notification id or lifecycle contract, update both the main-process relay and the
NotificationBridge; clicks after close and per-profile routing must remain valid. - When adding a tool that uses IPC, add it to the preload initialization path with the required renderer dependency; otherwise it can load and fail only when an event occurs.
- When changing Teams DOM selectors, title formats, or internal activity data, review the matching observers and their fallback or dedup behavior.
- When changing WebAuthn transport data or origin rules, keep the browser serialization, main-process validation, and reconstructed credential contract in step.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| A tool that needs IPC is initialized without the IPC object | The tool starts but fails later when a page or system event calls it | Keep IPC-dependent tools in modulesRequiringIpc and preserve the preload module test. |
| Teams removes or renames a DOM or React surface used by an observer | Unread counts, meeting signals, controls, or status updates stop without changing the host | Use feature checks, scoped observers, fallbacks, and configurable patterns. |
| A notification lifecycle event reaches the wrong renderer or loses its opaque id | A click opens the wrong account or Teams never completes its notification state | Relay through the creating WebContents and keep ids in the bounded notification bridge. |
| WebAuthn relay data comes from an origin outside the configured allowlist | A login subframe could request a host security-key operation | Check the browser-supplied message origin in preload and re-check it in the main process. |
| A file drop or paste occurs on a non-Teams page | A local file path could be exposed to an unrelated page | Restore file paths only for the approved Teams host patterns. |
Key files
| File | Why to read it |
|---|---|
| app/…/preload.js | Primary page-to-host bridge and browser tool bootstrap. |
| app/…/notificationBridge.js | Notification click and close routing back into Teams. |
| app/…/service.js | Native notification display, sound choice, icon handling, and renderer routing. |
| app/…/activityManager.js | Activity, call, idle-state, and wake-lock coordination. |
| app/…/activityHub.js | Shared event source for call and meeting activity. |
| app/…/mutationTitle.js and app/…/trayIconRenderer.js | Unread-count flow from Teams title changes to desktop tray state. |
| app/…/webauthnOverride.js | Browser-to-host security-key adaptation and origin-checked frame relay. |
| app/…/README.md | High-level map of the available browser tool capabilities and configuration model. |
| app/…/browserWindowManager.js | Browser-window setup and the host-side effects used by browser integration. |
| app/…/ipcValidator.js | Authoritative IPC channel allowlist for the browser boundary. |