Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't open Cursor from Toolbar #6

Open
EmptyBlueBox opened this issue Sep 13, 2024 · 7 comments
Open

Can't open Cursor from Toolbar #6

EmptyBlueBox opened this issue Sep 13, 2024 · 7 comments
Assignees
Labels
bug Something isn't working

Comments

@EmptyBlueBox
Copy link

When I add Cursor to the MenuHelper, I can't open it from the Toolbar.

MenuHelper 2024-09-13 16 04 18

Arc 2024-09-13 16 05 10

访达 2024-09-13 16 05 05

@Kyle-Ye
Copy link
Owner

Kyle-Ye commented Sep 14, 2024

Thanks for the reporting.

I can reproduce it and open folder via Cursor in Finder has no problem.

So it is definitely be a bug that MenuHelper need fix.

open . -a "Cursor"

I'm digging into LaunchServices framework for more detail.

Launch Services generated an error at _LSOpenStuffCallLocal:4129, converting to OSStatus -10820: Error Domain=NSOSStatusErrorDomain Code=-10820 "kLSAppDoesNotClaimTypeErr: Not used in 10.3 and later" UserInfo={_LSLine=4129, _LSFunction=_LSOpenStuffCallLocal}
image

@Kyle-Ye Kyle-Ye self-assigned this Sep 14, 2024
@Kyle-Ye Kyle-Ye added the bug Something isn't working label Sep 14, 2024
@Kyle-Ye
Copy link
Owner

Kyle-Ye commented Sep 14, 2024

Filter subsystem: "com.apple.launchservices" and category: "open".

Cursor result:

image

Visual Studio Code result:

image

@Kyle-Ye
Copy link
Owner

Kyle-Ye commented Sep 14, 2024

Spot the issue.

VSCode has 65 CFBundleDocumentTypes declared in its Info.plist which contains the folder item support while Cursor has only 40 CFBundleDocumentTypes declared which does not contains it.

image
<dict>
	<key>CFBundleTypeExtensions</key>
	<array/>
	<key>CFBundleTypeIconFile</key>
	<string>default.icns</string>
	<key>CFBundleTypeName</key>
	<string>Folder</string>
	<key>CFBundleTypeOSTypes</key>
	<array>
		<string>TEXT</string>
		<string>utxt</string>
		<string>TUTX</string>
		<string>****</string>
	</array>
	<key>CFBundleTypeRole</key>
	<string>Editor</string>
	<key>LSItemContentTypes</key>
	<array>
		<string>public.folder</string>
	</array>
</dict>

You can use Cursor to open supported files by right click the file and choose "Open it in Cursor". (.json .csv or anything it has declared).

MenuHelper Toolbar menu is just a shortcut menu for the Control-Click / Right-Click Finder window's background.

@Kyle-Ye
Copy link
Owner

Kyle-Ye commented Sep 14, 2024

You can submit feedback to Cursor and ask them to fix it.

@Kyle-Ye Kyle-Ye closed this as completed Sep 14, 2024
@Kyle-Ye
Copy link
Owner

Kyle-Ye commented Sep 14, 2024

Another solution is that MenuHelper can try to find another API which open(1) uses internal to fix it on MenuHelper side.

open . -a "Cursor"
image

@EmptyBlueBox
Copy link
Author

Thank you!

@Kyle-Ye
Copy link
Owner

Kyle-Ye commented Sep 20, 2024

3 ways to solve the issue.

  1. Wait for a new release to the issue for the upstream/Cursor. (Recommended)
  2. Change cursor app's plist file to add the missing type and code-sign yourself for local use (Risky and may make your account be banned by cursor)
  3. Make MenuHelper to behave the same as open -a xx.

For method 3, I took some time to reverse engineer open and CoreServicesUIAgent behind it.

The answer is we need to make MenuHelper a non-sandbox app or sign it with com.apple.private.launchservices.allowopenwithanyhandler entitlement.

The pseudocode logic is as the following on macOS 15

LSOpenStuffCallLocal:

let magicBool: Bool
if (launcherInSandbox) {
    check("com.apple.private.launchservices.allowopenwithanyhandler")
} else {
    1
}
...
openState.xx = magicBool
...
LSFindHandler(&openState)
// Consume the magicBool

LSFindHandler:
...
if (openState.xx) {
   // Force open it any way
}

For SIP enabled macOS, only Apple can sign a binary with com.apple.private.launchservices.allowopenwithanyhandler entitlement.

So the only way left for MenuHelper is make it a non-sandboxed app here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants