Skip to content

Promote terminal renderer API to stable #58660

Closed

Description

@iann0036

Relates to #46192

Terminal Providers have been in proposed since April and seem to be working fine. I don't see any open issues relating to them and was wondering what needs to occur to get this planned into a stable release?

Activity

  1. added
    terminal
    on Sep 14, 2018
  2. Tyriar commented on Sep 14, 2018

    @Tyriar
    Contributor

    Ian Mckay (@iann0036) I'm mainly waiting for feedback as to my knowledge only Live Share has experimented with them. If you're interested on using the terminal renderer API I'd love to hear more details.

  3. added
    info-needed
    on Sep 14, 2018
  4. iann0036 commented on Sep 15, 2018

    @iann0036
    ContributorAuthor

    Hey Daniel Imms (@Tyriar),

    I'm interested in using the terminal renderer for almost the exact same reason as the Live Share team with my extension which transmits/receives terminal data over WebSockets.

    Currently, as a workaround, I have a Go app bundled with my extension which I communicate with over IPC for Mac and Linux. Windows is a little more difficult due to the lack of ANSI.

  5. changed the title [-]Promote Terminal Providers[/-] [+]Promote Terminal Providers to stable[/+] on Sep 17, 2018
  6. added
    feature-request
    and removed
    info-needed
    on Sep 17, 2018
  7. changed the title [-]Promote Terminal Providers to stable[/-] [+]Promote terminal renderer API to stable[/+] on Oct 11, 2018
  8. removed this from the Backlog milestone on Jan 9, 2019
  9. 4 remaining items

  10. GabeDeBacker commented on Jan 24, 2019

    @GabeDeBacker
    Contributor

    First, let me comment on the interface above. All the event arguments would need to change to pass the terminal renderer as an argument.

    namespace window {
    	const onDidAcceptTerminalRendererInput: Event<{renderer: TerminalRenderer, input: string}>;
    	const onDidChangeTerminalRendererMaximumDimensions: Event<{renderer: TerminalRenderer, dimensions: TerminalDimensions}>;
    	const OnDidWriteTerminalData: Event<{renderer: TerminalRenderer, data: string}>;
    	const OnDidChangeTerminalDimensions: Event<{renderer: TerminalRenderer, data: string}>;
    }

    Second, I don't agree with making the terminal events global. I don't believe it makes sense for every consumer to have to do this in there code.

    class MyClass {
    private myTerminalRenderer: TerminalRenderer;
    
    void onDidWriteTerminalDataHandler(eventArgs: {renderer: TerminalRenderer, data: string}) : void {
       if (eventArgs.renderer == myTerminalRenderer) {
          this.doSomething();
       }
    }

    Doesn't seem efficient to broadcast events to multiple subscribers especially when it comes to keystrokes and multple terminals.

    I've honestly never seen an approcah like this for events that are specific to an object.

    If a subscriber wants to listen to all terminals, then they can already handle

    		export const onDidOpenTerminal: Event<Terminal>;
    		export const onDidCloseTerminal: Event<Terminal>;

    And subscribe to them independently.

    As a final point, things like TreeView in the VSCode namespace (as an example) do indeed have events that are not global (which in my opinion is how they should be).

    	export interface TreeView<T> extends Disposable {
    
    		/**
    		 * Event that is fired when an element is expanded
    		 */
    		readonly onDidExpandElement: Event<TreeViewExpansionEvent<T>>;
    
    		/**
    		 * Event that is fired when an element is collapsed
    		 */
    		readonly onDidCollapseElement: Event<TreeViewExpansionEvent<T>>;
  11. Tyriar commented on Jan 24, 2019

    @Tyriar
    Contributor

    This is because of https://github.com/Microsoft/vscode/wiki/Extension-API-guidelines#global-events

    Thoughts Johannes Rieken (@jrieken)? I think we might have gone the original way because the most typical case is that most extensions will want to control only the terminal(s) they have launched. It's not clear to me when this rule should not be followed.

  12. jrieken commented on Jan 24, 2019

    @jrieken
    Contributor

    I think we might have gone the original way because the most typical case is that most extensions will want to control only the terminal(s) they have launched. It's not clear to me when this rule should not be followed.

    I don't see a strong reason to not follow this rule. The pattern is well established and makes event easy, esp with global things like terminal that can also be created via user-gestures. What is the strong argument here to break consistency?

  13. GabeDeBacker commented on Jan 25, 2019

    @GabeDeBacker
    Contributor

    There are a couple of reasons here to augment the rule.

    First is simply performance. The more extensions you have that have to subscribe to global events and handle events they don't necessarily care about, the slower VSCode becomes. I really admire VSCode's desire for speed and am really impressed by it. So the architecture and API design should be done in a way that helps enforce that.

    Second is the API surface itself. If all events were to be global, then the number of APIs in a given namespace grows significantly over time. The API surface would end up with a very large namespace with hundreds of APIs and events that would be hard to logically understand.

    Some languages, C# as an example, do not allow you to place events in a namespace thereby forcing an architecture where the events are on classes.

    There is also an option of having the events at a global scope as well as on an object scope. That would alleviate my performance concerns above.

    Final point, if there really is a need for a global event, then perhaps creating logical namespace separations for them in the API surface will with my "large surface area" concern. The "window" namespace is already quite large today.

    As an example of today. Instead of this:

    export namespace window {
    	export function createTerminal(name?: string, shellPath?: string, shellArgs?: string[]): Terminal;
    	export function createTerminal(options: TerminalOptions): Terminal;
    	export const onDidOpenTerminal: Event<Terminal>;
    	export const onDidCloseTerminal: Event<Terminal>;

    A much more self discovering mechanism would be:

    export namespace terminals {
    	export function createTerminal(name?: string, shellPath?: string, shellArgs?: string[]): Terminal;
    	export function createTerminal(options: TerminalOptions): Terminal;
    	export const onDidOpenTerminal: Event<Terminal>;
    	export const onDidCloseTerminal: Event<Terminal>;
  14. Tyriar commented on Jan 30, 2019

    @Tyriar
    Contributor

    To clarify the rule, global events only apply to objects that are globally accessible. Terminals are globally accessible but TerminalRenderers are not. So TerminalRenderer events can be private.

    namespace window {
    	export const OnDidWriteTerminalData: Event<TerminalDataWriteEvent>;
    	export const OnDidChangeTerminalDimensions: Event<TerminalDimensionsChangeEvent>;
    
    	export interface TerminalDataWriteEvent {
    		terminal: Terminal;
    		data: string;
    	}
    
    	export interface TerminalDimensionsChangeEvent {
    		terminal: Terminal;
    		dimensions: TerminalDimensions;
    	}
    }
  15. added a commit that references this issue on Feb 5, 2019
    20e7b8b
  16. Tyriar commented on Mar 22, 2019

    @Tyriar
    Contributor

    Closing in favor of #70978

  17. removed this from the March 2019 milestone on Mar 22, 2019
  18. removed
    feature-request
    on Mar 22, 2019
  19. locked and limited conversation to collaborators on May 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

apiapi-proposalterminal

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions