From 0dc002d7532bc932b2daf21975bbbad7333d8ca1 Mon Sep 17 00:00:00 2001 From: raideno56 Date: Mon, 18 May 2026 22:10:12 +0200 Subject: [PATCH 1/3] feat: add the stop button --- crates/repl/src/notebook/cell.rs | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/crates/repl/src/notebook/cell.rs b/crates/repl/src/notebook/cell.rs index ac078b3338c1b3..6987664ea9098e 100644 --- a/crates/repl/src/notebook/cell.rs +++ b/crates/repl/src/notebook/cell.rs @@ -15,6 +15,7 @@ use settings::Settings as _; use theme_settings::ThemeSettings; use ui::{CommonAnimationExt, IconButtonShape, prelude::*}; use util::ResultExt; +use zed_actions::notebook::InterruptKernel; use crate::{ notebook::{CODE_BLOCK_INSET, GUTTER_WIDTH}, @@ -32,6 +33,7 @@ pub enum CellPosition { pub enum CellControlType { RunCell, RerunCell, + StopCell, ClearCell, CellOptions, CollapseCell, @@ -53,6 +55,7 @@ impl CellControlType { match self { CellControlType::RunCell => IconName::PlayFilled, CellControlType::RerunCell => IconName::ArrowCircle, + CellControlType::StopCell => IconName::Stop, CellControlType::ClearCell => IconName::ListX, CellControlType::CellOptions => IconName::Ellipsis, CellControlType::CollapseCell => IconName::ChevronDown, @@ -951,21 +954,30 @@ impl RenderableCell for CodeCell { } fn control(&self, _window: &mut Window, cx: &mut Context) -> Option { - let control_type = if self.has_outputs() { + let control_type = if self.is_executing { + CellControlType::StopCell + } else if self.has_outputs() { CellControlType::RerunCell } else { CellControlType::RunCell }; let cell_control = CellControl::new( - if self.has_outputs() { - "rerun-cell" - } else { - "run-cell" + match control_type { + CellControlType::StopCell => "stop-cell", + CellControlType::RerunCell => "rerun-cell", + CellControlType::RunCell => "run-cell", + _ => "run-cell", }, control_type, ) - .on_click(cx.listener(move |this, _, window, cx| this.run(window, cx))); + .on_click(cx.listener(move |this, _, window, cx| { + if this.is_executing { + window.dispatch_action(Box::new(InterruptKernel), cx); + } else { + this.run(window, cx); + } + })); Some(cell_control) } From 71ec6b7badd655d541ef98c70fae11f883eec0d4 Mon Sep 17 00:00:00 2001 From: Martin Ye Date: Thu, 11 Jun 2026 09:32:18 -0700 Subject: [PATCH 2/3] rewrite logic --- crates/repl/src/notebook/cell.rs | 38 ++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/crates/repl/src/notebook/cell.rs b/crates/repl/src/notebook/cell.rs index 6987664ea9098e..377b25c61346aa 100644 --- a/crates/repl/src/notebook/cell.rs +++ b/crates/repl/src/notebook/cell.rs @@ -62,6 +62,17 @@ impl CellControlType { CellControlType::ExpandCell => IconName::ChevronRight, } } + fn id(&self) -> &'static str { + match self { + CellControlType::RunCell => "CellControlType::RunCell", + CellControlType::RerunCell => "CellControlType::RerunCell", + CellControlType::StopCell => "CellControlType::StopCell", + CellControlType::ClearCell => "CellControlType::ClearCell", + CellControlType::CellOptions => "CellControlType::CellOptions", + CellControlType::CollapseCell => "CellControlType::CollapseCelln", + CellControlType::ExpandCell => "CellControlType::ExpandCell", + } + } } pub struct CellControl { @@ -962,24 +973,17 @@ impl RenderableCell for CodeCell { CellControlType::RunCell }; - let cell_control = CellControl::new( - match control_type { - CellControlType::StopCell => "stop-cell", - CellControlType::RerunCell => "rerun-cell", - CellControlType::RunCell => "run-cell", - _ => "run-cell", - }, - control_type, + Some( + CellControl::new(control_type.id(), control_type).on_click(cx.listener( + move |this, _, window, cx| { + if this.is_executing { + window.dispatch_action(Box::new(InterruptKernel), cx); + } else { + this.run(window, cx); + } + }, + )), ) - .on_click(cx.listener(move |this, _, window, cx| { - if this.is_executing { - window.dispatch_action(Box::new(InterruptKernel), cx); - } else { - this.run(window, cx); - } - })); - - Some(cell_control) } fn selected(&self) -> bool { From fb0dc34c61da94969956d77a930b100de8ba30c9 Mon Sep 17 00:00:00 2001 From: Martin Ye Date: Thu, 11 Jun 2026 09:32:18 -0700 Subject: [PATCH 3/3] rewrite logic Co-authored-by: Yara --- crates/repl/src/notebook/cell.rs | 38 ++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/crates/repl/src/notebook/cell.rs b/crates/repl/src/notebook/cell.rs index 6987664ea9098e..377b25c61346aa 100644 --- a/crates/repl/src/notebook/cell.rs +++ b/crates/repl/src/notebook/cell.rs @@ -62,6 +62,17 @@ impl CellControlType { CellControlType::ExpandCell => IconName::ChevronRight, } } + fn id(&self) -> &'static str { + match self { + CellControlType::RunCell => "CellControlType::RunCell", + CellControlType::RerunCell => "CellControlType::RerunCell", + CellControlType::StopCell => "CellControlType::StopCell", + CellControlType::ClearCell => "CellControlType::ClearCell", + CellControlType::CellOptions => "CellControlType::CellOptions", + CellControlType::CollapseCell => "CellControlType::CollapseCelln", + CellControlType::ExpandCell => "CellControlType::ExpandCell", + } + } } pub struct CellControl { @@ -962,24 +973,17 @@ impl RenderableCell for CodeCell { CellControlType::RunCell }; - let cell_control = CellControl::new( - match control_type { - CellControlType::StopCell => "stop-cell", - CellControlType::RerunCell => "rerun-cell", - CellControlType::RunCell => "run-cell", - _ => "run-cell", - }, - control_type, + Some( + CellControl::new(control_type.id(), control_type).on_click(cx.listener( + move |this, _, window, cx| { + if this.is_executing { + window.dispatch_action(Box::new(InterruptKernel), cx); + } else { + this.run(window, cx); + } + }, + )), ) - .on_click(cx.listener(move |this, _, window, cx| { - if this.is_executing { - window.dispatch_action(Box::new(InterruptKernel), cx); - } else { - this.run(window, cx); - } - })); - - Some(cell_control) } fn selected(&self) -> bool {