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

discussion: electron main fixup #8056

Closed
wants to merge 7 commits into from

Conversation

paul-marechal
Copy link
Member

What it does

How to test

Review checklist

Reminder for reviewers

Akos Kitta added 7 commits June 19, 2020 10:23
Signed-off-by: Akos Kitta <kittaakos@typefox.io>
Signed-off-by: Akos Kitta <kittaakos@typefox.io>
as the electron main cannot access the window object.
alternatively, we could get the config from the window:
`currentWindow.webContents.executeJavaScript` and get the config,
but the window is not yet loaded :/

Signed-off-by: Akos Kitta <kittaakos@typefox.io>
it can be retrieved from the FE config

Signed-off-by: Akos Kitta <kittaakos@typefox.io>
Signed-off-by: Akos Kitta <kittaakos@typefox.io>
Signed-off-by: Akos Kitta <kittaakos@typefox.io>
fixed the workspace location issue at app start.

Signed-off-by: Akos Kitta <kittaakos@typefox.io>
Copy link
Member Author

@paul-marechal paul-marechal left a comment

Choose a reason for hiding this comment

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

Just had one comment, the rest of the changes are fine with me. Once resolved I will move those changes into the original PR.

}

protected async onSecondInstance(event: ElectronEvent, argv: string[], cwd: string): Promise<void> {
await this.launch({ argv, cwd, secondInstance: true });
Copy link
Member Author

@paul-marechal paul-marechal Jun 19, 2020

Choose a reason for hiding this comment

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

Why remove cwd???

My approach was to pass everything Electron gives us because here's how the second instance API works:

  1. You can do cd some/place && app . and it will open /some/place as a workspace because the app knows what's the cwd when you do app .
  2. Now the app is already running, and you open a new terminal and do cd somewhere/else && app .. Here it will trigger the second-instance mechanism and forward the cwd used to invoke the second instance to the already running process. If we don't have the new cwd we cannot resolve app . to the correct location.

Copy link
Contributor

Choose a reason for hiding this comment

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

Why remove cwd???

Work in progress; otherwise, I could not start the app without a workspace error on macOS.

Copy link
Contributor

Choose a reason for hiding this comment

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

BTW, can you please fix the macOS behavior on your branch, and I'll just rebase this PR from yours and get back the cwd support. What you wrote 👆 sounds good to me, a very nice addition, but it does not work on macOS 😕 We must verify the bundled app behavior too.

Copy link
Contributor

Choose a reason for hiding this comment

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

  • You can do cd some/place && app . and it will open /some/place as a workspace because the app knows what's the cwd when you do app .
  • Now the app is already running, and you open a new terminal and do cd somewhere/else && app .. Here it will trigger the second-instance mechanism and forward the cwd used to invoke the second instance to the already running process. If we don't have the new cwd we cannot resolve app . to the correct location.

@marechal-p, VS Code handles it differently, right?

cat `which code`
#!/usr/bin/env bash
#
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.

function realpath() { python -c "import os,sys; print(os.path.realpath(sys.argv[1]))" "$0"; }
CONTENTS="$(dirname "$(dirname "$(dirname "$(dirname "$(realpath "$0")")")")")"
ELECTRON="$CONTENTS/MacOS/Electron"
CLI="$CONTENTS/Resources/app/out/cli.js"
ELECTRON_RUN_AS_NODE=1 "$ELECTRON" "$CLI" "$@"
exit $?

So the approach you have implemented does not work on macOS; when I start the app from a terminal in dev mode with yarn, or I launch the electron backend launch config from VS Code, without specifying any file my options will fall back to the electron process: "/Users/akos.kitta/Desktop/theia/node_modules/electron/dist/Electron.app/Contents/MacOS/Electron" and this cannot be opened for sure.

Is there a chance to support this new feature once it works in a follow-up PR?

CC: @akosyakov

@kittaakos kittaakos mentioned this pull request Jun 22, 2020
1 task
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