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

macOS: revisit usage of -n for open from CLI #132569

Closed
bpasero opened this issue Sep 7, 2021 · 5 comments
Closed

macOS: revisit usage of -n for open from CLI #132569

bpasero opened this issue Sep 7, 2021 · 5 comments
Assignees
Labels
electron Issues and items related to Electron under-discussion Issue is under discussion for relevance, priority, approach workbench-cli VS Code Command line issues

Comments

@bpasero
Copy link
Member

bpasero commented Sep 7, 2021

This is a follow up to #102975. Wondering whether we could drop our usage of -n when running with open command and rather rely on the open-file event in Electron to get the data passed in:

https://github.com/electron/electron/blob/13-x-y/docs/api/app.md#event-open-file-macos

My understanding is that this event would fire when a second instance is launched via open and without -n.

It probably needs an upstream fix to get access to more data. Similar to the work we are doing for request single instance lock.

@bpasero bpasero added the electron Issues and items related to Electron label Sep 7, 2021
@bpasero bpasero changed the title Revisit usage of -n for open macOS: revisit usage of -n for open from CLi Sep 7, 2021
@bpasero bpasero changed the title macOS: revisit usage of -n for open from CLi macOS: revisit usage of -n for open from CLI Sep 7, 2021
@bpasero
Copy link
Member Author

bpasero commented Sep 8, 2021

I ran a quick test by removing the -n from cli.ts and printing the events from open-file here:

app.on('open-file', (event, path) => {

And did not get any call, so maybe this is not working as I had thought.

@deepak1556
Copy link
Contributor

@bpasero why cannot we handle this case via the singleinstance api ?

app.on('second-instance', (event, commandLine, workingDirectory) => {
    // Someone tried to run a second instance, parse commandline for `-n`
   // and force new window if needed
})

If possible I would like to not rely on platform specific event and keep it consistent for all platform via a single entry point, thoughts ?

@bpasero
Copy link
Member Author

bpasero commented Sep 8, 2021

@deepak1556 yes sounds good, I wasn't sure whether when you use open with an existing app identifier that is running triggers the single instance flow too.

@deepak1556
Copy link
Contributor

deepak1556 commented Sep 8, 2021

Yup it will, as open just ends up launching the app process, and there are certain files that are setup in the user data directory to identify an active instance associated with it https://github.com/electron/electron/blob/3b1c9dfc5400ceffb75a934cb6b8686fc5ba3fcd/chromium_src/chrome/browser/process_singleton_posix.cc#L5-L38 should clarify things :)

@rzhao271 rzhao271 added the under-discussion Issue is under discussion for relevance, priority, approach label Oct 5, 2021
@rzhao271 rzhao271 added this to the Backlog milestone Dec 6, 2022
@rzhao271 rzhao271 added the workbench-cli VS Code Command line issues label Dec 6, 2022
@deepak1556
Copy link
Contributor

Merging to #97626, since we want to eventually end up with it.

@deepak1556 deepak1556 closed this as not planned Won't fix, can't repro, duplicate, stale Dec 13, 2022
@rzhao271 rzhao271 removed this from the Backlog milestone Jan 20, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Jan 27, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
electron Issues and items related to Electron under-discussion Issue is under discussion for relevance, priority, approach workbench-cli VS Code Command line issues
Projects
None yet
Development

No branches or pull requests

3 participants