Skip to content

feat(electron): grant microphone and clipboard permissions#40

Merged
johannesjo merged 2 commits intojohannesjo:mainfrom
Maskar:pr/electron-permissions
Mar 28, 2026
Merged

feat(electron): grant microphone and clipboard permissions#40
johannesjo merged 2 commits intojohannesjo:mainfrom
Maskar:pr/electron-permissions

Conversation

@Maskar
Copy link
Copy Markdown
Contributor

@Maskar Maskar commented Mar 28, 2026

Summary

  • Grant media (microphone) and clipboard-read permissions via Electron's permission handler
  • Add com.apple.security.device.audio-input entitlement for macOS builds

Motivation

Voice input and clipboard access are blocked by default in Electron. This enables CLI tools that use microphone input and ensures Cmd+V paste works reliably in terminals.

Test plan

  • Voice input works in terminal sessions
  • Cmd+V paste works in terminals

Copy link
Copy Markdown
Owner

@johannesjo johannesjo left a comment

Choose a reason for hiding this comment

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

Thanks for the PR @Maskar — nice and clean change. Two things I'd like addressed before merging:

1. media permission grants camera access too (critical)

permission === 'media' passes for both audio and video requests. The handler's 4th parameter (details) includes mediaTypes which should be checked to restrict this to audio only:

session.defaultSession.setPermissionRequestHandler(
  (_webContents, permission, callback, details) => {
    if (permission === 'clipboard-read') {
      return callback(true);
    }
    if (permission === 'media') {
      const types = (details as { mediaTypes?: string[] }).mediaTypes ?? [];
      // Only grant audio (microphone), deny video (camera)
      return callback(types.every((t) => t === 'audio'));
    }
    callback(false);
  },
);

2. Missing NSMicrophoneUsageDescription for macOS (important)

With hardenedRuntime: true, macOS requires a usage description string for microphone access — without it the OS will silently deny the permission. Add via extendInfo in package.json:

"mac": {
  "extendInfo": {
    "NSMicrophoneUsageDescription": "Parallel Code needs microphone access for voice input in terminal sessions."
  },
  ...
}

Add permission handler for media (microphone) and clipboard-read access.
Add audio-input entitlement for macOS builds.
@Maskar Maskar force-pushed the pr/electron-permissions branch from 221689f to c507478 Compare March 28, 2026 20:17
…UsageDescription

- Check details.mediaTypes to grant only audio (microphone), deny video (camera)
- Add NSMicrophoneUsageDescription for macOS hardened runtime compatibility
@johannesjo
Copy link
Copy Markdown
Owner

Thank you very much!

@johannesjo johannesjo merged commit b51c0b7 into johannesjo:main Mar 28, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants