Repository navigation
fix(notebook-migration): apply the jupyter panel's read-only setup before the notebook loads - #8909
Conversation
…fore the notebook loads
|
/request-review @mengw15 |
Backport auto-label reportThis
|
Automated Reviewer SuggestionsBased on the
|
There was a problem hiding this comment.
🟢 Approval recommended
The focused changes align with Notebook 6.5’s initialization and event behavior without introducing unresolved issues.
0 open findings
What changed in this PR
Moves Jupyter read-only enforcement into its preload lifecycle, preventing focus and missing kernels from restoring editing behavior.
Changes:
- Preloads cell, keyboard, kernel-dialog, and markdown protections.
- Makes cell-click messaging independent of kernel startup.
- Packages and documents the new preload file.
| File | Description |
|---|---|
custom.js |
Delegates cell-click messaging immediately. |
custom-preload.js |
Enforces read-only notebook behavior before loading. |
bin/local-dev/README.md |
Documents image rebuild requirements. |
bin/dockerfiles/jupyter.dockerfile |
Copies the preload customization into the image. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #8909 +/- ##
=========================================
Coverage 92.60% 92.60%
Complexity 5044 5044
=========================================
Files 1252 1252
Lines 53580 53580
Branches 6672 6672
=========================================
Hits 49616 49616
Misses 2317 2317
Partials 1647 1647
*This pull request uses carry forward flags. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
…#8912) ### What changes were proposed in this PR? This PR lets users convert R Jupyter notebooks, using the R conversion from apache#8911. It is the first of the UI PRs for R support (apache#8009). R files follow in apache#8963 and R folders in a later PR, each as a new tab beside the Python ones. **Import modal.** The Jupyter Notebook tab gets a "Python Notebook | R Notebook" switch, centered above the diagram. It defaults to Python. The diagram, the description and the upload label follow it, and changing it clears the staged file. The switch is a `FormControl`, so it keeps its value when the tab re-renders. `requestImport` now receives a `language`. **Disabled, not hidden.** When `rNotebookMigrationEnabled` is off, the R Notebook option stays visible but disabled, with the tooltip "R is not enabled on this deployment." Users can see that R exists without being able to pick it on a deployment that cannot run it. The guard from apache#8911 still refuses R in that case, before any model call. **Tab descriptors.** A small `IMPORT_TABS` list replaces the index checks that decided the folder tab and the language. The R file and folder tabs each add one entry. **Dispatch.** The dashboard passes the language to the notebook conversion. For R, only `.ipynb` is accepted in this PR. A notebook uploaded as R whose `kernelspec.language` is set and is not R is rejected before any model call: "This notebook uses a python kernel, not R. Switch the notebook type to Python Notebook." A notebook without a kernelspec is accepted. Other language mismatches are tracked in apache#8929. **Assets.** A new R notebook diagram, at the same size and border as the others. `frontend/LICENSE-binary` adds it to the Project Jupyter logo and Material Symbols entries. #### Demo video (wait time cut out) https://github.com/user-attachments/assets/9769bdd8-5e2d-4994-8a5a-be216908b09f #### R disabled on a deployment without R <img width="420" height="159" alt="Screenshot 2026-10-12 at 1 51 42 PM" src="https://github.com/user-attachments/assets/2c45ea97-9fe2-4b3c-a8ec-4fc2a8875d22" /> ### Any related issues, documentation, discussions? Closes apache#9384 Part of apache#8009 Parent-issue apache#4301 The plan is in apache#8866. R notebooks open in the Jupyter panel without a kernel, since the Jupyter image has no R kernel. apache#8909 removed the "Kernel not found" dialog that otherwise appears and keeps the cells read only. ### How was this PR tested? * `notebook-import-modal.component.spec.ts`, seven new tests: Python is the default; the R option is disabled with its tooltip while the R flag is off and enabled without one while it is on; switching to R changes the diagram and label and drops the staged notebook; R stays selected across a re-render; the file and folder tabs keep their own language; and submit passes `"r"`. Existing assertions now expect `"python"`. * `user-workflow.component.spec.ts`, five new tests: a Python notebook converts as Python by default, an R notebook converts as R with or without a kernelspec, a Python kernel notebook is rejected as R, and a non notebook file is rejected as R. The full frontend suite passes. Checked by hand against a local stack. With the R flag on, the switch changes the diagram, description and label, clears a staged file, and survives leaving and returning to the tab. With it off, the R option is disabled and shows its tooltip. The tab fits the modal without scrolling in every state. An R notebook converted end to end with a live model. ### Was this PR authored or co-authored using generative AI tooling? Generated-by: Claude Code (Claude Opus 5.5)
What changes were proposed in this PR?
The Jupyter panel's cells became editable as soon as a viewer clicked into one. Classic Notebook resets each editor's
readOnlyfromcell.is_editable()on every focus and re-enables the keyboard manager at the same time, so settingreadOnlyonce fromcustom.jsdid not hold. That setup also raced the notebook:custom.jsloads asynchronously and usually missesnotebook_loaded, and only worked because it was bound tokernel_readytoo.This PR moves the setup into
custom-preload.js, a hook Notebook 6.5 provides thatmain.jswaits for before it builds the notebook. Overrides placed there are always in effect:Cell.prototype.is_editablereturns false, so Notebook itself keeps every editor read only, including after focus.KeyboardManager.prototype.enableis a no op, and the manager is disabled once the notebook loads, so focusing a cell no longer brings back Shift+Enter,d dand the other shortcuts.KernelSelector.prototype._spec_not_foundcontinues without a kernel instead of opening the "Kernel not found" dialog. The panel never runs cells, so a notebook whose kernel is not installed opens normally. Python notebooks still matchpython3and start their kernel as before.unrenderoverride moves over unchanged.custom.jskeeps only the Texera messaging. Its cell click handler is now delegated fromdocumentand bound immediately, rather than onkernel_ready, so clicking a cell to highlight its operator also works when no kernel starts. It stays incustom.jsbecause it needs the originstart-texera-jupyter.shsubstitutes.jupyter.dockerfilecopies the new file, and the local dev README lists it among the files that need an image rebuild.Any related issues, documentation, discussions?
Closes #8908
Parent-issue #4301
R support (#8009) depends on this: R notebooks open in the panel without a kernel, which hit both the dialog and the editable cells.
How was this PR tested?
These files have no automated tests. Tested by hand in the Jupyter container, with real keystrokes:
d dandbchange nothing. Double clicking a markdown heading leaves it rendered. R syntax highlighting is intact, and the cell click handler is bound.custom-preload.jsis served by the rebuilt image. A server that was already running keeps serving Notebook's default stub until restarted, since Notebook caches static file locations.Was this PR authored or co-authored using generative AI tooling?
Generated-by: Claude Code (Claude Opus 5.5)