Skip to content

Allow extensions to access all terminals via API #13267

Closed

Description

@Tyriar

To give extensions more control over the terminal panel I'm proposing the following:

export namespace window {
  export const onDidOpenTerminal: Event<Terminal>;
  export let terminals: Terminal[];
}

A solid use case for this is to represent the terminals as tabs somewhere in the UI https://github.com/Tyriar/vscode-terminal-tabs

Activity

  1. added
    feature-request
    terminal
    on Oct 5, 2016
  2. Tyriar commented on Oct 5, 2016

    @Tyriar
    ContributorAuthor

    What do you think Johannes Rieken (@jrieken)?

  3. jrieken commented on Oct 6, 2016

    @jrieken
    Contributor

    Not yet sold on the importance and future-proof of that API. I would suggest to hold back with this API until the discussion about moving terminals into the editor space comes to an result (we recently talked about that in a UX sync). Then we might have a different set of requirements and limitations.

  4. Tyriar commented on Oct 6, 2016

    @Tyriar
    ContributorAuthor

    I was at one of those meetings that talked about that and it was shot down pretty hard, it would make management of terminals much more difficult and blur the lines between a panel and an editor. Would that really change the requirements though, this is just adding an open event and a list of terminals which would still be valid regardless of where a terminal was?

  5. jrieken commented on Oct 7, 2016

    @jrieken
    Contributor

    I am pretty sure the discussion will come again once we introduce horizontal editors. Not saying we merge panels and editors (errors, output, debug should stay there), but I have the (strong) feeling that terminal a much more like editors (I create/dispose them, I manage them) and for editors we have the far superior story for managing/navigating them. Like html-preview and extension-editors, terminal would greatly benefit from that IMO.

    Taking about the API: It might not look any different but I just want to be careful and not rush into something we cannot change again. I don't see strong feature pressure for this so I would wait for the bigger workbench UX changes to land first.

  6. Tyriar commented on Nov 16, 2016

    @Tyriar
    ContributorAuthor

    This may be necessary to scan the output of a gulp watch (or similar) command on any terminal and using co-processes (#13337) to send errors to the problems panel. /cc Dirk Bäumer (@dbaeumer)

  7. jrieken commented on Nov 17, 2016

    @jrieken
    Contributor

    Wouldn't activeTerminal and onDidChangeActiveTerminal APIs be better for spying on them?

  8. Tyriar commented on Nov 17, 2016

    @Tyriar
    ContributorAuthor

    Johannes Rieken (@jrieken) for the problems use case you would want to watch the output of terminals in the background. When working on VS Code for example I have 2 terminals; gulp watch (typically background) and ./scripts/*.sh (foreground).

    Dirk Bäumer (@dbaeumer) is this right? You would want to watch any terminal, not just ones that were launched via an extension?

  9. dbaeumer commented on Nov 18, 2016

    @dbaeumer
    Member

    I would like to watch the output of potential all terminals. However for the input I only need the active one. The user can only type in one terminal anyways.

  10. rkeithhill commented on Mar 23, 2017

    @rkeithhill

    Johannes Rieken (@jrieken) For an example of how the current behavior is sub-optimal see PowerShell/vscode-powershell#604

    We would love to see something like this for the PowerShell extension if it allowed us to bypass that initial, useless terminal startup. We now have an "integrated console" that effectively replaces the Debug Console at debug time and provides a REPL experience at edit time. That is, our integrated console allows the user to play around in the same PowerShell process that hosts both the language and debug services. This gives a nice SmallTalk-like REPL experience that spans edit & debug.

    The only way to plumb this in was to add another terminal type - PowerShell Integrated Console. Unfortunately when VSCode first starts, it loads up the default terminal first before we get a chance to start our integrated console.
    cc David Wilson (@daviwil)

  11. daviwil commented on Apr 21, 2017

    @daviwil
    Contributor

    Any chance we could see what shell exe the terminal launched? I know it's a bit of a grey area, but might be nice for determining whether I should kill one of the terminals in favor of the PowerShell Integrated Console.

  12. Tyriar commented on Apr 24, 2017

    @Tyriar
    ContributorAuthor

    David Wilson (@daviwil) the usage of it would probably be pretty limited, if you're just tracking the initial panel restore you could probably get around it some other way. I'm extra hesitant to add since it could be misleading, say if someone opens cmd inside powershell.

  13. daviwil commented on Apr 24, 2017

    @daviwil
    Contributor

    Sounds good, I definitely understand not wanting to add something of limited value!

  14. cvgaviao commented on Dec 15, 2017

    @cvgaviao

    Hi, I'm facing a situation where I 'll need to create one terminal for every root folder (selected project) because the commands I'm registering need to run in its own root folder terminal. But I would like to create the terminal only once, but don't know how to retrieve an already created one.
    any tip?

  15. handletastic commented on Feb 27, 2018

    @handletastic

    Has there been any updates as off 2018?

  16. Tyriar commented on Feb 27, 2018

    @Tyriar
    ContributorAuthor

    @hdsantos89 nothing other than more interest in getting at the PID of all terminals in #42521

  17. Tyriar commented on Mar 9, 2018

    @Tyriar
    ContributorAuthor

    To give a summary of the needs for this API:

    Let me know if I missed anything

  18. fabiospampinato commented on Mar 9, 2018

    @fabiospampinato
    Contributor

    their kill command currently runs workbench.action.terminal.kill 25 times

    Exactly, other than being pretty ugly and most of the times inefficient there are no guarantees this will even work (maybe the user has 26+ terminals open for some reason).

    A few more things that could be done with access to all terminals:

    • Merge all terminals in a single pane, or move each terminal to its own pane, taking advantage of the new split terminals feature.
    • Terminals could auto-create a basic configuration based on your active terminals.

    The proposed APIs look as future proof as they can possibly be to me.

  19. Tyriar commented on Apr 5, 2018

    @Tyriar
    ContributorAuthor

    This is needed for #46192

  20. Tyriar commented on Apr 12, 2018

    @Tyriar
    ContributorAuthor

    This is landing in tomorrow's insiders as a proposed API:

    export namespace window {
    	/**
    	 * The currently active terminals or an empty array.
    	 *
    	 * @readonly
    	 */
    	export let terminals: Terminal[];
    
    	/**
    	 * An [event](#Event) which fires when a terminal has been created, either through the
    	 * [createTerminal](#window.createTerminal) API or commands.
    	 */
    	export const onDidOpenTerminal: Event<Terminal>;
    }
  21. locked and limited conversation to collaborators on May 27, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

apifeature-requeston-testplanterminal

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions