Skip to content

feat: native macOS service provider for 'Open with Code' in Finder#302816

Open
ulugbekna wants to merge 2 commits intomainfrom
ulugbekna/finder-native-service
Open

feat: native macOS service provider for 'Open with Code' in Finder#302816
ulugbekna wants to merge 2 commits intomainfrom
ulugbekna/finder-native-service

Conversation

@ulugbekna
Copy link
Contributor

@ulugbekna ulugbekna commented Mar 18, 2026

@deepak1556 wdyt?

Replace the Automator workflow approach with a native NSServices provider
as suggested by @deepak1556. This approach:

- Declares NSServices in the app bundle's Info.plist so the service is
  always available when VS Code is installed (no install/uninstall step)
- Uses a native Objective-C++ Node addon that registers as
  NSApp.servicesProvider to handle the service callback
- Implements validateMenuItem: for menu enable/disable logic
- Forwards received file paths to windowsMainService.open() using the
  same code path as the existing open-file event handler

Files:
- build/darwin/sign.ts — inject NSServices into Info.plist
- build/filters.ts — exclude .gyp/.mm from hygiene checks
- src/vs/platform/native/electron-main/finderService/ — native addon
  (binding.gyp + Objective-C++ source)
- src/vs/platform/native/electron-main/finderService.ts — TS wrapper
- src/vs/code/electron-main/app.ts — register provider at startup

TODO before merge:
- Publish @vscode/finder-service as a package or integrate into build
- Add to package.json dependencies
- Wire node-gyp rebuild into the build pipeline
- Test cross-architecture builds (x64 + arm64)
…e/disable API

Address @deepak1556's feedback:
- Native module self-registers as NSApp.servicesProvider on load
  (no explicit init() call needed from JS)
- Expose onOpenFiles(callback) to receive paths from Finder
- Expose setEnabled(bool) to control menu item via validateMenuItem:
- Menu item starts disabled, JS enables after wiring the callback
Copilot AI review requested due to automatic review settings March 18, 2026 13:25
@ulugbekna ulugbekna enabled auto-merge (squash) March 18, 2026 13:25
@ulugbekna ulugbekna self-assigned this Mar 18, 2026
@ulugbekna ulugbekna requested a review from deepak1556 March 18, 2026 13:25
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a native macOS Services provider so Finder can show “Open with {product}” and pass selected file/folder paths directly into VS Code’s Electron main process (without requiring an Automator workflow install step).

Changes:

  • Introduces a new native Node addon (@vscode/finder-service) implementing an openFiles macOS Services handler.
  • Wires the addon into Electron main (CodeApplication) and forwards received paths into windowsMainService.open(...).
  • Updates macOS signing to inject an NSServices entry into the app’s Info.plist, and adjusts hygiene filters for the new file types.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
src/vs/platform/native/electron-main/finderService/src/finderService.mm Implements the macOS Services provider and bridges to JS via N-API.
src/vs/platform/native/electron-main/finderService/package.json Defines the new native addon package metadata and build script.
src/vs/platform/native/electron-main/finderService/binding.gyp Adds node-gyp build configuration for the addon (macOS frameworks/ARC).
src/vs/platform/native/electron-main/finderService.ts Adds a macOS-only loader for the addon in Electron main.
src/vs/code/electron-main/app.ts Initializes the Finder service integration and opens received paths in new windows.
build/filters.ts Updates hygiene filters for .mm and .gyp files.
build/darwin/sign.ts Injects NSServices into Info.plist during macOS signing.

@vs-code-engineering
Copy link
Contributor

📬 CODENOTIFY

The following users are being notified based on files changed in this PR:

@bpasero

Matched files:

  • src/vs/code/electron-main/app.ts
  • src/vs/platform/native/electron-main/finderService.ts
  • src/vs/platform/native/electron-main/finderService/binding.gyp
  • src/vs/platform/native/electron-main/finderService/package.json
  • src/vs/platform/native/electron-main/finderService/src/finderService.mm

@vs-code-engineering vs-code-engineering bot added this to the 1.113.0 milestone Mar 18, 2026
Copy link
Collaborator

@deepak1556 deepak1556 left a comment

Choose a reason for hiding this comment

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

This is much better, thank you. However, can you separate out the native addon code into its own repo and consume as a dependency. Example https://github.com/microsoft/vscode-windows-registry

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.

3 participants