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

Missing option for disabling terminal restoration #39137

Closed
fabiospampinato opened this issue Nov 25, 2017 · 35 comments · Fixed by #189204
Closed

Missing option for disabling terminal restoration #39137

fabiospampinato opened this issue Nov 25, 2017 · 35 comments · Fixed by #189204
Assignees
Labels
feature-request Request for new features or functionality insiders-released Patch has been released in VS Code Insiders terminal-persistence Relating to process reconnection or process revive terminal-process Problems launching processes, managing ptys, exiting, process leaks, etc. verification-needed Verification of issue is requested verified Verification succeeded
Milestone

Comments

@fabiospampinato
Copy link
Contributor

Whenever I open a project, chances are that a terminal will automatically open because the previous time I opened that project, its window had 1 or more terminals. This doesn't work for me:

  1. This "feature" is unpredictable. I may open a project 1 week or month later, who remembers if that window had a terminal?
  2. It's useless. If I want a terminal I'm a shortcut away from it. If I don't need it however, I have to focus to it and close it.
  3. I use my Terminals extension for managing terminals, I absolutely never need an empty terminal automatically open at startup.

What about a terminal.restoreTerminal: boolean option for disabling this?

@vscodebot vscodebot bot added the terminal Integrated terminal issues label Nov 25, 2017
@Tyriar
Copy link
Member

Tyriar commented Dec 11, 2017

The reason the terminal is automatically created is because the panel gets restored, which triggers the terminal being created.

@isidorn ever considered the ability to never restore a panel? This request has come before from the Powershell team.

@Tyriar Tyriar added the info-needed Issue requires more information from poster label Dec 11, 2017
@isidorn
Copy link
Contributor

isidorn commented Dec 12, 2017

@Tyriar no. We always restore all our ux as it was in a previous session.
I do not see why the panel is a sepcial case when compared to the sidebar, activity bar, editor state and so on.

@fabiospampinato
Copy link
Contributor Author

We always restore all our ux as it was in a previous session.

I don't think so.

