Skip to content

fix(notebook-migration): apply the jupyter panel's read-only setup before the notebook loads - #8909

Merged
mengw15 merged 1 commit into
apache:mainfrom
zyratlo:migration-tool-jupyter-readonly
Oct 7, 2026
Merged

mengw15 merged 1 commit into
apache:mainfrom
zyratlo:migration-tool-jupyter-readonly

Conversation

@zyratlo

@zyratlo zyratlo commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

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 readOnly from cell.is_editable() on every focus and re-enables the keyboard manager at the same time, so setting readOnly once from custom.js did not hold. That setup also raced the notebook: custom.js loads asynchronously and usually misses notebook_loaded, and only worked because it was bound to kernel_ready too.

This PR moves the setup into custom-preload.js, a hook Notebook 6.5 provides that main.js waits for before it builds the notebook. Overrides placed there are always in effect:

  • Cell.prototype.is_editable returns false, so Notebook itself keeps every editor read only, including after focus.
  • KeyboardManager.prototype.enable is a no op, and the manager is disabled once the notebook loads, so focusing a cell no longer brings back Shift+Enter, d d and the other shortcuts.
  • KernelSelector.prototype._spec_not_found continues 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 match python3 and start their kernel as before.
  • The markdown unrender override moves over unchanged.

custom.js keeps only the Texera messaging. Its cell click handler is now delegated from document and bound immediately, rather than on kernel_ready, so clicking a cell to highlight its operator also works when no kernel starts. It stays in custom.js because it needs the origin start-texera-jupyter.sh substitutes.

jupyter.dockerfile copies 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:

  • An R notebook (no kernel installed): no dialog. Typing, Enter, Backspace, Shift+Enter, d d and b change nothing. Double clicking a markdown heading leaves it rendered. R syntax highlighting is intact, and the cell click handler is bound.
  • A Python notebook: the kernel still starts, highlighting is unchanged, and an editor stays read only after focus (before this change it became editable).
  • custom-preload.js is 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)

@zyratlo

zyratlo commented Oct 7, 2026

Copy link
Copy Markdown
Contributor Author

/request-review @mengw15

@mengw15
mengw15 requested a balanced review from Copilot October 7, 2026 18:43
@Yicong-Huang Yicong-Huang added release/v1.3 back porting to release/v1.3 release/v1.2 back porting to release/v1.2 labels Oct 7, 2026
@github-actions
github-actions Bot requested review from mengw15 and xuang7 October 7, 2026 18:48
@github-actions

github-actions Bot commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

Backport auto-label report

This fix: PR was checked against each actively-supported release branch. A release/* label nominates a backport target; the branch's release manager approving this PR is what sends the fix there. The required Backport Approvals check stays red until every label below is approved, so each manager either approves or removes their own label — which is why the labels left on a merged PR are exactly the branches it reached.

Release branch Analysis
✅ release/v1.3 Change detected on this branch — label added; this fix is queued to backport here. @mengw15 decides: approving sends the fix here, removing this label declines it. The merge waits on one or the other. Review requested.
✅ release/v1.2 Change detected on this branch — label added; this fix is queued to backport here. @xuang7 decides: approving sends the fix here, removing this label declines it. The merge waits on one or the other. Review requested.

Auto-label run.

@github-actions github-actions Bot added docs Changes related to documentations infra platform Non-amber Scala service paths labels Oct 7, 2026
@github-actions

github-actions Bot commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

Automated Reviewer Suggestions

Based on the git blame history of the changed files, we recommend the following reviewers:

  • Committers with relevant context: @parshimers
    You can request their reviews formally with /request-review @parshimers.

@mengw15 mengw15 removed release/v1.2 back porting to release/v1.2 release/v1.3 back porting to release/v1.3 labels Oct 7, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 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.

@mengw15
mengw15 enabled auto-merge October 7, 2026 19:14
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.60%. Comparing base (4c982a7) to head (7445d6c).

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           
Flag Coverage Δ *Carryforward flag
access-control-service 77.38% <ø> (ø) Carriedforward from 4c982a7
agent-service 99.16% <ø> (ø) Carriedforward from 4c982a7
amber 88.09% <ø> (ø) Carriedforward from 4c982a7
computing-unit-managing-service 60.48% <ø> (ø) Carriedforward from 4c982a7
config-service 87.37% <ø> (ø) Carriedforward from 4c982a7
file-service 81.53% <ø> (ø) Carriedforward from 4c982a7
frontend 96.59% <ø> (ø) Carriedforward from 4c982a7
notebook-migration-service 83.73% <ø> (ø)
pyamber 98.52% <ø> (ø) Carriedforward from 4c982a7
workflow-compiling-service 74.09% <ø> (ø) Carriedforward from 4c982a7

*This pull request uses carry forward flags. Click here to find out more.

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

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@mengw15
mengw15 added this pull request to the merge queue Oct 7, 2026
Merged via the queue into apache:main with commit b143a4f Oct 7, 2026
45 of 62 checks passed
renovate-bot pushed a commit to renovate-bot/apache-_-texera that referenced this pull request Nov 10, 2026
…#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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Changes related to documentations infra platform Non-amber Scala service paths

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Notebook Migration] Jupyter panel cells become editable after a click

5 participants