The GitHub Actions job "Required Checks" on texera.git/main has failed.
Run started by GitHub user github-merge-queue[bot] (triggered by 
github-merge-queue[bot]).

Head commit for run:
b143a4fd72160f71ceb88fa80d790c5f8d146db6 / Ryan Zhang 
<[email protected]>
fix(notebook-migration): apply the jupyter panel's read-only setup before the 
notebook loads (#8909)

### 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)

Report URL: https://github.com/apache/texera/actions/runs/37676671004

With regards,
GitHub Actions via GitBox

Reply via email to