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

Initial contribution of @theia/external-terminal #9186

Merged
merged 1 commit into from
Mar 24, 2021

Conversation

DucNgn
Copy link
Contributor

@DucNgn DucNgn commented Mar 11, 2021

What it does

  • Introduces a new extension: @theia/external-terminal. The extension adds support for spawning external terminals from Electron applications. In the future, the extension can be extended to support features such as spawning external terminals during debug sessions.
    (Browser applications should not pull this extension).

Checklist for merging:

Command:

Preferences:

  • The PR contributes the following preferences:
    • terminal.external.windowsExec
    • terminal.external.osxExec
    • terminal.external.linuxExec
      to allow users to customize the desired terminal application to run on their current platform.
  • On startup, the backend determines the default terminal on the host machine, then sets the default field in the preference schema accordingly.
  • Changing the Exec preference of other OS than the current one won't have any effect. (i.e: Changing osxExec while running on Windows doesn't have any effect).

How to test:

  • Start Theia Electron application
  • Verify the default exec of host OS is displaying the correct terminal.

Calling command Open New External Terminal has different behaviors, depending on the current workspace status:

No workspaces opened and no current active editor -> Spawn the terminal at the user home directory.

no-ws-no-editors.mp4

No workspaces opened but has an active editor -> Spawn the terminal at the parent folder of the active editor file.

no-ws-active-editor.mp4

Only one workspace opened -> Spawn the terminal at the root of the current workspace.

singleWS.mp4

Multi-root workspace opened -> Displays a quick pick to let users choose which workspace to spawn the terminal.

multiWS.mp4

Review checklist

Reminder for reviewers

Signed-off-by: Duc Nguyen duc.a.nguyen@ericsson.com

@DucNgn DucNgn force-pushed the dn/external-terminal branch from ff65621 to 5d61df6 Compare March 11, 2021 16:56
@vince-fugnitto
Copy link
Member

vince-fugnitto commented Mar 11, 2021

I'll file the appropriate CQs for the changes.

Edit: added a link in the pull-request description: CQ.

@vince-fugnitto vince-fugnitto added electron issues related to the electron target terminal issues related to the terminal CQ Required (deprecated) issues requiring a CQ (contributor questionnaire) labels Mar 11, 2021
@vince-fugnitto
Copy link
Member

vince-fugnitto commented Mar 16, 2021

The CQ has been approved 👍:

We have completed a high level triage of the attachment and you may now check the content into your project’s source code repository...

Copy link
Member

@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.

LGTM, works well on Windows!

I just have minor comments.

@DucNgn DucNgn force-pushed the dn/external-terminal branch from 5d61df6 to e6af6d0 Compare March 17, 2021 18:41
@paul-marechal paul-marechal marked this pull request as ready for review March 17, 2021 19:44
@paul-marechal
Copy link
Member

paul-marechal commented Mar 17, 2021

Please rebase on latest master, I just merged #9169 :)

Copy link
Contributor

@colin-grant-work colin-grant-work left a comment

Choose a reason for hiding this comment

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

Seems to be working for me. Some minor comments on the code and some even more minor comments on the comments. I do wonder why the name terminal-external rather than external-terminal. The former sounds like it's things that happen outside of the terminal, rather than terminals that appear outside the application.

