
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>
44 lines
1.3 KiB
Rust
44 lines
1.3 KiB
Rust
use async_dispatcher::{set_dispatcher, Dispatcher, Runnable};
|
|
use gpui::{AppContext, PlatformDispatcher};
|
|
use settings::Settings as _;
|
|
use std::{sync::Arc, time::Duration};
|
|
|
|
mod jupyter_settings;
|
|
mod kernels;
|
|
mod outputs;
|
|
mod runtime_panel;
|
|
mod session;
|
|
mod stdio;
|
|
|
|
pub use jupyter_settings::JupyterSettings;
|
|
pub use runtime_panel::RuntimePanel;
|
|
|
|
fn zed_dispatcher(cx: &mut AppContext) -> impl Dispatcher {
|
|
struct ZedDispatcher {
|
|
dispatcher: Arc<dyn PlatformDispatcher>,
|
|
}
|
|
|
|
// PlatformDispatcher is _super_ close to the same interface we put in
|
|
// async-dispatcher, except for the task label in dispatch. Later we should
|
|
// just make that consistent so we have this dispatcher ready to go for
|
|
// other crates in Zed.
|
|
impl Dispatcher for ZedDispatcher {
|
|
fn dispatch(&self, runnable: Runnable) {
|
|
self.dispatcher.dispatch(runnable, None)
|
|
}
|
|
|
|
fn dispatch_after(&self, duration: Duration, runnable: Runnable) {
|
|
self.dispatcher.dispatch_after(duration, runnable);
|
|
}
|
|
}
|
|
|
|
ZedDispatcher {
|
|
dispatcher: cx.background_executor().dispatcher.clone(),
|
|
}
|
|
}
|
|
|
|
pub fn init(cx: &mut AppContext) {
|
|
set_dispatcher(zed_dispatcher(cx));
|
|
JupyterSettings::register(cx);
|
|
runtime_panel::init(cx)
|
|
}
|