diff --git a/crates/repl/src/notebook/notebook_ui.rs b/crates/repl/src/notebook/notebook_ui.rs index ce0b6f598971ecdb07bdf763a359830dd334be1e..a04c124c3d5ab56128bc5440d9999fadd74caa8f 100644 --- a/crates/repl/src/notebook/notebook_ui.rs +++ b/crates/repl/src/notebook/notebook_ui.rs @@ -206,13 +206,14 @@ impl NotebookEditor { cell_order: cell_order.clone(), original_cell_order: cell_order.clone(), cell_map: cell_map.clone(), - kernel: Kernel::Shutdown, // TODO: use recommended kernel after the implementation is done in repl + kernel: Kernel::Shutdown, kernel_specification: None, execution_requests: HashMap::default(), kernel_picker_handle: PopoverMenuHandle::default(), }; editor.launch_kernel(window, cx); editor.refresh_language(cx); + editor.refresh_kernelspecs(cx); cx.subscribe(¬ebook_item, |this, _item, _event, cx| { this.refresh_language(cx); @@ -222,6 +223,18 @@ impl NotebookEditor { editor } + fn refresh_kernelspecs(&mut self, cx: &mut Context) { + let store = ReplStore::global(cx); + let project = self.project.clone(); + let worktree_id = self.worktree_id; + + let refresh_task = store.update(cx, |store, cx| { + store.refresh_python_kernelspecs(worktree_id, &project, cx) + }); + + cx.background_spawn(refresh_task).detach_and_log_err(cx); + } + fn refresh_language(&mut self, cx: &mut Context) { let notebook_language = self.notebook_item.read(cx).notebook_language(); let task = cx.spawn(async move |this, cx| { @@ -313,8 +326,13 @@ impl NotebookEditor { } fn launch_kernel(&mut self, window: &mut Window, cx: &mut Context) { - // use default Python kernel if no specification is set - let spec = self.kernel_specification.clone().unwrap_or_else(|| { + let spec = self.kernel_specification.clone().or_else(|| { + ReplStore::global(cx) + .read(cx) + .active_kernelspec(self.worktree_id, None, cx) + }); + + let spec = spec.unwrap_or_else(|| { KernelSpecification::Jupyter(LocalKernelSpecification { name: "python3".to_string(), path: PathBuf::from("python3"),