Skip to content

Unnecessary extra Terminal in IDE #6186

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

Closed
jankeromnes opened this issue Oct 13, 2021 · 20 comments
Closed

Unnecessary extra Terminal in IDE #6186

jankeromnes opened this issue Oct 13, 2021 · 20 comments
Labels
component: ide editor: code (browser) meta: stale This issue/PR is stale and will be closed soon team: IDE type: bug Something isn't working user experience

Comments

@jankeromnes
Copy link
Contributor

jankeromnes commented Oct 13, 2021

Bug description

When your .gitpod.yml implements a certain number of tasks, there is now always an extra Terminal open in VS Code.

For example, the Gitpod repository specifies three tasks (also known as Terminals):

gitpod/.gitpod.yml

Lines 38 to 46 in 9d4bfb5

tasks:
- name: Java
init: leeway exec --package components/supervisor-api/java:lib --package components/gitpod-protocol/java:lib -- ./gradlew jar
- name: TypeScript
before: scripts/branch-namespace.sh
init: yarn --network-timeout 100000 && yarn build
- name: Go
init: leeway exec --filter-type go -v -- go mod verify
openMode: split-right

However, when opening Gitpod in Gitpod, we observe four Terminals (the top-most one is empty):

Screenshot 2021-10-13 at 10 35 06

Screenshot 2021-10-13 at 10 35 18

Steps to reproduce

  1. Open https://gitpod.io/#https://github.com/gitpod-io/gitpod
  2. Count the number of Terminals open in VS Code

Workspace affected

No response

Expected behavior

There shouldn't be an unnecessary extra empty Terminal open in VS Code:

  • Either we re-use the first empty Terminal for the first task
  • Or we close the first empty Terminal when there are tasks in .gitpod.yml

(Note: It is fine to have an empty Terminal open by default when there are no tasks in .gitpod.yml)

Example repository

https://github.com/gitpod-io/gitpod

Anything else?

No response

@jankeromnes jankeromnes added user experience component: ide type: improvement Improves an existing feature or existing code team: IDE labels Oct 13, 2021
@akosyakov
Copy link
Member

I would say it is rather a bug, but tricky one. We streamlined terminal integration by reusing the pty service from Microsoft and cannot control initial terminals anymore. So if you open a terminal panel and there are not yet terminals contributed by our extension then default pty service will create a new one. Right now we always show the terminal panel, maybe we don't do it. cc @loujaybee @svenefftinge

I removed it from the inbox, since it does not seem to be major issue.

@akosyakov akosyakov added type: bug Something isn't working editor: code (browser) and removed type: improvement Improves an existing feature or existing code labels Oct 13, 2021
@0Grit
Copy link

0Grit commented Oct 13, 2021

That terminal doesn't usually have the environment variables I want the users of my workspace to have.

@akosyakov
Copy link
Member

That terminal doesn't usually have the environment variables I want the users of my workspace to have.

Could you share steps to reproduce? I tried on gitpod-io/gitpod and seems to be fine there.

@0Grit
Copy link

0Grit commented Oct 14, 2021

In my case I was adding a tab completion script to .bashrc during init of a prebuild task.
The only way I could think of to ensure the completion script was active for users of my workspace was to exit the prebuild task in the command section.
However the "extra" terminal still remained and did not have my tab completion script active. From recollection it also did not have any of the environment variables I was setting in the prebuild task either.

However, some of this could be related to the other issue I've been battling for a while related to command failures in the init section of a pre-build task. All together it is resulting in a bit of superstition.

The individual commits of this PR tell the story. golioth/example-application#1

@akosyakov
Copy link
Member

I think you should add it as a part of Dockerimage. There is no guarantee that something sourced in one terminal can be available in another. There could be different race condition when a regular user terminal is started before task terminals execute any of your commands.

@0Grit
Copy link

0Grit commented Oct 14, 2021

Problem is, a command I need to run post dockerimage gives me the completion script.

