repl: Add restart kernel action and improve shutdown (#16609)
- Implement restart kernel functionality - Clean up shutdown process to properly drop messaging and exit status tasks - Refactor kernel state handling for better consistency Closes #16037 Release Notes: - repl: Added restart kernel action - repl: Fixed issue with shutting down kernels that are in a failure state
This commit is contained in:
parent
9f0438b540
commit
2ad9a742dd
7 changed files with 177 additions and 41 deletions
|
@ -173,8 +173,6 @@ impl QuickActionBar {
|
|||
url: format!("{}#change-kernel", ZED_REPL_DOCUMENTATION),
|
||||
}),
|
||||
)
|
||||
// TODO: Add Restart action
|
||||
// .action("Restart", Box::new(gpui::NoAction))
|
||||
.custom_entry(
|
||||
move |_cx| {
|
||||
Label::new("Shut Down Kernel")
|
||||
|
@ -189,6 +187,20 @@ impl QuickActionBar {
|
|||
}
|
||||
},
|
||||
)
|
||||
.custom_entry(
|
||||
move |_cx| {
|
||||
Label::new("Restart Kernel")
|
||||
.size(LabelSize::Small)
|
||||
.color(Color::Error)
|
||||
.into_any_element()
|
||||
},
|
||||
{
|
||||
let editor = editor.clone();
|
||||
move |cx| {
|
||||
repl::restart(editor.clone(), cx);
|
||||
}
|
||||
},
|
||||
)
|
||||
.separator()
|
||||
.action("View Sessions", Box::new(repl::Sessions))
|
||||
// TODO: Add shut down all kernels action
|
||||
|
@ -305,6 +317,15 @@ fn session_state(session: View<Session>, cx: &WindowContext) -> ReplMenuState {
|
|||
};
|
||||
|
||||
let menu_state = match &session.kernel {
|
||||
Kernel::Restarting => ReplMenuState {
|
||||
tooltip: format!("Restarting {}", kernel_name).into(),
|
||||
icon_is_animating: true,
|
||||
popover_disabled: true,
|
||||
icon_color: Color::Muted,
|
||||
indicator: Some(Indicator::dot().color(Color::Muted)),
|
||||
status: session.kernel.status(),
|
||||
..fill_fields()
|
||||
},
|
||||
Kernel::RunningKernel(kernel) => match &kernel.execution_state {
|
||||
ExecutionState::Idle => ReplMenuState {
|
||||
tooltip: format!("Run code on {} ({})", kernel_name, kernel_language).into(),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue