jupyter-cell-source
A tiny JupyterLab 4 extension that exposes the live source of a notebook cell, including unsaved edits, as a JupyterLab command result.
It exists because two things are true at once:
jupyterlab-difftakesoriginalSourcefrom the caller and does not compare it with the live cell. A staleoriginalSourcesilently overwrites unsaved edits on Accept/Reject.- JupyterLab's
/api/contentsreturns the saved file, not the in-memory buffer.
This command gives a caller (for example an agent driving
jupyterlab-commands-toolkit) a reliable way to compare the live buffer with disk
before opening a diff.
Requirements
- JupyterLab 4.x
jupyterlab-commands-toolkit— providesexecute_commandand returns the command's result to the caller.
Command
research:get-cell-source
Arguments (both optional):
| Argument | Description |
|---|---|
cellId |
Id of the target cell. Defaults to the active cell. |
notebookPath |
Notebook path relative to the server root. Defaults to the current notebook. |
The visible tab is preferred. If you pass notebookPath and the current tab points
elsewhere, the first matching tab is used.
Return value:
{
"path": "analysis.ipynb",
"cellId": "4d6ee618-c7c9-42ba-b3e9-3c1ed3783a03",
"dirty": false,
"source": "# cell source, exactly as stored in the model\n..."
}
On failure: {"error": "no_notebook" | "no_model" | "cell_not_found", ...}.
dirty is the document-level flag. To decide whether a specific cell is safe to
diff, compare its source byte-for-byte with the same cell in the saved .ipynb.
Build
export PATH=/path/to/jupyter/env/bin:$PATH
jlpm install
jlpm build
The prebuilt extension is written to:
jupyter_cell_source/labextension/
Install from PyPI
pip install jupyter-cell-source
Then restart JupyterLab. If you have a conda-pypi source configured, the same wheel can be installed through conda.
Install from a local build
Copy the built extension into the JupyterLab labextensions directory:
PREFIX=$(python -c "import sys; print(sys.prefix)")
cp -r jupyter_cell_source/labextension \
"$PREFIX/share/jupyter/labextensions/jupyter-cell-source"
For a conda/mamba environment, this installs into the environment prefix. Make sure
python and jupyter come from the same environment.
Then restart JupyterLab and reload the page. Verify with:
jupyter labextension list | grep cell-source
Uninstall
rm -rf "$PREFIX/share/jupyter/labextensions/jupyter-cell-source"
Restart JupyterLab.
Notes
- Keep a single tab per notebook when driving
jupyterlab-diff: that extension resolvesnotebookPathto the first matching widget, and duplicate tabs can make it fail silently. This command prefers the visible tab, but the diff extension does not. - The command reads
cell.sharedModel.getSource(). It does not save the document.
License
MIT
Metadata
Release files for jupyter-cell-source 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| jupyter_cell_source-0.1.0.tar.gz | 54.6 kB | With provenance | Details for jupyter_cell_source-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| jupyter_cell_source-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for jupyter_cell_source-0.1.0-py3-none-any.whl |
Total release size: 65.2 kB
Release files / jupyter_cell_source-0.1.0.tar.gz
| Download URL | jupyter_cell_source-0.1.0.tar.gz |
|---|---|
| Size | 54.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
267cbe54f2789c87d292c5e34462485f0ae686984f500da9fbc13ad9d69bd12a
|
|
BLAKE2b-256 checksum How to use checksums |
4b82b90ca5e0f6edb8576b72ff33076310871658ad77d7172a3cb94ce1ed646b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 4, 2026.
Transparency logRelease files / jupyter_cell_source-0.1.0-py3-none-any.whl
| Download URL | jupyter_cell_source-0.1.0-py3-none-any.whl |
|---|---|
| Size | 10.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e2ebd6cfa09eef10bc5e21c30762bc01f04b0eb011d1c50f1600572374fee15f
|
|
BLAKE2b-256 checksum How to use checksums |
cd36bc5e9d1dd625bba7f433a6644553d2eebcc6e05a633922369363feaab4bc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 4, 2026.
Transparency logSecurity for jupyter-cell-source 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for jupyter_cell_source-0.1.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 4, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.