@akosyakov
Copy link
Member

akosyakov commented Oct 14, 2021

Problem is, a command I need to run post dockerimage gives me the completion script.

There is not way to generate the completion script in Dockerimage? It has to be post?

@0Grit
Copy link

0Grit commented Oct 14, 2021

It technically varies with the version of tooling specified by a config file in the workspace repository. I'm taking a note to dig into this a bit more and see if making sure I get the 'correct' completion script is redundant.

@johndunderhill
Copy link

FWIW, I'm having the same problem: I run a setup script when the workspace is started or restarted. This script detects Gitpod, and sets up the environment for development and testing. On bare metal, the script configures the environment for staging/production, loading a bunch of additional drivers that don't work on Gitpod. The configuration is reflected in a collection of environment variables that need to be added to the shell. I do this by appending a few lines to .bashrc. This works beautifully everywhere, except for that extra phantom terminal, which is confusing my developers and causing other problems.

@jeanp413 jeanp413 self-assigned this Oct 20, 2021
jeanp413 added a commit to gitpod-io/openvscode-server that referenced this issue Oct 20, 2021
@jeanp413
Copy link
Member

jeanp413 commented Oct 20, 2021

Pushed gitpod-io/openvscode-server@e83735d fixing this (this only works for new workspaces though). Should be in tomorrow's insiders.
You'll still see an extra terminal if you reload or access a workspace with a stored workbench state with the panel already open

akosyakov pushed a commit to gitpod-io/openvscode-server that referenced this issue Oct 20, 2021
jeanp413 added a commit to gitpod-io/openvscode-server that referenced this issue Oct 21, 2021
@akosyakov
Copy link
Member

@jeanp413 i tried it seems to work
@0Grit @johndunderhill Could you try how it works for you? You can switch to Insiders in preferences: https://gitpod.io/preferences

I just want to understand whether issue is addressed or there is something to do.

@0Grit
Copy link

0Grit commented Oct 21, 2021

Was literally checking as you typed.

@0Grit
Copy link

0Grit commented Oct 21, 2021

@akosyakov my workspace is struggling to start... EDIT: (Restarted my browser and the workspace came up, chrome)

@johndunderhill
Copy link

@akosyakov Thanks for your help with this. I switched to the 'Insider' track in preferences and created a new workspace for an affected repo. This seems to work--no extra terminal, and the environment variables are present.

startup

@johndunderhill
Copy link

@akosyakov But...we still get an extra terminal on restarts:

startup3

@svenefftinge
Copy link
Member

@akosyakov is the restart issue existing because the terminal is stored in the layout and therefore we get the race again? I think users should get the same terminals on restarts as on first start.

@akosyakov
Copy link
Member

@akosyakov is the restart issue existing because the terminal is stored in the layout and therefore we get the race again? I think users should get the same terminals on restarts as on first start.

It will require changing MS code. Stock VS Code server does not preserve terminals between sessions.

@0Grit
Copy link

0Grit commented Oct 22, 2021

Same result here. Works then doesn't after workspace restart.

jeanp413 added a commit to gitpod-io/openvscode-server that referenced this issue Oct 24, 2021
akosyakov pushed a commit to gitpod-io/openvscode-server that referenced this issue Oct 25, 2021
@jeanp413
Copy link
Member

Removing from groundwork as the main issue is fixed except for this edge case that will require changes in core vscode

You'll still see an extra terminal if you reload or access a workspace with a stored workbench state with the panel already open

@jeanp413 jeanp413 removed their assignment Jan 10, 2022
@stale
Copy link

stale bot commented Apr 11, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the meta: stale This issue/PR is stale and will be closed soon label Apr 11, 2022
@stale stale bot closed this as completed Apr 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: ide editor: code (browser) meta: stale This issue/PR is stale and will be closed soon team: IDE type: bug Something isn't working user experience
Projects
None yet
Development

No branches or pull requests

6 participants