Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shortcuts to insert cell before/after are swapped at random #17026

Open
The-Markitecht opened this issue Dec 2, 2024 · 6 comments
Open

Shortcuts to insert cell before/after are swapped at random #17026

The-Markitecht opened this issue Dec 2, 2024 · 6 comments
Labels
bug status:Needs Triage Applied to new issues that need triage

Comments

@The-Markitecht
Copy link

The-Markitecht commented Dec 2, 2024

Description

These 2 documented keyboard shortcuts:
A = new cell above current
B = new cell below current
are often effectively SWAPPED for no obvious reason. This comes and goes seemingly at random. This is severely disruptive to workflow.

Once it gets into the swapped state, every cell behaves that way, even in other notebooks. Don't know exactly what gets it into the swapped state. Dozens of attempts to find a trigger for the behavior have found no pattern, no reliable way to trigger it. Yet.

During the swapped state, arrow keys work as expected to navigate through to cells above or below the new one, in the correct order i.e. the same order they appear on screen.

Could not find any similar reports in the issue database or any forums on the internet.

This is a MADDENING issue that might actually drive me (and others?) away from Jupyter entirely. That would be a real shame since it's obviously very powerful.

Reproduce

  1. Create a new notebook. (I noticed this issue the very first time I used Jupyter Lab, and every time since. I've never used Jupyter Notebook.)
  2. Add some cells.
  3. Observe that the B and A keyboard shortcuts work as expected (insert BEFORE or AFTER).
  4. Add a code cell with a line of Python in it. (not sure about this part)
  5. Press Ctrl-Enter to run the cell. (not sure about this part)
  6. Press B shortcut.
  7. Observe that the new cell goes AFTER the current one, not BEFORE it as expected.
  8. Press A shortcut.
  9. Observe that the new cell goes BEFORE the current one, not AFTER it as expected. These 2 shortcuts appear to be effectively swapped now.
  10. Use arrow keys to navigate to any other cell.
  11. Try B and A shortcuts there, and observe that they are still swapped for any cell, of any type.
  12. Try B and A shortcuts in another notebook, and observe that they are still swapped for any notebook.
  13. Click browser's "reload page" button. Wait for page to load. Observe the shortcuts are still swapped.
  14. Re-test in a different browser, and observe the same issue.
  15. Click the "insert before" or "insert after" buttons within a cell. Observe that they still work correctly. Only the keyboard shortcuts are swapped. SOMETIMES (maybe 50%?) those buttons seem to fix the issue temporarily. It comes back 1 to 5 minutes later. Those buttons' "tool tip" hints always show the correct letters B and A as expected.
  16. Open the keyboard shortcuts in Jupyter settings. Observe that they always show the correct assignments for B and A. No other shortcuts use B or A alone. All shortcuts are the defaults.
  17. Click menu File / Shut Down. Launch server again. Reload page. Observe shortcuts are still swapped.

Expected behavior

Expect B and A to consistently insert a new cell BEFORE or AFTER the current cell. Just like the GUI before/after buttons within the cell do.

Context

  • Operating System and version: Debian bookworm/sid 12.8
  • Browser and version: I normally use Brave 1.71.118 (Chromium: 130.0.6723.70) (Official Build) (64-bit). Issue even happens on Firefox 102.1.0esr (64-bit) (a non-Chromium browser). The only browser extensions are Bitwarden, and Tab Groups Extension. Neither of those use B or A shortcuts.
  • JupyterLab version: 4.3.1
Troubleshoot Output
(zipline-virtual-env) === x@(redacted): (redacted)/zipline/zipline-virtual-env/bin $ jupyter troubleshoot
$PATH:
        /(redacted)/zipline/zipline-virtual-env/bin
        /usr/local/bin
        /usr/bin
        /bin
        /usr/local/games
        /usr/games
        /snap/bin
        /home/x/.i3
        /home/x/.local/bin
        /home/x/.i3
        /home/x/.local/bin

sys.path:
/(redacted)/zipline/zipline-virtual-env/bin
/usr/lib/python311.zip
/usr/lib/python3.11
/usr/lib/python3.11/lib-dynload
/(redacted)/zipline/zipline-virtual-env/lib/python3.11/site-packages

sys.executable:
/(redacted)/zipline/zipline-virtual-env/bin/python

sys.version:
3.11.2 (main, Sep 14 2024, 03:00:30) [GCC 12.2.0]

platform.platform():
Linux-5.18.0-4-amd64-x86_64-with-glibc2.36

which -a jupyter:
/(redacted)/zipline/zipline-virtual-env/bin/jupyter

pip list:
Package Version
------------------------- --------------
alembic 1.14.0
anyio 4.6.2.post1
argon2-cffi 23.1.0
argon2-cffi-bindings 21.2.0
arrow 1.3.0
asttokens 2.4.1
async-lru 2.0.4
attrs 24.2.0
babel 2.16.0
bcolz-zipline 1.2.12
beautifulsoup4 4.12.3
bleach 6.2.0
blosc2 2.7.1
Bottleneck 1.4.2
certifi 2024.8.30
cffi 1.17.1
charset-normalizer 3.4.0
click 8.1.7
comm 0.2.2
contourpy 1.3.1
cycler 0.12.1
debugpy 1.8.8
decorator 5.1.1
defusedxml 0.7.1
empyrical-reloaded 0.5.11
exchange_calendars 4.5.8
executing 2.1.0
fastjsonschema 2.20.0
fonttools 4.55.0
fqdn 1.5.1
greenlet 3.1.1
h11 0.14.0
h5py 3.12.1
httpcore 1.0.7
httpx 0.27.2
idna 3.10
intervaltree 3.1.0
ipykernel 6.29.5
ipython 8.29.0
iso3166 2.1.1
iso4217 1.12.20240625
isoduration 20.11.0
jedi 0.19.2
Jinja2 3.1.4
json5 0.9.28
jsonpointer 3.0.0
jsonschema 4.23.0
jsonschema-specifications 2024.10.1
jupyter_client 8.6.3
jupyter_core 5.7.2
jupyter-events 0.10.0
jupyter-lsp 2.2.5
jupyter_server 2.14.2
jupyter_server_terminals 0.5.3
jupyterlab 4.3.1
jupyterlab_pygments 0.3.0
jupyterlab_server 2.27.3
kiwisolver 1.4.7
korean-lunar-calendar 0.3.1
lru-dict 1.3.0
Mako 1.3.6
MarkupSafe 3.0.2
matplotlib 3.9.2
matplotlib-inline 0.1.7
mistune 3.0.2
msgpack 1.1.0
multipledispatch 1.0.0
nbclient 0.10.0
nbconvert 7.16.4
nbformat 5.10.4
ndindex 1.9.2
nest-asyncio 1.6.0
networkx 3.4.2
notebook_shim 0.2.4
numexpr 2.10.1
numpy 2.1.3
overrides 7.7.0
packaging 24.2
pandas 2.2.3
pandocfilters 1.5.1
parso 0.8.4
patsy 1.0.1
peewee 3.17.3
pexpect 4.9.0
pillow 11.0.0
pip 23.0.1
platformdirs 4.3.6
prometheus_client 0.21.0
prompt_toolkit 3.0.48
psutil 6.1.0
ptyprocess 0.7.0
pure_eval 0.2.3
py-cpuinfo 9.0.0
pycparser 2.22
Pygments 2.18.0
pyluach 2.2.0
pyparsing 3.2.0
python-dateutil 2.9.0.post0
python-interface 1.6.1
python-json-logger 2.0.7
pytz 2024.2
PyYAML 6.0.2
pyzmq 26.2.0
referencing 0.35.1
requests 2.32.3
rfc3339-validator 0.1.4
rfc3986-validator 0.1.1
rpds-py 0.21.0
scipy 1.14.1
Send2Trash 1.8.3
setuptools 66.1.1
six 1.16.0
sniffio 1.3.1
sortedcontainers 2.4.0
soupsieve 2.6
SQLAlchemy 2.0.36
stack-data 0.6.3
statsmodels 0.14.4
tables 3.10.1
terminado 0.18.1
tinycss2 1.4.0
toolz 1.0.0
tornado 6.4.1
traitlets 5.14.3
types-python-dateutil 2.9.0.20241003
typing_extensions 4.12.2
tzdata 2024.2
uri-template 1.3.0
urllib3 2.2.3
wcwidth 0.2.13
webcolors 24.11.1
webencodings 0.5.1
websocket-client 1.8.0
zipline-reloaded 3.1

Command Line Output This issue causes no unusual console output in the terminal where Jupyter was invoked. I'll try to catch it misbehaving again, while --debug is in effect.
Browser Output JavaScript console, each time i use the shortcut, outputs these 2 errors:
(anonymous) @ VM2981:1
jlab_core.e3a3a97fe081da5cfa40.js?v=e3a3a97fe081da5cfa40:1 TypeError: Cannot read properties of null (reading 'id')
    at te.estimateWidgetSize (jlab_core.e3a3a97fe081da5cfa40.js?v=e3a3a97fe081da5cfa40:1:1185043)
    at jlab_core.e3a3a97fe081da5cfa40.js?v=e3a3a97fe081da5cfa40:1:1726908
    at Array.map ()
    at te.onListChanged (jlab_core.e3a3a97fe081da5cfa40.js?v=e3a3a97fe081da5cfa40:1:1726875)
    at m (jlab_core.e3a3a97fe081da5cfa40.js?v=e3a3a97fe081da5cfa40:1:1827134)
    at Object.l [as emit] (jlab_core.e3a3a97fe081da5cfa40.js?v=e3a3a97fe081da5cfa40:1:1826810)
    at a.emit (jlab_core.e3a3a97fe081da5cfa40.js?v=e3a3a97fe081da5cfa40:1:1824647)
    at jlab_core.e3a3a97fe081da5cfa40.js?v=e3a3a97fe081da5cfa40:1:1151866
    at Array.forEach ()
    at b._onSharedModelChanged (jlab_core.e3a3a97fe081da5cfa40.js?v=e3a3a97fe081da5cfa40:1:1151840)
e.exceptionHandler @ jlab_core.e3a3a97fe081da5cfa40.js?v=e3a3a97fe081da5cfa40:1
m @ jlab_core.e3a3a97fe081da5cfa40.js?v=e3a3a97fe081da5cfa40:1
l @ jlab_core.e3a3a97fe081da5cfa40.js?v=e3a3a97fe081da5cfa40:1
emit @ jlab_core.e3a3a97fe081da5cfa40.js?v=e3a3a97fe081da5cfa40:1
(anonymous) @ jlab_core.e3a3a97fe081da5cfa40.js?v=e3a3a97fe081da5cfa40:1
_onSharedModelChanged @ jlab_core.e3a3a97fe081da5cfa40.js?v=e3a3a97fe081da5cfa40:1
m @ jlab_core.e3a3a97fe081da5cfa40.js?v=e3a3a97fe081da5cfa40:1
l @ jlab_core.e3a3a97fe081da5cfa40.js?v=e3a3a97fe081da5cfa40:1
emit @ jlab_core.e3a3a97fe081da5cfa40.js?v=e3a3a97fe081da5cfa40:1
E._onYCellsChanged @ 5521.cc7da8760b98f2dd2c18.js?v=cc7da8760b98f2dd2c18:1
r @ 9046.99c477ea375dcbb8c7ca.js?v=99c477ea375dcbb8c7ca:1
Fi @ 9046.99c477ea375dcbb8c7ca.js?v=99c477ea375dcbb8c7ca:1
Ac @ 9046.99c477ea375dcbb8c7ca.js?v=99c477ea375dcbb8c7ca:1
_callObserver @ 9046.99c477ea375dcbb8c7ca.js?v=99c477ea375dcbb8c7ca:1
(anonymous) @ 9046.99c477ea375dcbb8c7ca.js?v=99c477ea375dcbb8c7ca:1
r @ 9046.99c477ea375dcbb8c7ca.js?v=99c477ea375dcbb8c7ca:1
zo @ 9046.99c477ea375dcbb8c7ca.js?v=99c477ea375dcbb8c7ca:1
Jo @ 9046.99c477ea375dcbb8c7ca.js?v=99c477ea375dcbb8c7ca:1
transact @ 9046.99c477ea375dcbb8c7ca.js?v=99c477ea375dcbb8c7ca:1
transact @ 5521.cc7da8760b98f2dd2c18.js?v=cc7da8760b98f2dd2c18:1
insertCells @ 5521.cc7da8760b98f2dd2c18.js?v=cc7da8760b98f2dd2c18:1
insertCell @ 5521.cc7da8760b98f2dd2c18.js?v=cc7da8760b98f2dd2c18:1
h @ jlab_core.e3a3a97fe081da5cfa40.js?v=e3a3a97fe081da5cfa40:1
execute @ jlab_core.e3a3a97fe081da5cfa40.js?v=e3a3a97fe081da5cfa40:1
execute @ jlab_core.e3a3a97fe081da5cfa40.js?v=e3a3a97fe081da5cfa40:1
_executeKeyBinding @ jlab_core.e3a3a97fe081da5cfa40.js?v=e3a3a97fe081da5cfa40:1
await in _executeKeyBinding
processKeydownEvent @ jlab_core.e3a3a97fe081da5cfa40.js?v=e3a3a97fe081da5cfa40:1
evtKeydown @ jlab_core.e3a3a97fe081da5cfa40.js?v=e3a3a97fe081da5cfa40:1
handleEvent @ jlab_core.e3a3a97fe081da5cfa40.js?v=e3a3a97fe081da5cfa40:1
jlab_core.e3a3a97fe081da5cfa40.js?v=e3a3a97fe081da5cfa40:1 TypeError: Cannot read properties of null (reading 'id')
    at p (jlab_core.e3a3a97fe081da5cfa40.js?v=e3a3a97fe081da5cfa40:1:1092156)
    at jlab_core.e3a3a97fe081da5cfa40.js?v=e3a3a97fe081da5cfa40:1:1092554
    at m (jlab_core.e3a3a97fe081da5cfa40.js?v=e3a3a97fe081da5cfa40:1:1827134)
    at Object.l [as emit] (jlab_core.e3a3a97fe081da5cfa40.js?v=e3a3a97fe081da5cfa40:1:1826810)
    at a.emit (jlab_core.e3a3a97fe081da5cfa40.js?v=e3a3a97fe081da5cfa40:1:1824647)
    at jlab_core.e3a3a97fe081da5cfa40.js?v=e3a3a97fe081da5cfa40:1:1151866
    at Array.forEach ()
    at b._onSharedModelChanged (jlab_core.e3a3a97fe081da5cfa40.js?v=e3a3a97fe081da5cfa40:1:1151840)
    at m (jlab_core.e3a3a97fe081da5cfa40.js?v=e3a3a97fe081da5cfa40:1:1827134)
    at Object.l [as emit] (jlab_core.e3a3a97fe081da5cfa40.js?v=e3a3a97fe081da5cfa40:1:1826810)
e.exceptionHandler @ jlab_core.e3a3a97fe081da5cfa40.js?v=e3a3a97fe081da5cfa40:1
m @ jlab_core.e3a3a97fe081da5cfa40.js?v=e3a3a97fe081da5cfa40:1
l @ jlab_core.e3a3a97fe081da5cfa40.js?v=e3a3a97fe081da5cfa40:1
emit @ jlab_core.e3a3a97fe081da5cfa40.js?v=e3a3a97fe081da5cfa40:1
(anonymous) @ jlab_core.e3a3a97fe081da5cfa40.js?v=e3a3a97fe081da5cfa40:1
_onSharedModelChanged @ jlab_core.e3a3a97fe081da5cfa40.js?v=e3a3a97fe081da5cfa40:1
m @ jlab_core.e3a3a97fe081da5cfa40.js?v=e3a3a97fe081da5cfa40:1
l @ jlab_core.e3a3a97fe081da5cfa40.js?v=e3a3a97fe081da5cfa40:1
emit @ jlab_core.e3a3a97fe081da5cfa40.js?v=e3a3a97fe081da5cfa40:1
E._onYCellsChanged @ 5521.cc7da8760b98f2dd2c18.js?v=cc7da8760b98f2dd2c18:1
r @ 9046.99c477ea375dcbb8c7ca.js?v=99c477ea375dcbb8c7ca:1
Fi @ 9046.99c477ea375dcbb8c7ca.js?v=99c477ea375dcbb8c7ca:1
Ac @ 9046.99c477ea375dcbb8c7ca.js?v=99c477ea375dcbb8c7ca:1
_callObserver @ 9046.99c477ea375dcbb8c7ca.js?v=99c477ea375dcbb8c7ca:1
(anonymous) @ 9046.99c477ea375dcbb8c7ca.js?v=99c477ea375dcbb8c7ca:1
r @ 9046.99c477ea375dcbb8c7ca.js?v=99c477ea375dcbb8c7ca:1
zo @ 9046.99c477ea375dcbb8c7ca.js?v=99c477ea375dcbb8c7ca:1
Jo @ 9046.99c477ea375dcbb8c7ca.js?v=99c477ea375dcbb8c7ca:1
transact @ 9046.99c477ea375dcbb8c7ca.js?v=99c477ea375dcbb8c7ca:1
transact @ 5521.cc7da8760b98f2dd2c18.js?v=cc7da8760b98f2dd2c18:1
insertCells @ 5521.cc7da8760b98f2dd2c18.js?v=cc7da8760b98f2dd2c18:1
insertCell @ 5521.cc7da8760b98f2dd2c18.js?v=cc7da8760b98f2dd2c18:1
h @ jlab_core.e3a3a97fe081da5cfa40.js?v=e3a3a97fe081da5cfa40:1
execute @ jlab_core.e3a3a97fe081da5cfa40.js?v=e3a3a97fe081da5cfa40:1
execute @ jlab_core.e3a3a97fe081da5cfa40.js?v=e3a3a97fe081da5cfa40:1
_executeKeyBinding @ jlab_core.e3a3a97fe081da5cfa40.js?v=e3a3a97fe081da5cfa40:1
await in _executeKeyBinding
processKeydownEvent @ jlab_core.e3a3a97fe081da5cfa40.js?v=e3a3a97fe081da5cfa40:1
evtKeydown @ jlab_core.e3a3a97fe081da5cfa40.js?v=e3a3a97fe081da5cfa40:1
handleEvent @ jlab_core.e3a3a97fe081da5cfa40.js?v=e3a3a97fe081da5cfa40:1
@jupyterlab-probot jupyterlab-probot bot added the status:Needs Triage Applied to new issues that need triage label Dec 2, 2024
@krassowski
Copy link
Member

Can you try downgrading to JupyterLab 4.3.0 and confirm if the problem goes away?

@The-Markitecht
Copy link
Author

pip uninstall jupyterlab
pip install jupyterlab==4.3.0

I doubt if that also rippled into any packages it depends on....

Packages
pip list

Package Version


alembic 1.14.0
anyio 4.6.2.post1
argon2-cffi 23.1.0
argon2-cffi-bindings 21.2.0
arrow 1.3.0
asttokens 2.4.1
async-lru 2.0.4
attrs 24.2.0
babel 2.16.0
bcolz-zipline 1.2.12
beautifulsoup4 4.12.3
bleach 6.2.0
blosc2 2.7.1
Bottleneck 1.4.2
certifi 2024.8.30
cffi 1.17.1
charset-normalizer 3.4.0
click 8.1.7
comm 0.2.2
contourpy 1.3.1
cycler 0.12.1
debugpy 1.8.8
decorator 5.1.1
defusedxml 0.7.1
empyrical-reloaded 0.5.11
exchange_calendars 4.5.8
executing 2.1.0
fastjsonschema 2.20.0
fonttools 4.55.0
fqdn 1.5.1
greenlet 3.1.1
h11 0.14.0
h5py 3.12.1
httpcore 1.0.7
httpx 0.27.2
idna 3.10
intervaltree 3.1.0
ipykernel 6.29.5
ipython 8.29.0
iso3166 2.1.1
iso4217 1.12.20240625
isoduration 20.11.0
jedi 0.19.2
Jinja2 3.1.4
json5 0.9.28
jsonpointer 3.0.0
jsonschema 4.23.0
jsonschema-specifications 2024.10.1
jupyter_client 8.6.3
jupyter_core 5.7.2
jupyter-events 0.10.0
jupyter-lsp 2.2.5
jupyter_server 2.14.2
jupyter_server_terminals 0.5.3
jupyterlab 4.3.0
jupyterlab_pygments 0.3.0
jupyterlab_server 2.27.3
kiwisolver 1.4.7
korean-lunar-calendar 0.3.1
lru-dict 1.3.0
Mako 1.3.6
MarkupSafe 3.0.2
matplotlib 3.9.2
matplotlib-inline 0.1.7
mistune 3.0.2
msgpack 1.1.0
multipledispatch 1.0.0
nbclient 0.10.0
nbconvert 7.16.4
nbformat 5.10.4
ndindex 1.9.2
nest-asyncio 1.6.0
networkx 3.4.2
notebook_shim 0.2.4
numexpr 2.10.1
numpy 2.1.3
overrides 7.7.0
packaging 24.2
pandas 2.2.3
pandocfilters 1.5.1
parso 0.8.4
patsy 1.0.1
peewee 3.17.3
pexpect 4.9.0
pillow 11.0.0
pip 23.0.1
platformdirs 4.3.6
prometheus_client 0.21.0
prompt_toolkit 3.0.48
psutil 6.1.0
ptyprocess 0.7.0
pure_eval 0.2.3
py-cpuinfo 9.0.0
pycparser 2.22
Pygments 2.18.0
pyluach 2.2.0
pyparsing 3.2.0
python-dateutil 2.9.0.post0
python-interface 1.6.1
python-json-logger 2.0.7
pytz 2024.2
PyYAML 6.0.2
pyzmq 26.2.0
referencing 0.35.1
requests 2.32.3
rfc3339-validator 0.1.4
rfc3986-validator 0.1.1
rpds-py 0.21.0
scipy 1.14.1
Send2Trash 1.8.3
setuptools 66.1.1
six 1.16.0
sniffio 1.3.1
sortedcontainers 2.4.0
soupsieve 2.6
SQLAlchemy 2.0.36
stack-data 0.6.3
statsmodels 0.14.4
tables 3.10.1
terminado 0.18.1
tinycss2 1.4.0
toolz 1.0.0
tornado 6.4.1
traitlets 5.14.3
types-python-dateutil 2.9.0.20241003
typing_extensions 4.12.2
tzdata 2024.2
uri-template 1.3.0
urllib3 2.2.3
wcwidth 0.2.13
webcolors 24.11.1
webencodings 0.5.1
websocket-client 1.8.0
zipline-reloaded 3.1

4.3.0 also got the symptom, starting with the very first attempt. See screen shot.

I was in the Any Time heading cell and hit A. New cell should have landed after Any Time. Landed before instead. At that time I had done nothing at all besides:

  • launch the server
  • open the notebook
  • arrow down one time to arrive at Any Time cell.
  • press A

Clearing the browser cache and reloading the page had no impact on the symptom.

@The-Markitecht
Copy link
Author

2024-12-03-092527_1920x2928_scrot

@JasonWeill
Copy link
Contributor

Thanks for opening this issue! Can you share the output of jupyter labextension list? Are any labextensions enabled? If so, does the problem persist when you disable these extensions?

@The-Markitecht
Copy link
Author

The-Markitecht commented Dec 3, 2024

JupyterLab v4.3.0
(redacted)/zipline/zipline-virtual-env/share/jupyter/labextensions
        jupyterlab_pygments v0.3.0 enabled OK (python, jupyterlab_pygments)

I don't know what that does, or how to turn it off.

Thanks for the follow-up!

@The-Markitecht
Copy link
Author

By the way, a while back, I already set the windowing mode to defer if that matters. It really messed with my head to have cells not showing up because of the default setting. Found that suggestion in other issues in this database.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug status:Needs Triage Applied to new issues that need triage
Projects
None yet
Development

No branches or pull requests

3 participants