In fairness the problem is not easy! JupyterLab only got document-wide undo/redo in 2021 per https://jupyterlab.readthedocs.io/en/3.1.x/getting_started/c... .