Skip to content

Avoid using system clipboard in Notebook widget#18474

Merged
krassowski merged 3 commits into
jupyterlab:mainfrom
brichet:avoid_use_of_system_clipboard
Feb 10, 2026
Merged

Avoid using system clipboard in Notebook widget#18474
krassowski merged 3 commits into
jupyterlab:mainfrom
brichet:avoid_use_of_system_clipboard

Conversation

@brichet

@brichet brichet commented Feb 10, 2026

Copy link
Copy Markdown
Contributor

This PR removed the use of system clipboard from the Notebook widget.

References

Related to #18136, and opened as WIP to help debugging.

Code changes

When a clipboard interaction (copy, cut or paste) in Notebook involves cells, the Notebook is aware of the interaction, and can (i) store the copied cells locally (on copy or cut interaction) or (ii) compare the previous copied cell to the pasted one (on paste interaction).
This allows to emit a signal when cells are pasted, whether the pasted cells come from the same Notebook or not, and if they were copied or cut.

Before this PR, to store the copied/cut cells or to compare the pasted cells, the Notebook was using the system clipboard as the last copied cells.
After this PR, when a clipboard interaction happens, the Notebook is aware of the cells involved in the interaction, and does not need the system clipboard.

User-facing changes

None

Backwards-incompatible changes

None

@brichet brichet added the bug label Feb 10, 2026
@jupyterlab-probot

Copy link
Copy Markdown

Thanks for making a pull request to jupyterlab!
To try out this branch on binder, follow this link: Binder

@krassowski krassowski left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good on Binder

Comment thread packages/notebook/src/widget.ts Outdated
@brichet

brichet commented Feb 10, 2026

Copy link
Copy Markdown
Contributor Author

Do we want to update this test, to test both settings ?
We could revert #18335 and add a tests set with the setting to true, only for copy, cut and paste actions. If it starts to fail again, then we'll remove it.

@krassowski

Copy link
Copy Markdown
Member

Do we want to update this test, to test both settings ?

Yes, I think we should.

@brichet

brichet commented Feb 10, 2026

Copy link
Copy Markdown
Contributor Author

OK I added the tests.
BTW, sharding the regression tests is really nice 👍

@brichet brichet marked this pull request as ready for review February 10, 2026 12:13
@krassowski krassowski linked an issue Feb 10, 2026 that may be closed by this pull request

@krassowski krassowski left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @brichet!

@krassowski krassowski merged commit 986a06e into jupyterlab:main Feb 10, 2026
113 of 114 checks passed
@lumberbot-app

lumberbot-app Bot commented Feb 10, 2026

Copy link
Copy Markdown

Owee, I'm MrMeeseeks, Look at me.

There seem to be a conflict, please backport manually. Here are approximate instructions:

  1. Checkout backport branch and update it.
git checkout 4.5.x
git pull
  1. Cherry pick the first parent branch of the this PR on top of the older branch:
git cherry-pick -x -m1 986a06ead3b426f0d15803af203c626c98681d5d
  1. You will likely have some merge/cherry-pick conflict here, fix them and commit:
git commit -am 'Backport PR #18474: Avoid using system clipboard in Notebook widget'
  1. Push to a named branch:
git push YOURFORK 4.5.x:auto-backport-of-pr-18474-on-4.5.x
  1. Create a PR against branch 4.5.x, I would have named this PR:

"Backport PR #18474 on branch 4.5.x (Avoid using system clipboard in Notebook widget)"

And apply the correct labels and milestones.

Congratulations — you did some good work! Hopefully your backport PR will be tested by the continuous integration and merged soon!

Remember to remove the Still Needs Manual Backport label once the PR gets merged.

If these instructions are inaccurate, feel free to suggest an improvement.

krassowski pushed a commit to krassowski/jupyterlab that referenced this pull request Feb 10, 2026
@brichet brichet deleted the avoid_use_of_system_clipboard branch February 10, 2026 13:48
krassowski added a commit that referenced this pull request Feb 10, 2026
…otebook widget) (#18475)

Co-authored-by: Nicolas Brichet <32258950+brichet@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

keyboard shortcut to paste a cell now requires mouse (in Firefox)

2 participants