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

Terminal shell integration proposed api #208257

Merged
merged 22 commits into from Mar 21, 2024
Merged

Terminal shell integration proposed api #208257

merged 22 commits into from Mar 21, 2024

Conversation

Tyriar
Copy link
Member

@Tyriar Tyriar commented Mar 20, 2024

Part of #145234


This is the initial implementation of the new Terminal.shellIntegration and related proposed APIs. There are a few TODOs still in the code but these will get resolved before finalization.

@karrtikr these still aren't set in stone but it is probably worth trying to implement something against it for feedback once merged.

@Tyriar Tyriar added this to the March 2024 milestone Mar 20, 2024
@Tyriar Tyriar self-assigned this Mar 20, 2024
@Tyriar Tyriar marked this pull request as ready for review March 21, 2024 18:04
Copy link
Contributor

@karrtikr karrtikr left a comment

Choose a reason for hiding this comment

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

@Tyriar Tyriar merged commit 733b8aa into main Mar 21, 2024
6 checks passed
@Tyriar Tyriar deleted the tyriar/145234 branch March 21, 2024 19:41
Copy link
Contributor

@karrtikr karrtikr left a comment

Choose a reason for hiding this comment

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

TPI doc review

Comment on lines +62 to +70
export interface Terminal {
/**
* An object that contains [shell integration](https://code.visualstudio.com/docs/terminal/shell-integration)-powered
* features for the terminal. This will always be undefined immediately after the terminal
* is created. Listen to {@link window.onDidActivateTerminalShellIntegration} to be notified
* when shell integration is activated for a terminal.
*/
shellIntegration: TerminalShellIntegration | undefined;
}
Copy link
Contributor

@karrtikr karrtikr Mar 25, 2024

Choose a reason for hiding this comment

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

Should probably include a note that shell integration may never activate for a terminal. For eg. One common case is command prompt

* The current working directory of the terminal. This will be a {@link Uri} if the string
* reported by the shell can reliably be mapped to the connected machine.
*/
cwd: Uri | string | undefined;
Copy link
Contributor

Choose a reason for hiding this comment

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

Should probably be readonly

Comment on lines +176 to +185
export interface TerminalShellIntegrationChangeEvent {
/**
* The terminal that shell integration has been activated in.
*/
terminal: Terminal;
/**
* The shell integration object.
*/
shellIntegration: TerminalShellIntegration;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here

Comment on lines +15 to +43
terminal: Terminal;

/**
* The full command line that was executed, including both the command and arguments.
* The accuracy of this value depends on the shell integration implementation:
*
* - It may be undefined or the empty string until {@link onDidEndTerminalShellExecution} is
* fired.
* - It may be inaccurate initially if the command line is pulled from the buffer directly
* via the [`OSC 633/133 ; A`, `B` and `C` sequences](https://code.visualstudio.com/docs/terminal/shell-integration#_vs-code-custom-sequences-osc-633-st).
* - It may contain line continuation characters and/or parts of the right prompt.
* - It may be inaccurate if the shell integration does not support command line reporting
* via the [`OSC 633 ; E` sequence](https://code.visualstudio.com/docs/terminal/shell-integration#_vs-code-custom-sequences-osc-633-st).
*/
commandLine: string | undefined;

/**
* The working directory that was reported by the shell when this command executed. This
* will be a {@link Uri} if the string reported by the shell can reliably be mapped to the
* connected machine. This requires the shell integration to support working directory
* reporting via the [`OSC 633 ; P`](https://code.visualstudio.com/docs/terminal/shell-integration#_vs-code-custom-sequences-osc-633-st)
* or `OSC 1337 ; CurrentDir=<Cwd> ST` sequences.
*/
cwd: Uri | string | undefined;

/**
* The exit code reported by the shell.
*/
exitCode: Thenable<number | undefined>;
Copy link
Contributor

Choose a reason for hiding this comment

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

And here

Tyriar added a commit that referenced this pull request Mar 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants