feat: native macOS service provider for 'Open with Code' in Finder#302816
Open
feat: native macOS service provider for 'Open with Code' in Finder#302816
Conversation
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
Contributor
There was a problem hiding this comment.
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 anopenFilesmacOS Services handler. - Wires the addon into Electron main (
CodeApplication) and forwards received paths intowindowsMainService.open(...). - Updates macOS signing to inject an
NSServicesentry into the app’sInfo.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. |
Contributor
📬 CODENOTIFYThe following users are being notified based on files changed in this PR: @bpaseroMatched files:
|
deepak1556
requested changes
Mar 18, 2026
Collaborator
deepak1556
left a comment
There was a problem hiding this comment.
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
@deepak1556 wdyt?