Repository navigation
Conversation
Contributor
Coverage Report for ./frontend
File CoverageNo changed files found. |
manzt
force-pushed
the
notebook-extensions/scope
branch
from
December 3, 2026 19:07
77e3b8b to
1e5221d
Compare
manzt
force-pushed
the
notebook-extensions/scope
branch
2 times, most recently
from
December 3, 2026 19:14
217b953 to
fc12173
Compare
manzt
marked this pull request as ready for review
December 3, 2026 19:16
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Generated Python can fail on import due to missing imports and incorrect local-schema references, while extension lifecycle failures can leave bindings attached and prevent complete cleanup.
6 open issues
Qualify extension-local schemas in fields and unions · New Import msgspec in the models() template · New Roll back earlier attachments when a later one fails · New Run all detach callbacks even if one raises · New Close every notebook and clear the extension registry on failure · New Ensure teardown failures don't skip document and backend cleanup · New
What changed in this PR
Adds Python support for notebook extensions, including generated handler interfaces, notebook-scoped records, and runtime lifecycle hooks that survive kernel restarts.
Changes:
- Generate Python models, typed calls/results, event factories, and handler dispatch.
- Integrate extension lifetimes and retained records with host sessions and snapshots.
- Add lifecycle and generation tests, documentation, and CI coverage.
| File | Description |
|---|---|
tests/_server/host/test_notebook_extensions.py |
Tests extension lifecycle and snapshots. |
packages/host-protocol/src/__tests__/python.test.ts |
Tests extension binding generation. |
packages/host-protocol/scripts/python/models.ts |
Extracts model definitions and supports dotted fields. |
packages/host-protocol/scripts/python/extension.ts |
Generates extension-specific Python bindings. |
packages/host-protocol/scripts/python/calls.ts |
Shares operation generation and resolves local types. |
packages/host-protocol/scripts/python.ts |
Writes registered extension modules. |
packages/host-protocol/README.md |
Documents Python binding support. |
marimo/_server/host/session.py |
Includes extensions in initial session events. |
marimo/_server/host/bridge.py |
Manages extension lifetimes and snapshots. |
marimo/_server/host/backend.py |
Passes runtime details to attachment callbacks. |
marimo/_server/host/api.py |
Delegates initial events to the bridge. |
marimo/_server/extensions/scope.py |
Provides retained records and runtime access. |
marimo/_server/extensions/notebook.py |
Manages installed extensions and runtime bindings. |
marimo/_server/extensions/__init__.py |
Introduces the extension package. |
marimo/_core/stream.py |
Allows event-name lookup from extension classes. |
.github/workflows/test_host_protocol.yaml |
Triggers checks for generated extension bindings. |
Review effort: Balanced
Comment on lines
+63
to
+64
| for runtime in self._runtimes: | ||
| runtime._detach() |
Comment on lines
+887
to
+888
| if extensions := self._extensions.get(notebook_id): | ||
| extensions.detach() |
manzt
force-pushed
the
notebook-extensions/scope
branch
from
December 3, 2026 19:56
fc12173 to
a201d0b
Compare
Contributor
|
React Doctor skipped this pull request — it changed no React files. Reviewed by React Doctor for commit |
1 of 6 tasks
So far the host has nowhere to keep the state of a marimo extension. These changes add `NotebookExtensions`, which opens each extension once per loaded editor notebook and hands it a `NotebookScope`.
scope.put(record, request_id=key)
scope.runtime.send(command)
The scope retains the extension's record, publishes it when it changes, and supplies it to snapshots and resets. `scope.runtime.while_ready(bind)` enters `bind` for each runtime while it is ready, and `send` reaches that runtime's kernel.
manzt
force-pushed
the
notebook-extensions/scope
branch
from
December 3, 2026 20:56
a201d0b to
94ba32b
Compare
Member
|
Could you elaborate on the role of "clear"? Why does it not send a removal event? |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


This PR adds the Python API for implementing a notebook extension. From an extension definition, marimo generates the record type, a typed
CallandResultfor each operation, and theHandlersprotocol the extension implements.The host calls
open(scope)once per extension per loaded notebook. It uses the handlers thatopenyields for requests from all clients and exitsopenwhen the notebook closes. The scope survives runtime restarts.The breakpoint extension in #12225 uses
while_readyto publish an empty breakpoint set for each new runtime andputto share subsequent edits with connected clients.