repl: Replace REPL panel with sessions view (#14981)

This PR removes the REPL panel and replaces it with a new sessions view
that gets displayed in its own pane.

The sessions view can be opened with the `repl: sessions` command (we
can adjust the name, as needed).

There was a rather in-depth refactoring needed to extricate the various
REPL functionality on the editor from the `RuntimePanel`.

<img width="1136" alt="Screenshot 2024-07-22 at 4 12 12 PM"
src="https://github.com/user-attachments/assets/ac0da351-778e-4200-b08c-39f9e77d78bf">

<img width="1136" alt="Screenshot 2024-07-22 at 4 12 17 PM"
src="https://github.com/user-attachments/assets/6ca53476-6ac4-4f8b-afc8-f7863f7065c7">

Release Notes:

- N/A
This commit is contained in:
Marshall Bowers 2024-07-22 16:22:50 -04:00 committed by GitHub
parent 8f20ea1093
commit d8a42bbf63
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 474 additions and 637 deletions

View file

@ -5,21 +5,9 @@ use gpui::AppContext;
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
use settings::{Settings, SettingsSources};
use ui::Pixels;
#[derive(Copy, Clone, Default, Debug, Serialize, Deserialize, JsonSchema, PartialEq, Eq)]
#[serde(rename_all = "snake_case")]
pub enum JupyterDockPosition {
Left,
#[default]
Right,
Bottom,
}
#[derive(Debug, Default)]
pub struct JupyterSettings {
pub dock: JupyterDockPosition,
pub default_width: Pixels,
pub kernel_selections: HashMap<String, String>,
}
@ -34,31 +22,15 @@ impl JupyterSettings {
#[derive(Clone, Serialize, Deserialize, JsonSchema, Debug)]
pub struct JupyterSettingsContent {
/// Where to dock the Jupyter panel.
///
/// Default: `right`
dock: Option<JupyterDockPosition>,
/// Default width in pixels when the jupyter panel is docked to the left or right.
///
/// Default: 640
pub default_width: Option<f32>,
/// Default kernels to select for each language.
///
/// Default: `{}`
pub kernel_selections: Option<HashMap<String, String>>,
}
impl JupyterSettingsContent {
pub fn set_dock(&mut self, dock: JupyterDockPosition) {
self.dock = Some(dock);
}
}
impl Default for JupyterSettingsContent {
fn default() -> Self {
JupyterSettingsContent {
dock: Some(JupyterDockPosition::Right),
default_width: Some(640.0),
kernel_selections: Some(HashMap::new()),
}
}
@ -79,14 +51,6 @@ impl Settings for JupyterSettings {
let mut settings = JupyterSettings::default();
for value in sources.defaults_and_customizations() {
if let Some(dock) = value.dock {
settings.dock = dock;
}
if let Some(default_width) = value.default_width {
settings.default_width = Pixels::from(default_width);
}
if let Some(source) = &value.kernel_selections {
for (k, v) in source {
settings.kernel_selections.insert(k.clone(), v.clone());
@ -114,14 +78,6 @@ mod tests {
JupyterSettings::register(cx);
assert_eq!(JupyterSettings::enabled(cx), false);
assert_eq!(
JupyterSettings::get_global(cx).dock,
JupyterDockPosition::Right
);
assert_eq!(
JupyterSettings::get_global(cx).default_width,
Pixels::from(640.0)
);
// Setting a custom setting through user settings
SettingsStore::update_global(cx, |store, cx| {
@ -140,13 +96,5 @@ mod tests {
});
assert_eq!(JupyterSettings::enabled(cx), true);
assert_eq!(
JupyterSettings::get_global(cx).dock,
JupyterDockPosition::Left
);
assert_eq!(
JupyterSettings::get_global(cx).default_width,
Pixels::from(800.0)
);
}
}