Runtimes UI Starter (#13625)

Initial runtimes UI panel. The main draw here is that all message
subscription occurs with two background tasks that run for the life of
the kernel. Follow on to #12062

* [x] Disable previous cmd-enter behavior only if runtimes are enabled
in settings
* [x] Only show the runtimes panel if it is enabled via settings
* [x] Create clean UI for the current sessions

### Running Kernels UI

<img width="205" alt="image"
src="https://github.com/zed-industries/zed/assets/836375/814ae79b-0807-4e23-bc95-77ce64f9d732">

* [x] List running kernels
* [x] Implement shutdown
* [x] Delete connection file on `drop` of `RunningKernel`
* [x] Implement interrupt

#### Project-specific Kernel Settings

- [x] Modify JupyterSettings to include a `kernel_selections` field
(`HashMap<String, String>`).
- [x] Implement saving and loading of kernel selections to/from
`.zed/settings.json` (by default, rather than global settings?)

#### Kernel Selection Persistence

- [x] Save the selected kernel for each language when the user makes a
choice.
- [x] Load these selections when the RuntimePanel is initialized.

#### Use Selected Kernels

- [x] Modify kernel launch to use the selected kernel for the detected
language.
- [x] Fallback to default behavior if no selection is made.

### Empty states

- [x] Create helpful UI for when the user has 0 kernels they can launch
and/or 0 kernels running

<img width="694" alt="image"
src="https://github.com/zed-industries/zed/assets/836375/d6a75939-e4e4-40fb-80fe-014da041cc3c">

## Future work

### Kernel Discovery

- Improve the kernel discovery process to handle various installation
methods (system, virtualenv, poetry, etc.).
- Create a way to refresh the available kernels on demand

### Documentation:

- Update documentation to explain how users can configure kernels for
their projects.
- Provide examples of .zed/settings.json configurations for kernel
selection.

### Kernel Selection UI

- Implement a new section in the RuntimePanel to display available
kernels.
- Group on the language name from the kernel specification 
- Create a dropdown for each language group to select the default
kernel.


Release Notes:

- N/A

---------

Co-authored-by: Kirill <kirill@zed.dev>
This commit is contained in:
Kyle Kelley 2024-07-05 08:15:50 -07:00 committed by GitHub
parent 821aa0811d
commit c77ea47f43
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 1438 additions and 965 deletions

View file

@ -55,11 +55,11 @@ impl TerminalOutput {
pub fn render(&self, cx: &ViewContext<ExecutionView>) -> AnyElement {
let theme = cx.theme();
let buffer_font = ThemeSettings::get_global(cx).buffer_font.family.clone();
let mut text_runs = self.handler.text_runs.clone();
text_runs.push(self.handler.current_text_run.clone());
let runs = text_runs
let runs = self
.handler
.text_runs
.iter()
.chain(Some(&self.handler.current_text_run))
.map(|ansi_run| {
let color = terminal_view::terminal_element::convert_color(&ansi_run.fg, theme);
let background_color = Some(terminal_view::terminal_element::convert_color(
@ -88,16 +88,15 @@ impl TerminalOutput {
impl LineHeight for TerminalOutput {
fn num_lines(&self, _cx: &mut WindowContext) -> u8 {
// todo!(): Track this over time with our parser and just return it when needed
self.handler.buffer.lines().count() as u8
}
}
#[derive(Clone)]
struct AnsiTextRun {
pub len: usize,
pub fg: alacritty_terminal::vte::ansi::Color,
pub bg: alacritty_terminal::vte::ansi::Color,
len: usize,
fg: alacritty_terminal::vte::ansi::Color,
bg: alacritty_terminal::vte::ansi::Color,
}
impl AnsiTextRun {