mito-ds / mito

The mitosheet package, trymito.io, and other public Mito code.
https://trymito.io
Other
2.3k stars 161 forks source link

"New Mitosheet" button showing in unsupported kernels #1357

Open smm9509 opened 2 weeks ago

smm9509 commented 2 weeks ago

Describe the bug When the kernel of a Jupyter Lab Notebook is set to something other than ipykernel (e.g. xeus-octave or qalc), the purple button "New Mitosheet" still shows, and clicking it adds a cell with code in the wrong syntax for the current kernel. screenshot of bug

To Reproduce Steps to reproduce the behavior:

  1. Get a non-python Jupyter kernel (e.g. Xeus Octave, or in my case I'm using my own Qalc Kernel not yet released)
  2. python -m mitosheet hello
  3. open or create a Jupyter Lab Notebook using the browser tab that opens
  4. in the northeast corner, click on "Python 3 (ipykernel)" and select a non-python kernel or a kernel that runs in a python environment without Mito image
  5. click the purple button "New Mitosheet"
  6. see the kernel throw errors as it attempts to process code in the wrong programming language. screenshot of bug

Please include the relevant dataset if the bug you encountered is dataset specific. Make sure to anonymize the data properly.

Expected behavior The purple button "New Mitosheet" is hidden or grayed out when an unsupported Jupyter kernel is selected, and it does not cause problems in the current Notebook.

Screenshots screenshot of bug

Desktop:

Additional context

aarondr77 commented 2 weeks ago

Hey @smm9509 thanks for pointing this out. I think we should be able to detect the type of kernel we're operating in and conditionally load this extension / display the button.

Let me take a look into this and see if there's a good fix.