Skip to content

Add explicit permission check handler for media queries#2289

Closed
IsmaelMartinez wants to merge 3 commits intomainfrom
worktree-vivid-giggling-globe
Closed

Add explicit permission check handler for media queries#2289
IsmaelMartinez wants to merge 3 commits intomainfrom
worktree-vivid-giggling-globe

Conversation

@IsmaelMartinez
Copy link
Owner

Summary

  • Adds session.setPermissionCheckHandler(() => true) so that navigator.permissions.query() explicitly reports "granted" for camera/microphone
  • Without this, Teams' calling module may fail during initialisation because Electron's default permissionCheck can return an unexpected state for media queries

Closes #2221

Test plan

  • Verify calls still work on X11
  • Verify calls still work on Wayland
  • Verify screen sharing still works
  • Verify notifications still work

🤖 Generated with Claude Code

Teams' calling module may query navigator.permissions before
starting a call. Without setPermissionCheckHandler, Electron can
return an unexpected state, which could cause the calling component
to fail during initialisation.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@github-actions
Copy link
Contributor

github-actions bot commented Mar 3, 2026

✅ Changelog entry generated and committed to this PR:

Add explicit permission check handler for media queries - by @IsmaelMartinez (#2289)

The file .changelog/pr-2289.txt will be included when you merge this PR.

You can edit it directly in this PR if needed.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces a fix for an issue where the Teams calling module could fail to initialize within the Electron application. The problem stemmed from Electron's default permission checks returning an unexpected state for media queries. By explicitly setting a permission check handler to always grant camera and microphone access, the PR ensures consistent permission reporting, allowing the Teams calling module to initialize correctly.

Highlights

  • Media Permissions: Added an explicit session.setPermissionCheckHandler(() => true) to ensure navigator.permissions.query() reports "granted" for camera and microphone, which resolves an issue with Teams' calling module initialization.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • app/mainAppWindow/index.js
    • Added a new line of code to set an explicit permission check handler for the web contents session.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

The pull request addresses an issue where Teams' calling module might fail due to unexpected states for media queries by explicitly setting a permission check handler to ensure navigator.permissions.query() reports 'granted' for camera and microphone. However, this introduces a significant security risk by explicitly granting all permission requests in the Electron session, bypassing critical security controls. The current implementation grants all permissions universally, which could lead to unintended security implications. Furthermore, the preload script contains a generic IPC bridge, a known security anti-pattern. A more targeted approach with granular permission checks, focusing only on necessary permissions, and removing the generic IPC bridge is recommended to improve the application's security posture and adhere to the principle of least privilege.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 3, 2026

📦 PR Build Artifacts

Build successful! Download artifacts:

🐧 Linux

x86_64 (435.61 MB) - Contains: .deb, .rpm, .tar.gz, .AppImage

arm64 (426.83 MB) - Contains: .deb, .rpm, .tar.gz, .AppImage

armv7l (404.89 MB) - Contains: .deb, .rpm, .tar.gz, .AppImage

🍎 macOS

x86_64 (125.29 MB) - Contains: .dmg

🪟 Windows

x86_64 (105.74 MB) - Contains: .exe installer


📝 Note: Snap packages (.snap) are built in a separate workflow

View workflow run

🕐 Last updated: 2026-03-03 11:51 UTC

@github-actions
Copy link
Contributor

github-actions bot commented Mar 3, 2026

📦 PR Snap Build Artifacts

Snap builds successful! Download artifacts:

🐧 Linux Snap Packages

x86_64 (107.67 MB)

arm64 (104.58 MB)

armv7l (98.82 MB)


📝 Note: Other package formats (.deb, .rpm, .AppImage, .dmg, .exe) are built in the main workflow

View workflow run

Restrict permission grants to known Teams origins instead of
granting all permissions universally.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@sonarqubecloud
Copy link

sonarqubecloud bot commented Mar 3, 2026

IsmaelMartinez added a commit that referenced this pull request Mar 13, 2026
Teams' calling component crashes during _getInitialState because
Electron does not grant media permissions by default. This adds
permission handling at three layers:

1. setPermissionRequestHandler - grants camera/microphone/display-capture
   requests so Teams can access devices without a prompt dialog
2. setPermissionCheckHandler - returns true for trusted Teams origins so
   navigator.permissions.query() reports the correct state
3. Preload permissions.query() override - directly patches the renderer
   Permissions API to report 'granted' for media, covering Chromium
   version differences in how the native handler maps to the JS API

Supersedes #2289.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@IsmaelMartinez
Copy link
Owner Author

Superseded by #2331, which includes this change plus two additional permission-handling layers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

[Bug]: Crash when using camera or microphone

1 participant