Skip to content

Commit 0b4f8d4

Browse files
Display a toast notification when switching kernels (#154)
Co-authored-by: Peyton Murray <[email protected]>
1 parent 3e35942 commit 0b4f8d4

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/index.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { ILabShell, JupyterFrontEnd, JupyterFrontEndPlugin } from '@jupyterlab/application';
22
import { INotebookTracker, NotebookPanel } from '@jupyterlab/notebook';
3-
import { Dialog, showDialog, ReactWidget } from '@jupyterlab/apputils';
3+
import { Dialog, showDialog, ReactWidget, Notification } from '@jupyterlab/apputils';
44
import { PageConfig } from '@jupyterlab/coreutils';
55
import { INotebookContent } from '@jupyterlab/nbformat';
66

@@ -366,6 +366,17 @@ const plugin: JupyterFrontEndPlugin<void> = {
366366
return;
367367
}
368368

369+
const currentKernel = panel.sessionContext.session?.kernel?.name || '';
370+
371+
if (currentKernel !== kernel) {
372+
const currentKernelDisplay = KERNEL_DISPLAY_NAMES[currentKernel] || currentKernel;
373+
const targetKernelDisplay = KERNEL_DISPLAY_NAMES[kernel] || kernel;
374+
Notification.warning(
375+
`You are about to switch your notebook coding language from ${currentKernelDisplay} to ${targetKernelDisplay}. Your previously created code will not run as intended.`,
376+
{ autoClose: 5000 }
377+
);
378+
}
379+
369380
await switchKernel(panel, kernel);
370381
}
371382
});

0 commit comments

Comments
 (0)