You don't restore: the activity bar (global, non session-specific), status bar (global, non session specific), active activity bar section (it's always "explorer"), the "replace" input field always starts hidden (#30250) and probably other things as well.

I do not see why the panel is a sepcial case when compared to the sidebar, activity bar, editor state and so on.

The editor state and sidebar are useful, so it may be the activity bar for some people, but what use does it have a "debug" panel automatically open at startup? Or an empty terminal that automatically opens because when 2 months ago I closed that window it had a terminal visible?

@Tyriar
Copy link
Member

Tyriar commented Dec 12, 2017

@isidorn the special case is to avoid creating terminal sessions when the terminal panel is restored as some extensions want to prevent the initial terminal being created.

Allowing an empty terminal is another way to workaround the same issue, it's a pretty big change in thinking though.

@vscodebot vscodebot bot closed this as completed Dec 19, 2017
@vscodebot
Copy link

vscodebot bot commented Dec 19, 2017

This issue has been closed automatically because it needs more information and has not had recent activity. See also our issue reporting guidelines.

Happy Coding!

@fabiospampinato
Copy link
Contributor Author

@Tyriar could you reopen this please? What kind of "more info" is needed?

@Tyriar Tyriar added under-discussion Issue is under discussion for relevance, priority, approach and removed info-needed Issue requires more information from poster labels Dec 27, 2017
@Tyriar Tyriar reopened this Dec 27, 2017
@fabiospampinato
Copy link
Contributor Author

I've tried to fix this in an extension, it didn't work. This is what I've tried:

  • Running vscode.commands.executeCommand ( 'workbench.action.terminal.kill' ); inside the activate function.
    • There's no way of knowing if there's actually a terminal open (Allow extensions to access all terminals via API #13267).
    • Maybe there's another extension that opens a terminal at startup, we shouldn't just kill it.
    • There's a noticeable delay between the restored terminal opening and then closing. Maybe I could uninstall all my other extensions, or maybe I could rename my extension to "000", or something, ensuring that it's activate function will be called as soon as possible, but this is not really a solution.
  • Killing all terminals upon shutdown, so that none will be restored the next time that window gets opened
    • It would actually produce the desired effect only after the second opening of that window, unless that's a completely new window.
    • I couldn't find a way to hook into the "shutdown" event, there's the deactivate function, but I believe that gets triggered after the actual window is closed, so there's no terminal to kill anymore. Even if there was a way of doing this there's no way of knowing how many terminals are open, if any (Allow extensions to access all terminals via API #13267).
  • Injecting custom JS with this ensuring that the workbench.action.terminal.kill gets executed as soon as possible
    • I couldn't find a way to do it, is VSC actually exporting something to the global namespace that I can use to execute commands?

This is a bit annoying to me, and I couldn't find a way of fixing it without patching VSC itself.

Is there any update on this? Maybe an option for this could be added as part of #44302?

@fabiospampinato
Copy link
Contributor Author

fabiospampinato commented Aug 19, 2018

If anybody else finds those restored terminals annoying, this is what I'm currently doing for killing them:

  1. Use Custom CSS and JS Loader, needed for injecting some code into VSC.
  2. Use Fix VSCode Checksum to remove the [Unsupported] thing from the titlebar.
  3. Add the following to your settings:
  "vscode_custom_css.imports": [
    "file:///path/to/my/vsc_custom.js"
  ]
  1. Add the following code to your /path/to/my/vsc_custom.js file:
/* CLOSE RESTORED PANEL */

(function () {

  function hasEvent ( event ) {

    return _performanceEntries.includes ( event );

  }

  function close () {

    const kill = document.querySelector ( '.terminal-action.kill' );

    if ( kill ) kill.click ();

    const hide = document.querySelector ( '.panel .hide-panel-action' );

    if ( hide ) hide.click ();

    return !!kill || !!hide;

  }

  function loop () {

    if ( hasEvent ( 'extensionHostReady' ) || close () ) return;

    requestAnimationFrame ( loop );

  }

  loop ();

})();

@Tyriar
Copy link
Member

Tyriar commented Aug 20, 2018

Use Custom CSS and JS Loader, needed for injecting some code into VSC.
Use Fix VSCode Checksum to remove the [Unsupported] thing from the titlebar.

This is bad, the whole point of the unsupported message is to make it obvious that the source has been modified so the team doesn't have to chase down issues that are caused by people manipulating VS Code's source code - several team members wasted a bunch of time in the past on such problems.

const button = document.querySelector ( '.terminal-action.kill' );
if ( button ) button.click ();

In 1.26 you have a window.terminals ext API (and window.onDidOpenTerminal) which you can query at any time and kill all of them after launch.

@fabiospampinato
Copy link
Contributor Author

fabiospampinato commented Aug 20, 2018

This is bad, the whole point of the unsupported message is to make it obvious that the source has been modified so the team doesn't have to chase down issues that are caused by people manipulating VS Code's source code - several team members wasted a bunch of time in the past on such problems.

I understand that, but it's also very annoying to me to read that [Unsupported] message every single time, if I can remove it I'll do it. Maybe a -patched suffix could be added to the version displayed in the About window instead, maybe this way it will also be more useful because when people get asked which version they are running they'll say 1.26.1-patched instead of just forgetting to mention that they are running a patched version.

In 1.26 you have a window.terminals ext API (and window.onDidOpenTerminal) which you can query at any time and kill all of them after launch.

window.onDidOpenTerminal is not triggered for the restored terminal, or I guess maybe my extension isn't active yet when that happens.

I can't fix it with an extension because:

  • I don't think there's a way of knowing if the open terminal has been uselessly restored or maybe opened manually or by another extension, in the latter cases it shouldn't be killed.
  • It takes a while before my extension gets activated and can actually kill the terminal.

That piece of code I posted kills the terminal almost instantaneously and only if it's a restored terminal.

Of course I would rather just set an option in my settings for disabling panel/terminal restoration, but said option doesn't seem like is going to get implemented.

@Tyriar
Copy link
Member

Tyriar commented Aug 21, 2018

@fabiospampinato created #56929 to address the annoying part of it

@Tyriar
Copy link
Member

Tyriar commented Sep 7, 2018

Let's do a setting to prevent this which your users could enable (your extension could have a notification that helps users). The setting terminal.restoreOnStartUp (is there a better name for this?) would prevent terminals being created via TerminalPanel.setVisible during launch. I believe this is the code in question:

https://github.com/Microsoft/vscode/blob/5a2d01053c38593cd9061f42b12d25a36c5ff475/src/vs/workbench/parts/terminal/electron-browser/terminalPanel.ts#L118-L121

@Tyriar Tyriar added help wanted Issues identified as good community contribution opportunities feature-request Request for new features or functionality and removed under-discussion Issue is under discussion for relevance, priority, approach labels Sep 7, 2018
@fabiospampinato
Copy link
Contributor Author

Thanks for wanting to fix this. I have a couple of questions:

  • Since the thing being restored is actually the panel itself, shouldn't the setting disable that instead?
  • Shouldn't this setting be enabled by default? It's difficult for me to imagine someone wanting to have the panel open at startup, unpredictably (who remembers if last time it was open or not).

Regarding the name I see there are already settings like: window.restoreFullscreen and zenMode.restore so maybe one of these would be good:

  • workbench.restorePanel
  • workbench.panel.restore
  • terminal.restore

terminal.restoreOnStartUp is more explicit but at the expense of verbosity 🤔

@Tyriar
Copy link
Member

Tyriar commented Sep 10, 2018

Since the thing being restored is actually the panel itself, shouldn't the setting disable that instead?

@isidorn doesn't want that to be a thing for the panel. Plus it makes more sense for this to be a terminal setting as we only want the terminal not to restore, output, problems, etc. should still be restored at normal.

Shouldn't this setting be enabled by default? It's difficult for me to imagine someone wanting to have the panel open at startup, unpredictably (who remembers if last time it was open or not).

The workbench has always restored the state it was previously in, if you had a terminal open it will be open with a new shell to jump into, it's easy to hide/kill.

terminal.restoreOnStartUp is more explicit but at the expense of verbosity

I think being explicit is better here, terminal.restore is too ambiguous and is very similar for example to the setting that was just removed to restore the processes.

@fabiospampinato
Copy link
Contributor Author

we only want the terminal not to restore

The "Debug Console" open at startup is totally useless too, even more so than the terminal.

terminal.restoreOnStartUp should not restore the panel if the active section is "Terminal", right? Or do you want the panel restored without creating a terminal in it?

@Tyriar
Copy link
Member

Tyriar commented Sep 10, 2018

@fabiospampinato the behavior I'm thinking is that a set visible on startup would not create a process and instead hide the panel immediately, allowing extensions to show it again when they activate.

@fabiospampinato
Copy link
Contributor Author

fabiospampinato commented Sep 10, 2018

@Tyriar I'm concerned this could cause the panel to get rendered very briefly, effectively flashing it on the screen, which is what I'm seeing with my code 🤔

@SilentFlute
Copy link

@codestothestars how do i use this "tasks" config, put it in settings.json?

@Tyriar
Copy link
Member

Tyriar commented Jun 28, 2023

@SilentFlute
Copy link

@zm-cttae
Copy link

It's been a while since our last work and the issue's been bumped already..
So when is the team's next availability to get this one On Deck?
VSC wreaks havoc when I want to use Netflix or play a videogame 😅

@Tyriar
Copy link
Member

Tyriar commented Jul 20, 2023

VSC wreaks havoc when I want to use Netflix or play a videogame 😅

@zm-cttae what do you mean by this? I wouldn't have expected this to cause performance problems.

@zm-cttae
Copy link

It's something to do with PowerShell being open that messes with other games and anything running off GPU 0 (3D)

@zm-cttae
Copy link

AFAIK the terminal does use GPU rendering also

@Tyriar
Copy link
Member

Tyriar commented Jul 20, 2023

@zm-cttae that's surprising, are you using a low spec GPU?

You can disable GPU rendering by setting "terminal.integrated.gpuAcceleration": "off", your terminals will be noticeably slower but I'd prioritize gaming performance in this case 😉

@ORBAT
Copy link

ORBAT commented Jul 25, 2023

Is there any workaround for this yet? It's irritating to have the terminal always pop open on restart if I happen to close my editor when I had a Julia REPL still running.

I'd be OK with a solution that closes all terminals when I quit VSCode.

@Tyriar
Copy link
Member

Tyriar commented Jul 29, 2023

I thought about it and went with hideOnStartup in #189204. The word "restore" might confuse the user with persistent sessions but the main reason for this was that the panel still gets "restored" by the view system, it just hides almost immediately after and doesn't create a terminal.

Early feedback on the setting would be awesome. Here's the definition:

[TerminalSettingId.HideOnStartup]: {
	description: localize('terminal.integrated.hideOnStartup', "Whether to hide the terminal view on startup, avoiding creating a terminal when there are no persistent sessions."),
	type: 'string',
	enum: ['never', 'whenEmpty', 'always'],
	markdownEnumDescriptions: [
		localize('hideOnStartup.never', "Never hide the terminal view on startup."),
		localize('hideOnStartup.whenEmpty', "Only hide the terminal when there are no persistent sessions restored."),
		localize('hideOnStartup.always', "Always hide the terminal, even when there are persistent sessions restored.")
	],
	default: 'never'
},

@Tyriar Tyriar modified the milestones: Backlog, August 2023 Jul 29, 2023
@Tyriar Tyriar added terminal-persistence Relating to process reconnection or process revive and removed under-discussion Issue is under discussion for relevance, priority, approach labels Jul 29, 2023
@vscodenpa vscodenpa added unreleased Patch has not yet been released in VS Code Insiders insiders-released Patch has been released in VS Code Insiders and removed unreleased Patch has not yet been released in VS Code Insiders labels Jul 29, 2023
@meganrogge meganrogge removed their assignment Aug 25, 2023
@Tyriar Tyriar added the verification-needed Verification of issue is requested label Aug 28, 2023
@meganrogge meganrogge added the verified Verification succeeded label Aug 29, 2023
Tyriar added a commit to microsoft/vscode-docs that referenced this issue Sep 6, 2023
gregvanl pushed a commit to microsoft/vscode-docs that referenced this issue Sep 6, 2023
gregvanl pushed a commit to microsoft/vscode-docs that referenced this issue Sep 7, 2023
* Add 1.82 release notes placeholder

* Documentation for JSON Schema support needs updating

* adding documentation for the work done this iteration

* Update 1.82 vscode.d.ts commit ID

* Update 1.82 Windows keybindings

* news - api, batch range formatting

* Update 1.82 vscode.d.ts commit ID for latest comments

* Add release notes sections

* Update terminal image support enablement

* Update 1.82 settings

* Update 1.82 macOS keybindings

* Update 1.82 Linux keybindings

* add port forwarding doc (#6627)

* add port forwarding doc

* apply suggestions

* Add release notes for python terminal experiment

* Fix

* add accessibility updates

* add ty

* Update v1_82.md

* add copy output mp4

* Release notes

* Update default setting value

* quick search notes

* Dev Containers notes

* PRs

* Issue trackers

* Mention Settings editor remote search

* Merge in husky hooks

* polish

* Update v1_82.md

* small edits and formatting

* update notes

* Compress image

* Update v1_82.md

* my stuff so far

* related info

* updating the documentation concerning the setting for json sorting

* resetting back the documentation

* my input

* input

* input

* Edits to recent updates

* More edits

* Adding items

* Release notes

* Stub my sections

* Update changelog

* Improves diff editor changelog.

* diff editor changelog improvements

* Put Setings editor in own section

* Stub terminal selection

* Autoplay videos

* added video for sticky scroll improvements

* Add prebuild guide info

* Update v1_82.md

* Terminal notes progress

* More terminal notes

* add terminal focus section

* Remove unfilled release notes sections

* Add 1.82 highlights

* small edits

* move

* Add Electron 25 update section

* Terminal progress

* Copilot explain terminal selection

* Dim unfocused

* New APIs

* Terminal API proposals

* Add remote highlights, small edits

* Add 1.82 social image

* Document hideOnStartup setting (#6647)

Part of microsoft/vscode#39137

* Bracketed paste mode update

* Document terminal.integrated.cursorStyleInactive

* full edit pass

* Shrink  .gifs, tune highlights length and links

* Update Date metadata, link to video Marketplace theme

* Fix italics

* move to https://github.com/microsoft/vscode-internalbacklog/blob/main/internal-release-notes/engineering-release-notes/v1_82.md

* DateApproved

---------

Co-authored-by: Martin Aeschlimann <martinae@microsoft.com>
Co-authored-by: Aiday Marlen Kyzy <aidaymarlenkyzy@gmail.com>
Co-authored-by: Johannes <johannes.rieken@gmail.com>
Co-authored-by: Daniel Imms <2193314+Tyriar@users.noreply.github.com>
Co-authored-by: Connor Peet <connor@peet.io>
Co-authored-by: Kartik Raj <karraj@microsoft.com>
Co-authored-by: meganrogge <megan.rogge@microsoft.com>
Co-authored-by: Aaron Munger <aamunger@microsoft.com>
Co-authored-by: Aaron Munger <aaron.munger@gmail.com>
Co-authored-by: Joyce Er <joyceerhl@gmail.com>
Co-authored-by: andreamah <andrea_mah22@hotmail.com>
Co-authored-by: Christof Marti <chrmarti@microsoft.com>
Co-authored-by: Raymond Zhao <7199958+rzhao271@users.noreply.github.com>
Co-authored-by: Courtney Webster <60238438+cwebster-99@users.noreply.github.com>
Co-authored-by: Justin Chen <54879025+justschen@users.noreply.github.com>
Co-authored-by: Tyler James Leonhardt <me@tylerleonhardt.com>
Co-authored-by: Benjamin Pasero <benjamin.pasero@microsoft.com>
Co-authored-by: Matt Bierner <matb@microsoft.com>
Co-authored-by: Henning Dieterichs <hdieterichs@microsoft.com>
Co-authored-by: Aiday Marlen Kyzy <amarlenkyzy@microsoft.com>
Co-authored-by: Brigit Murtaugh <brigit.murtaugh@microsoft.com>
Co-authored-by: Robo <hop2deep@gmail.com>
@github-actions github-actions bot locked and limited conversation to collaborators Sep 12, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature-request Request for new features or functionality insiders-released Patch has been released in VS Code Insiders terminal-persistence Relating to process reconnection or process revive terminal-process Problems launching processes, managing ptys, exiting, process leaks, etc. verification-needed Verification of issue is requested verified Verification succeeded
Projects
None yet
Development

Successfully merging a pull request may close this issue.