JupyterLab extension for hot patching externally modified notebooks
Project description
hot-notebook-patching
A JupyterLab extension for hot patching notebooks that are edited externally — for example by an AI coding agent like Claude Code.
Instead of triggering a full notebook reload (which restarts the kernel and clears widget state), only the cells that actually changed are patched into the live notebook model.
What it does
Claude Code edits notebook.ipynb on disk
↓
Extension detects the file change
↓
Only modified cells are patched
↓
Kernel keeps running · Widget state intact · Scroll position preserved
Modified lines are highlighted with an orange left-border marker directly in the cell editor, similar to git-diff gutter decorations in VS Code.
Requirements
- JupyterLab ≥ 4.0
- Notebooks must use
nbformat4.5+ (cell IDs required for accurate diffing)
Installation
pip install hot-notebook-patching
Usage
Toolbar button
Each notebook gets a ⚡ bolt button in the toolbar. Click it to toggle auto-patch mode — the extension will watch the file for changes and patch automatically.
Commands
| Action | How |
|---|---|
| Patch once from disk | Toolbar ⚡ button (when auto-patch is off) · Shift+P inside a notebook · Command Palette → Patch Notebook From Disk |
| Toggle auto-patch | Toolbar ⚡ button · Command Palette → Toggle Auto-Patch on File Change |
What is preserved
- Running kernel
- Widget state (ipywidgets, anywidget, …)
- Cell outputs and execution counts
- Scroll position
What is updated
- Cell source code (with line-level diff indicators)
- Cell metadata
- Added / deleted / reordered cells
Conflict detection
If both you and an external tool edited the same cell since the last patch, the extension skips that cell and logs a warning — it will never silently overwrite your changes.
Auto-execute on patch
Add "hotpatch": true to a cell's metadata and the cell will be automatically executed after its source is patched:
{
"hotpatch": true
}
Development
git clone https://github.com/kolibril13/hot-notebook-patching
cd hot-notebook-patching
# Create venv and install JupyterLab
uv venv .venv
uv pip install --python .venv/bin/python jupyterlab
# Install JS dependencies and build
.venv/bin/jlpm install
.venv/bin/jlpm build:lib:prod
.venv/bin/jlpm build:labextension:dev
# Install Python package in editable mode
uv pip install --python .venv/bin/python hatchling hatch-jupyter-builder editables
uv pip install --python .venv/bin/python -e . --no-build-isolation
# Link the extension for live development
.venv/bin/jupyter labextension develop . --overwrite
# Start JupyterLab
.venv/bin/jupyter lab
For iterative development, rebuild after source changes:
.venv/bin/jlpm build:lib:prod && .venv/bin/jlpm build:labextension:dev
Then hard-refresh JupyterLab (Cmd+Shift+R / Ctrl+Shift+R).
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file hot_notebook_patching-0.1.0-py3-none-any.whl.
File metadata
- Download URL: hot_notebook_patching-0.1.0-py3-none-any.whl
- Upload date:
- Size: 25.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9eea5dc71d5c837670c1cedf5630b4ae7147f290825b1e1741231cc57ab01bf9
|
|
| MD5 |
d2b664332dcb5a0f5630867bd624ea06
|
|
| BLAKE2b-256 |
e02c07df486bd7ee3b3d2dbd19e94aaf52f871969af7c94cabcff9340219834d
|