Enrich code_mode NotebookCell with runtime status and error#9056
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
There was a problem hiding this comment.
Pull request overview
This PR extends the code_mode cell inspection surface so agents can see execution-related runtime information for each notebook cell, by wrapping document cells with kernel graph state and exposing a synthesized status plus a persisted error.
Changes:
- Added an enriched code_mode
NotebookCellwrapper that joins document cell data with runtime state (status,error). - Updated
_CellsViewto return enriched cells (including repr output showing status). - Expanded tests to snapshot the new
CellsView/enriched cell representations and validate status mapping behavior.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
marimo/_code_mode/_context.py |
Introduces enriched NotebookCell with synthesized status/error; updates _CellsView to yield enriched cells and include status in repr. |
marimo/_code_mode/__init__.py |
Re-exports the enriched NotebookCell and the new CellStatusType. |
tests/_code_mode/test_cells_view.py |
Updates repr expectations to snapshots and adds new tests for enriched cell status/error and repr. |
mscolnick
reviewed
Apr 6, 2026
mscolnick
reviewed
Apr 6, 2026
mscolnick
reviewed
Apr 6, 2026
Agents inspecting cells via code_mode had no visibility into execution state. The new `NotebookCell` wrapper joins document data with runtime state from the kernel graph, exposing `status` (a synthesized `CellStatusType`) and `error` (the last exception, persisted across status changes). Staleness is detected from code mismatch, the runtime stale flag (lazy mode), or never-run cells.
Add docstrings to the delegated properties on `NotebookCell` so they appear in `help()` output, and fix the `_CellsView` docstring which referenced a nonexistent `CellView` type instead of `NotebookCell`.
The inline comments on the `Literal` type definition aren't surfaced by `help()`, so agents calling `help(NotebookCell)` had no way to discover what each status value means. Moving the descriptions into the `status` property docstring puts them where interactive help actually displays them.
`_CellsView` methods like `values()`, `items()`, `find()`, and `grep()` returned `list`, exposing mutability on what should be a read-only view. Narrowing the return type to `Sequence` signals the intended contract. Also fixes an edge case where cells registered in the kernel graph but never executed returned `status=None` instead of `"stale"`. This happens when a cell has an impl with matching code but `run_result_status` is still `None` — the staleness check missed it because the code matched and the runtime `stale` flag wasn't set.
The protocol used `str | None` for `runtime_state` and `run_result_status`, but the canonical types `RuntimeStateType` and `RunResultStatusType` already exist in `marimo._ast.cell`. Since this protocol is internal, there's no reason to keep the types loose.
mscolnick
approved these changes
Apr 7, 2026
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.
Agents inspecting cells via code_mode had no visibility into execution state. The new
NotebookCellwrapper joins document data with runtime state from the kernel graph, exposingstatus(a synthesizedCellStatusType) anderror(the last exception, persisted across status changes). Staleness is detected from code mismatch, the runtime stale flag (lazy mode), or never-run cells.