Skip to content

Fix the cell toolbar for Jupytext Notebook factory #1358

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

Merged
merged 4 commits into from
Mar 22, 2025

Conversation

brichet
Copy link
Contributor

@brichet brichet commented Mar 10, 2025

This PR fixes #990.

The cell toolbar is an extension added to the Notebook factory from the plugin '@jupyterlab/cell-toolbar-extension:plugin'.
With this PR, we make sure that the cell-toolbar-extension is activated, and add all the extensions of the Notebook factory to the Jupytext Notebook factory.

Copy link

Thank you for making this pull request.

Did you know? You can try it on Binder: Binder:lab or Binder:notebook.

Also, the version of Jupytext developed in this PR can be installed with pip:

HATCH_BUILD_HOOKS_ENABLE=true pip install git+https://github.com/brichet/jupytext.git@fix_cell_toolbar

(this requires nodejs, see more at Developing Jupytext)

@mwouts
Copy link
Owner

mwouts commented Mar 11, 2025

Thank you @brichet for this PR and fixing that long standing issue! @mahendrapaipuri may I let you review this PR? Thanks!

@mwouts mwouts requested a review from mahendrapaipuri March 11, 2025 18:36
Copy link

codecov bot commented Mar 11, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.85%. Comparing base (c148bfe) to head (07afb94).
Report is 4 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1358   +/-   ##
=======================================
  Coverage   96.85%   96.85%           
=======================================
  Files          32       32           
  Lines        4924     4924           
=======================================
  Hits         4769     4769           
  Misses        155      155           
Flag Coverage Δ
external 73.41% <ø> (ø)
functional 86.77% <ø> (ø)
integration 80.19% <ø> (+<0.01%) ⬆️
unit 65.54% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Comment on lines 73 to 75
for (const extension of docRegistry.widgetExtensions('Notebook')) {
docRegistry.addWidgetExtension(FACTORY, extension);
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is there a race condition here? I mean, what happens if there are widgets extensions that have registered themselves to Notebook factory after Jupytext?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There is probably a race condition here, this is why we wait for the cell toolbar extension (the one which add the extension to the Notebook factory) to be activated before creating the factory.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually, I missed that there was a signal when a widget extension is added to the registry.
We should probably use it in the factory to keep the factory up to date.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yess, that would be way to go if we can make Jupytext subscribe to that signal.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I updated the PR

@mahendrapaipuri
Copy link
Collaborator

Cheers @brichet for the PR. Could you please rebase onto the main and push so that tests will pass. Cheers!

Copy link
Collaborator

@mahendrapaipuri mahendrapaipuri left a comment

Choose a reason for hiding this comment

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

Cheers @brichet If CI goes green, I think we are good to go!

const firstCell = await page.notebook.getCellLocator(0);
await firstCell?.hover();

await expect(firstCell!.locator('.jp-cell-toolbar')).toHaveCount(1);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Awesome!! Cheers for the tests, very helpful!

@brichet
Copy link
Contributor Author

brichet commented Mar 13, 2025

Looks good, thanks for the review @mahendrapaipuri

@mwouts mwouts added this to the 1.17.0 milestone Mar 22, 2025
@mwouts mwouts merged commit 0638547 into mwouts:main Mar 22, 2025
35 checks passed
@brichet brichet deleted the fix_cell_toolbar branch March 25, 2025 09:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Jupytext and Jupyterlab: cell mini-toolbars missing with Jupytext Notebook
3 participants