From a8b84497a3e32d6a98c7b23a05a43cbc776d1c30 Mon Sep 17 00:00:00 2001 From: Nadir <67718820+raideno@users.noreply.github.com> Date: Tue, 21 Apr 2026 00:11:11 +0200 Subject: [PATCH] repl: Correctly discover user's kernels (#50978) Closes #50977 Before you mark this PR as ready for review, make sure that you have: - [x] Added a solid test coverage and/or screenshots from doing manual testing - [x] Done a self-review taking into account security and performance aspects - [x] Aligned any UI changes with the [UI checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist) Before: image After: image Release Notes: - Fixed kernels discovery in python notebook editor. --------- Co-authored-by: Finn Evers --- crates/repl/src/notebook/notebook_ui.rs | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) 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"),