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:
Kyle Kelley 2024-08-21 11:51:58 -07:00 committed by GitHub
parent 9f0438b540
commit 2ad9a742dd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 177 additions and 41 deletions

View file

@ -168,6 +168,27 @@ pub fn shutdown(editor: WeakView<Editor>, cx: &mut WindowContext) {
});
}
pub fn restart(editor: WeakView<Editor>, cx: &mut WindowContext) {
let Some(editor) = editor.upgrade() else {
return;
};
let entity_id = editor.entity_id();
let Some(session) = ReplStore::global(cx)
.read(cx)
.get_session(entity_id)
.cloned()
else {
return;
};
session.update(cx, |session, cx| {
session.restart(cx);
cx.notify();
});
}
fn cell_range(buffer: &BufferSnapshot, start_row: u32, end_row: u32) -> Range<Point> {
let mut snippet_end_row = end_row;
while buffer.is_line_blank(snippet_end_row) && snippet_end_row > start_row {