Metadata-Version: 2.4
Name: hot-notebook-patching
Version: 0.2.2
Summary: JupyterLab extension for hot patching externally modified notebooks
License: MIT
License-File: LICENSE
Classifier: Framework :: Jupyter
Classifier: Framework :: Jupyter :: JupyterLab
Classifier: Framework :: Jupyter :: JupyterLab :: 4
Classifier: Framework :: Jupyter :: JupyterLab :: Extensions
Classifier: Framework :: Jupyter :: JupyterLab :: Extensions :: Prebuilt
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Requires-Python: >=3.8
Requires-Dist: jupyterlab<5.0.0,>=4.0.0
Description-Content-Type: text/markdown

# hot-notebook-patching

[![PyPI version](https://img.shields.io/pypi/v/hot-notebook-patching)](https://pypi.org/project/hot-notebook-patching/)
[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/hot-notebook-patching)](https://pypi.org/project/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.

https://github.com/user-attachments/assets/6e287a55-41ff-48c0-a48c-f7a56d708413



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


## Installation

Requires JupyterLab 4.

```bash
pip install hot-notebook-patching
```

Then restart JupyterLab (or start it fresh) — the extension is prebuilt, no `jupyter labextension build` step needed.

To uninstall:

```bash
pip uninstall 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) · `Cmd/Ctrl+Alt+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


## Development

```bash
# Terminal 1: rebuild on every source change
source .venv/bin/activate
jlpm watch

# Terminal 2: start JupyterLab
source .venv/bin/activate
jupyter lab
```

After each rebuild, hard-refresh the browser tab (`Cmd+Shift+R`) — no server restart needed.