packages/terminal-external/README.md Outdated Show resolved Hide resolved
packages/terminal-external/src/common/terminal-external.ts Outdated Show resolved Hide resolved
} else if (process.env.DESKTOP_SESSION === 'kde-plasma') {
r('konsole');
} else if (process.env.COLORTERM) {
r(process.env.COLORTERM);
Copy link
Contributor

Choose a reason for hiding this comment

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

This seems to fail for me (on RedHat Linux) at this branch. It seems that the COLORTERM in my environment is truecolor, but when that's used to spawn a terminal, the openTerminal request fails.

root ERROR Request openTerminal failed with error: spawn truecolor ENOENT Error: spawn truecolor ENOENT
    at Process.ChildProcess._handle.onexit (internal/child_process.js:264:19)
    at onErrorNT (internal/child_process.js:456:16)
    at processTicksAndRejections (internal/process/task_queues.js:81:21)

VSCode suffers the same failure, though, so perhaps we shouldn't expect to do better, and once I set the preference to the correct path, I do get a new terminal as expected.

Copy link
Member

@paul-marechal paul-marechal Mar 22, 2021

Choose a reason for hiding this comment

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

https://www.gnu.org/software/gettext/manual/html_node/The-TERM-variable.html

Not sure what the actual semantic of TERM and COLORTERM is, but IIUC one can use them to tell programs like xterm to configure some kind of feature support, or in the case of COLORTERM it would be set by the terminal application itself for processes spawned by it to detect features like truecolor support. So trying to use it to get an executable sounds weird, given that?

Being as bad as VS Code is acceptable, but if someone is able to tell for sure that this is bogus then we can fix that logic.

@vince-fugnitto
Copy link
Member

vince-fugnitto commented Mar 18, 2021

I do wonder why the name terminal-external rather than external-terminal.

@colin-grant-work I believe it was mainly to group terminal functionality together on the filesystem:

image

I agree however that external-terminal reads better.

@colin-grant-work
Copy link
Contributor

On a side note, I ❤️ the desktop background in the screencasts in the description.

@DucNgn DucNgn force-pushed the dn/external-terminal branch from 3ace0ae to 4c4a7df Compare March 22, 2021 16:20
@DucNgn DucNgn changed the title Initial contribution of @theia/terminal-external Initial contribution of @theia/external-terminal Mar 22, 2021
@DucNgn DucNgn force-pushed the dn/external-terminal branch from 5f7d24a to a3aa8d9 Compare March 22, 2021 19:38
@DucNgn
Copy link
Contributor Author

DucNgn commented Mar 22, 2021

@colin-grant-work

Thank you for such a detailed review, super appreciate it. I updated the PR to address your comments 👍

Side note: my razer desktop background 😄

Copy link
Member

@vince-fugnitto vince-fugnitto left a comment

Choose a reason for hiding this comment

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

The updated changes look good to me, and are well described.
We can always update the extension in the future to add additional features, and/or refactorings if necessary.

The changes also work well, I verified on macOS and Linux 👍

@DucNgn DucNgn force-pushed the dn/external-terminal branch from a3aa8d9 to 8f08be0 Compare March 23, 2021 13:18
The following commit adds a new extension `@theia/terminal-external`.
The extension adds support for spawning external terminals from Electron applications.

+ Supports opening native terminals by calling `Open New External Terminal` from the command palette.
+ The commit contributes the following preferences:
    - `terminal.external.windowsExec`
    - `terminal.external.osxExec`
    - `terminal.external.linuxExec`
to allow users to customize the desired terminal application to run on their current OS.

Co-authored-by: Paul <paul.marechal@ericsson.com>
Co-authored-by: vince-fugnitto <vincent.fugnitto@ericsson.com>
Signed-off-by: Duc Nguyen <duc.a.nguyen@ericsson.com>
@DucNgn DucNgn force-pushed the dn/external-terminal branch from 8f08be0 to db38e00 Compare March 23, 2021 13:19
@DucNgn
Copy link
Contributor Author

DucNgn commented Mar 23, 2021

@kittaakos Thanks for the review! Just wanted to clarify that this extension targets Electron applications only.

Other than that, I updated the PR to address your comments.

@kittaakos
Copy link
Contributor

Just wanted to clarify that this extension targets Electron applications only.

👍 Can we enforce it? I am curious if this is something Theia can do. What happens when a downstream adds the new @theia/external-terminal extension to the browser app? Thanks!

Copy link
Contributor

@kittaakos kittaakos left a comment

Choose a reason for hiding this comment

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

Very nice! Thank you for the new feature

@DucNgn
Copy link
Contributor Author

DucNgn commented Mar 23, 2021

What happens when a downstream adds the new @theia/external-terminal extension to the browser app?

I believe adding the extension to a browser app won't break anything, it simply will just be a no-op.

@kittaakos
Copy link
Contributor

I believe adding the extension to a browser app won't break anything, it simply will just be a no-op.

Of course, you're right. Thank you!

{
"backendElectron": "lib/electron-node/external-terminal-backend-module",
"frontendElectron": "lib/electron-browser/external-terminal-frontend-module"
}

@vince-fugnitto
Copy link
Member

I'll merge the pull-request tomorrow so it can be added to the upcoming release.
Since the new extension is pretty self-contained (no other extension depends on it) there isn't a potential risk of breaking anyone.

Thank you for the work @dukengn 👍

@paul-marechal paul-marechal merged commit eb83e0e into eclipse-theia:master Mar 24, 2021
@vince-fugnitto vince-fugnitto deleted the dn/external-terminal branch March 24, 2021 17:12
@vince-fugnitto vince-fugnitto added this to the 1.12.0 milestone Mar 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CQ Required (deprecated) issues requiring a CQ (contributor questionnaire) electron issues related to the electron target terminal issues related to the terminal
Projects
None yet
Development

Successfully merging this pull request may close these issues.

terminal: add support for opening external terminal windows
5 participants