Skip to content

A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.

fix: remove notifications with overlapping work as new document transactions (#8900)

Myles Scolnickb31c823e624c
diff --git a/frontend/src/__mocks__/requests.ts b/frontend/src/__mocks__/requests.ts
index 085d0896a9..b822535956 100644
--- a/frontend/src/__mocks__/requests.ts
+++ b/frontend/src/__mocks__/requests.ts
@@ -17,7 +17,6 @@ export const MockRequestClient = {
sendModelValue: vi.fn().mockResolvedValue({}),
sendRename: vi.fn().mockResolvedValue({}),
sendRestart: vi.fn().mockResolvedValue({}),
- syncCellIds: vi.fn().mockResolvedValue({}),
sendDocumentTransaction: vi.fn().mockResolvedValue({}),
sendSave: vi.fn().mockResolvedValue({}),
sendCopy: vi.fn().mockResolvedValue({}),
diff --git a/frontend/src/core/cells/cells.ts b/frontend/src/core/cells/cells.ts
index 34993281b4..c3e641b397 100644
--- a/frontend/src/core/cells/cells.ts
+++ b/frontend/src/core/cells/cells.ts
@@ -589,7 +589,9 @@ const {
const serializedEditorState = editorView?.state.toJSON({
history: historyField,
});
- serializedEditorState.doc = state.cellData[cellId].code;
+ if (serializedEditorState) {
+ serializedEditorState.doc = state.cellData[cellId].code;
+ }
// release the granular atom(s) created for this cell
releaseCellAtoms(cellId);
diff --git a/frontend/src/core/cells/effects.ts b/frontend/src/core/cells/effects.ts
deleted file mode 100644
index 0893b627ed..0000000000
--- a/frontend/src/core/cells/effects.ts
+++ /dev/null
@@ -1,42 +0,0 @@
-/* Copyright 2026 Marimo. All rights reserved. */
-
-import { debounce, isEqual } from "lodash-es";
-import type { MultiColumn } from "@/utils/id-tree";
-import { kioskModeAtom } from "../mode";
-import { getRequestClient } from "../network/requests";
-import type { UpdateCellIdsRequest } from "../network/types";
-import { store } from "../state/jotai";
-import type { CellId } from "./ids";
-
-const debounceSyncCellIds = debounce((request: UpdateCellIdsRequest) => {
- return getRequestClient().syncCellIds(request);
-}, 400);
-
-export const CellEffects = {
- onCellIdsChange: (
- cellIds: MultiColumn<CellId>,
- prevCellIds: MultiColumn<CellId>,
- ) => {
- const kioskMode = store.get(kioskModeAtom);
- if (kioskMode) {
- return;
- }
- // If cellIds is empty, return early
- if (cellIds.isEmpty()) {
- return;
- }
- // If prevCellIds is empty, also return early
- // this means that the notebook was just created
- if (prevCellIds.isEmpty()) {
- return;
- }
-
- // If they are different references, send an update to the server
- if (!isEqual(cellIds.inOrderIds, prevCellIds.inOrderIds)) {
- // "name" property is not actually required
- void debounceSyncCellIds({
- cellIds: cellIds.inOrderIds,
- });
- }
- },
-};
diff --git a/frontend/src/core/edit-app.tsx b/frontend/src/core/edit-app.tsx
index 8dd6fef546..80d8ba384d 100644
--- a/frontend/src/core/edit-app.tsx
+++ b/frontend/src/core/edit-app.tsx
@@ -20,13 +20,11 @@ import { CellArray } from "../components/editor/renderers/cell-array";
import { CellsRenderer } from "../components/editor/renderers/cells-renderer";
import { useHotkey } from "../hooks/useHotkey";
import {
- cellIdsAtom,
hasCellsAtom,
notebookIsRunningAtom,
numColumnsAtom,
useCellActions,
} from "./cells/cells";
-import { CellEffects } from "./cells/effects";
import type { AppConfig, UserConfig } from "./config/config-schema";
import { RuntimeState } from "./kernel/RuntimeState";
import { getSessionId } from "./kernel/session";
@@ -35,7 +33,6 @@ import { viewStateAtom } from "./mode";
import { useRequestClient } from "./network/requests";
import { useFilename } from "./saving/filename";
import { lastSavedNotebookAtom } from "./saving/state";
-import { useJotaiEffect } from "./state/jotai";
import { useMarimoKernelConnection } from "./websocket/useMarimoKernelConnection";
interface AppProps {
@@ -58,8 +55,6 @@ export const EditApp: React.FC<AppProps> = ({
appConfig,
hideControls = false,
}) => {
- useJotaiEffect(cellIdsAtom, CellEffects.onCellIdsChange);
-
const { setCells, mergeAllColumns, collapseAllCells, expandAllCells } =
useCellActions();
const viewState = useAtomValue(viewStateAtom);
diff --git a/frontend/src/core/islands/bridge.ts b/frontend/src/core/islands/bridge.ts
index 3334e1bf00..e7e77b0d6e 100644
--- a/frontend/src/core/islands/bridge.ts
+++ b/frontend/src/core/islands/bridge.ts
@@ -162,7 +162,6 @@ export class IslandsPyodideBridge implements RunRequests, EditRequests {
saveAppConfig = throwNotImplemented;
saveCellConfig = throwNotImplemented;
sendRestart = throwNotImplemented;
- syncCellIds = throwNotImplemented;
sendDocumentTransaction = throwNotImplemented;
readCode = throwNotImplemented;
readSnippets = throwNotImplemented;
diff --git a/frontend/src/core/islands/main.ts b/frontend/src/core/islands/main.ts
index 18fe949958..a3750bcf57 100644
--- a/frontend/src/core/islands/main.ts
+++ b/frontend/src/core/islands/main.ts
@@ -113,7 +113,6 @@ export async function initialize() {
case "installing-package-alert":
case "completion-result":
case "reload":
- case "update-cell-ids":
case "focus-cell":
case "variables":
case "variable-values":
diff --git a/frontend/src/core/network/requests-lazy.ts b/frontend/src/core/network/requests-lazy.ts
index 199825fb34..25adde6585 100644
--- a/frontend/src/core/network/requests-lazy.ts
+++ b/frontend/src/core/network/requests-lazy.ts
@@ -119,7 +119,6 @@ const ACTIONS: Record<keyof AllRequests, Action> = {
downloadStorage: "waitForConnectionOpen",
// Sync operations that wait for connection
- syncCellIds: "waitForConnectionOpen",
sendDocumentTransaction: "waitForConnectionOpen",
sendCodeCompletionRequest: "waitForConnectionOpen",
};
diff --git a/frontend/src/core/network/requests-network.ts b/frontend/src/core/network/requests-network.ts
index 9b730c83d4..ab85081999 100644
--- a/frontend/src/core/network/requests-network.ts
+++ b/frontend/src/core/network/requests-network.ts
@@ -49,15 +49,6 @@ export function createNetworkRequests(): EditRequests & RunRequests {
})
.then(handleResponseReturnNull);
},
- syncCellIds: async (request) => {
- await waitForConnectionOpen();
- return getClient()
- .POST("/api/kernel/sync/cell_ids", {
- body: request,
- params: getParams(),
- })
- .then(handleResponseReturnNull);
- },
sendDocumentTransaction: async (request) => {
await waitForConnectionOpen();
return getClient()
diff --git a/frontend/src/core/network/requests-static.ts b/frontend/src/core/network/requests-static.ts
index aa16a683d8..8ac611382c 100644
--- a/frontend/src/core/network/requests-static.ts
+++ b/frontend/src/core/network/requests-static.ts
@@ -36,7 +36,6 @@ export function createStaticRequests(): EditRequests & RunRequests {
return null;
},
sendRestart: throwNotInEditMode,
- syncCellIds: throwNotInEditMode,
sendDocumentTransaction: throwNotInEditMode,
sendRun: throwNotInEditMode,
sendRunScratchpad: throwNotInEditMode,
diff --git a/frontend/src/core/network/requests-toasting.tsx b/frontend/src/core/network/requests-toasting.tsx
index 7df0cb1875..71148d765e 100644
--- a/frontend/src/core/network/requests-toasting.tsx
+++ b/frontend/src/core/network/requests-toasting.tsx
@@ -21,7 +21,6 @@ export function createErrorToastingRequests(
sendInstantiate: "Failed to instantiate",
sendFunctionRequest: "Failed to send function request",
sendRestart: "Failed to restart",
- syncCellIds: "Failed to sync cell IDs",
sendDocumentTransaction: "Failed to sync document transaction",
sendRun: "Failed to run",
sendRunScratchpad: "Failed to run scratchpad",
diff --git a/frontend/src/core/network/types.ts b/frontend/src/core/network/types.ts
index 50f5eac892..e2c257b909 100644
--- a/frontend/src/core/network/types.ts
+++ b/frontend/src/core/network/types.ts
@@ -80,7 +80,6 @@ export interface SetCellConfigRequest {
}
export type UpdateUIElementRequest = schemas["UpdateUIElementRequest"];
export type ModelRequest = schemas["ModelRequest"];
-export type UpdateCellIdsRequest = schemas["UpdateCellIdsRequest"];
export type NotebookDocumentTransactionRequest =
schemas["NotebookDocumentTransactionRequest"];
export type UpdateUserConfigRequest = schemas["UpdateUserConfigRequest"];
@@ -140,7 +139,6 @@ export interface EditRequests {
saveAppConfig: (request: SaveAppConfigurationRequest) => Promise<null>;
saveCellConfig: (request: SetCellConfigRequest) => Promise<null>;
sendRestart: () => Promise<null>;
- syncCellIds: (request: UpdateCellIdsRequest) => Promise<null>;
sendDocumentTransaction: (
request: NotebookDocumentTransactionRequest,
) => Promise<null>;
diff --git a/frontend/src/core/wasm/bridge.ts b/frontend/src/core/wasm/bridge.ts
index 7334ab8df5..9cd8052463 100644
--- a/frontend/src/core/wasm/bridge.ts
+++ b/frontend/src/core/wasm/bridge.ts
@@ -558,7 +558,6 @@ export class PyodideBridge implements RunRequests, EditRequests {
return null;
};
- syncCellIds = () => Promise.resolve(null);
sendDocumentTransaction = () => Promise.resolve(null);
addPackage: EditRequests["addPackage"] = async (request) => {
diff --git a/frontend/src/core/websocket/useMarimoKernelConnection.tsx b/frontend/src/core/websocket/useMarimoKernelConnection.tsx
index 709b52b768..6c6151ae46 100644
--- a/frontend/src/core/websocket/useMarimoKernelConnection.tsx
+++ b/frontend/src/core/websocket/useMarimoKernelConnection.tsx
@@ -97,7 +97,7 @@ export function useMarimoKernelConnection(opts: {
const { autoInstantiate, sessionId, setCells } = opts;
const { showBoundary } = useErrorBoundary();
- const { handleCellMessage, setCellIds } = useCellActions();
+ const { handleCellMessage } = useCellActions();
const actionsWithoutMiddleware = useCellActions({ skipMiddleware: true });
const handleDocumentTransaction = (
@@ -328,9 +328,6 @@ export function useMarimoKernelConnection(opts: {
case "focus-cell":
focusAndScrollCellOutputIntoView(msg.data.cell_id);
return;
- case "update-cell-ids":
- setCellIds({ cellIds: msg.data.cell_ids });
- return;
case "notebook-document-transaction":
handleDocumentTransaction(msg.data.transaction);
return;
diff --git a/marimo/_cli/development/commands.py b/marimo/_cli/development/commands.py
index 82e2a1ccec..1d221e3b92 100644
--- a/marimo/_cli/development/commands.py
+++ b/marimo/_cli/development/commands.py
@@ -311,7 +311,6 @@ def _generate_server_api_schema() -> dict[str, Any]:
notifications.QueryParamsAppendNotification,
notifications.QueryParamsDeleteNotification,
notifications.QueryParamsClearNotification,
- notifications.UpdateCellIdsNotification,
notifications.FocusCellNotification,
notifications.NotificationMessage,
# ai
@@ -433,7 +432,6 @@ def _generate_server_api_schema() -> dict[str, Any]:
models.SuccessResponse,
models.SuccessResponse,
models.UpdateCellConfigRequest,
- models.UpdateCellIdsRequest,
models.NotebookDocumentTransactionRequest,
models.FocusCellRequest,
models.UpdateUIElementValuesRequest,
diff --git a/marimo/_code_mode/_context.py b/marimo/_code_mode/_context.py
index d9679a750b..638f7dce34 100644
--- a/marimo/_code_mode/_context.py
+++ b/marimo/_code_mode/_context.py
@@ -940,8 +940,7 @@ class AsyncCodeModeContext:
self._kernel.cell_metadata[cell_id] = CellMetadata(config=cfg)
# Build document transaction ops from the plan and broadcast
- # a single NotebookDocumentTransactionNotification instead of
- # the legacy UpdateCellCodes / UpdateCellIds notifications.
+ # a single NotebookDocumentTransactionNotification.
doc_ops = _plan_to_document_ops(
plan=plan,
existing_ids=existing_id_set,
diff --git a/marimo/_internal/notifications.py b/marimo/_internal/notifications.py
index 5afdce7838..e8aae64ee3 100644
--- a/marimo/_internal/notifications.py
+++ b/marimo/_internal/notifications.py
@@ -39,7 +39,6 @@ from marimo._messaging.notification import (
SQLTablePreviewNotification,
StartupLogsNotification,
UIElementMessageNotification,
- UpdateCellIdsNotification,
ValidateSQLResultNotification,
VariableDeclarationNotification,
VariablesNotification,
@@ -85,7 +84,6 @@ __all__ = [
"SecretKeysResultNotification",
"StartupLogsNotification",
"UIElementMessageNotification",
- "UpdateCellIdsNotification",
"VariableDeclarationNotification",
"VariableValue",
"VariableValuesNotification",
diff --git a/marimo/_messaging/notification.py b/marimo/_messaging/notification.py
index 3aa1fe3457..ee15f1e572 100644
--- a/marimo/_messaging/notification.py
+++ b/marimo/_messaging/notification.py
@@ -788,17 +788,6 @@ class CacheInfoNotification(Notification, tag="cache-info"):
disk_total: int
-class UpdateCellIdsNotification(Notification, tag="update-cell-ids"):
- """Updates cell ordering in notebook.
-
- Attributes:
- cell_ids: Complete ordered list of cell IDs.
- """
-
- name: ClassVar[str] = "update-cell-ids"
- cell_ids: list[CellId_t]
-
-
class NotebookDocumentTransactionNotification(
Notification, tag="notebook-document-transaction"
):
@@ -861,7 +850,6 @@ NotificationMessage = Union[
CacheInfoNotification,
# Kiosk
FocusCellNotification,
- UpdateCellIdsNotification,
# Document
NotebookDocumentTransactionNotification,
]
diff --git a/marimo/_runtime/marimo_pdb.py b/marimo/_runtime/marimo_pdb.py
index 1251e510dc..721e995d82 100644
--- a/marimo/_runtime/marimo_pdb.py
+++ b/marimo/_runtime/marimo_pdb.py
@@ -36,7 +36,7 @@ def try_restart() -> bool:
if ctx.cell_id is None or ctx.cell_id not in graph.cells:
return False
- # This runs the request and also runs UpdateCellCodes
+ # This runs the request and queues the cell for execution
ctx._kernel.enqueue_control_request(
ExecuteCellsCommand(
cell_ids=[ctx.cell_id],
diff --git a/marimo/_runtime/runtime.py b/marimo/_runtime/runtime.py
index 4ea3efce22..c330942a42 100644
--- a/marimo/_runtime/runtime.py
+++ b/marimo/_runtime/runtime.py
@@ -63,6 +63,7 @@ from marimo._messaging.errors import (
MarimoSyntaxError,
UnknownError,
)
+from marimo._messaging.notebook.changes import ReorderCells, Transaction
from marimo._messaging.notebook.document import (
NotebookDocument,
notebook_document_context,
@@ -77,6 +78,7 @@ from marimo._messaging.notification import (
HumanReadableStatus,
InstallingPackageAlertNotification,
MissingPackageAlertNotification,
+ NotebookDocumentTransactionNotification,
PackageStatusType,
RemoveUIElementsNotification,
SecretKeysResultNotification,
@@ -87,7 +89,6 @@ from marimo._messaging.notification import (
SQLTablePreviewNotification,
StorageDownloadReadyNotification,
StorageEntriesNotification,
- UpdateCellIdsNotification,
ValidateSQLResultNotification,
VariableDeclarationNotification,
VariablesNotification,
@@ -2153,7 +2154,12 @@ class Kernel:
return
broadcast_notification(
- UpdateCellIdsNotification(cell_ids=list(request.cell_ids))
+ NotebookDocumentTransactionNotification(
+ transaction=Transaction(
+ changes=(ReorderCells(cell_ids=tuple(request.cell_ids)),),
+ source="kernel",
+ )
+ )
)
# Handle markdown cells specially during kernel-ready initialization
diff --git a/marimo/_schemas/generated/notifications.yaml b/marimo/_schemas/generated/notifications.yaml
index b33410532e..de94f429e3 100644
--- a/marimo/_schemas/generated/notifications.yaml
+++ b/marimo/_schemas/generated/notifications.yaml
@@ -1521,22 +1521,6 @@ components:
- msg
title: UnknownError
type: object
- UpdateCellIdsNotification:
- description: "Updates cell ordering in notebook.\n\nAttributes:\n cell_ids:\
- \ Complete ordered list of cell IDs."
- properties:
- cell_ids:
- items:
- type: string
- type: array
- op:
- enum:
- - update-cell-ids
- required:
- - op
- - cell_ids
- title: UpdateCellIdsNotification
- type: object
ValidateSQLResultNotification:
description: "SQL query validation result.\n\nAttributes:\n request_id: Request\
\ ID this responds to.\n parse_result: SQL parsing result.\n validate_result:\
diff --git a/marimo/_schemas/generated/session.yaml b/marimo/_schemas/generated/session.yaml
index 2670a1e866..82fd56459d 100644
--- a/marimo/_schemas/generated/session.yaml
+++ b/marimo/_schemas/generated/session.yaml
@@ -98,6 +98,8 @@ components:
- application/vnd.marimo+mimebundle
- application/vnd.vega.v5+json
- application/vnd.vegalite.v5+json
+ - application/vnd.vega.v6+json
+ - application/vnd.vegalite.v6+json
- application/vnd.jupyter.widget-view+json
- image/png
- image/svg+xml
@@ -110,6 +112,7 @@ components:
- video/mpeg
- text/html
- text/plain
+ - text/password
- text/markdown
- text/latex
- text/csv
@@ -138,6 +141,8 @@ components:
- application/vnd.marimo+mimebundle
- application/vnd.vega.v5+json
- application/vnd.vegalite.v5+json
+ - application/vnd.vega.v6+json
+ - application/vnd.vegalite.v6+json
- application/vnd.jupyter.widget-view+json
- image/png
- image/svg+xml
@@ -150,6 +155,7 @@ components:
- video/mpeg
- text/html
- text/plain
+ - text/password
- text/markdown
- text/latex
- text/csv
diff --git a/marimo/_server/api/endpoints/editing.py b/marimo/_server/api/endpoints/editing.py
index 79ebac6473..e07e7d3cc4 100644
--- a/marimo/_server/api/endpoints/editing.py
+++ b/marimo/_server/api/endpoints/editing.py
@@ -6,10 +6,7 @@ from typing import TYPE_CHECKING
from starlette.authentication import requires
from marimo._cli.sandbox import SandboxMode
-from marimo._messaging.notification import (
- FocusCellNotification,
- UpdateCellIdsNotification,
-)
+from marimo._messaging.notification import FocusCellNotification
from marimo._server.api.deps import AppState
from marimo._server.api.utils import (
dispatch_control_request,
@@ -28,10 +25,8 @@ from marimo._server.models.models import (
StdinRequest,
SuccessResponse,
UpdateCellConfigRequest,
- UpdateCellIdsRequest,
)
from marimo._server.router import APIRouter
-from marimo._types.ids import ConsumerId
from marimo._utils.formatter import DefaultFormatter
if TYPE_CHECKING:
@@ -93,39 +88,6 @@ async def delete_cell(request: Request) -> BaseResponse:
return await dispatch_control_request(request, DeleteCellRequest)
[email protected]("/sync/cell_ids")
-@requires("edit")
-async def sync_cell_ids(request: Request) -> BaseResponse:
- """
- parameters:
- - in: header
- name: Marimo-Session-Id
- schema:
- type: string
- required: true
- requestBody:
- content:
- application/json:
- schema:
- $ref: "#/components/schemas/UpdateCellIdsRequest"
- responses:
- 200:
- description: Sync cell ids
- content:
- application/json:
- schema:
- $ref: "#/components/schemas/SuccessResponse"
- """
- app_state = AppState(request)
- body = await parse_request(request, cls=UpdateCellIdsRequest)
- session_id = app_state.require_current_session_id()
- app_state.require_current_session().notify(
- UpdateCellIdsNotification(cell_ids=body.cell_ids),
- from_consumer_id=ConsumerId(session_id),
- )
- return SuccessResponse()
-
-
@router.post("/focus_cell")
@requires("edit")
async def focus_cell(request: Request) -> BaseResponse:
diff --git a/marimo/_server/export/_pdf_raster.py b/marimo/_server/export/_pdf_raster.py
index 21b9d13339..ebba894f0d 100644
--- a/marimo/_server/export/_pdf_raster.py
+++ b/marimo/_server/export/_pdf_raster.py
@@ -224,18 +224,12 @@ def _collect_raster_targets(session_view: SessionView) -> list[_RasterTarget]:
def _sort_targets_by_notebook_order(
- session_view: SessionView,
+ cell_ids: list[CellId_t],
targets: list[_RasterTarget],
) -> list[_RasterTarget]:
"""Sort targets in notebook order so capture sequencing is deterministic."""
- if session_view.cell_ids is None:
- return targets
-
- order = {
- cell_id: index
- for index, cell_id in enumerate(session_view.cell_ids.cell_ids)
- }
+ order = {cell_id: index for index, cell_id in enumerate(cell_ids)}
fallback_index = len(order)
return sorted(
targets,
@@ -438,7 +432,9 @@ async def collect_pdf_png_fallbacks(
LOGGER.debug("Raster capture skipped: no eligible outputs found.")
return {}
- targets = _sort_targets_by_notebook_order(session_view, targets)
+ targets = _sort_targets_by_notebook_order(
+ list(app.cell_manager.cell_ids()), targets
+ )
server_mode = options.server_mode.lower()
if server_mode not in {"static", "live"}:
LOGGER.warning(
diff --git a/marimo/_server/models/models.py b/marimo/_server/models/models.py
index 3dc10f9191..67e4592a8e 100644
--- a/marimo/_server/models/models.py
+++ b/marimo/_server/models/models.py
@@ -249,10 +249,6 @@ class RenameNotebookRequest(msgspec.Struct, rename="camel"):
filename: str
-class UpdateCellIdsRequest(msgspec.Struct, rename="camel"):
- cell_ids: list[CellId_t]
-
-
class NotebookDocumentTransactionRequest(msgspec.Struct, rename="camel"):
changes: list[DocumentChange]
diff --git a/marimo/_session/file_change_handler.py b/marimo/_session/file_change_handler.py
index c1ad37181c..6de2ba2f53 100644
--- a/marimo/_session/file_change_handler.py
+++ b/marimo/_session/file_change_handler.py
@@ -152,7 +152,7 @@ class EditModeReloadStrategy(ReloadStrategy):
SyncGraphCommand(
cells=dict(zip(cell_ids, codes)),
run_ids=changed_not_deleted,
- delete_ids=list(deleted),
+ delete_ids=sorted(deleted),
),
from_consumer_id=None,
)
@@ -163,7 +163,7 @@ class EditModeReloadStrategy(ReloadStrategy):
SyncGraphCommand(
cells=dict(zip(cell_ids, codes)),
run_ids=[],
- delete_ids=list(deleted),
+ delete_ids=sorted(deleted),
),
from_consumer_id=None,
)
diff --git a/marimo/_session/state/serialize.py b/marimo/_session/state/serialize.py
index 13faece967..b4d3e8240e 100644
--- a/marimo/_session/state/serialize.py
+++ b/marimo/_session/state/serialize.py
@@ -91,17 +91,7 @@ def serialize_session_view(
cells: list[Cell] = []
if cell_ids is None:
- if view.cell_ids is not None:
- cell_ids = view.cell_ids.cell_ids
- else:
- # TODO: This is a problem for exporting to HTML, but not for caching the session view for replays. Something seems off.
- LOGGER.debug(
- "When serializing session view, the notebook-order of cells was "
- "not known. This may cause issues when attempting to "
- "reconstruct the notebook state from the serialized session "
- "view."
- )
- cell_ids = view.cell_notifications.keys()
+ cell_ids = view.cell_notifications.keys()
for cell_id in cell_ids:
cell_notif = view.cell_notifications.get(cell_id)
diff --git a/marimo/_session/state/session_view.py b/marimo/_session/state/session_view.py
index 9dc2a3f502..fe06b40f29 100644
--- a/marimo/_session/state/session_view.py
+++ b/marimo/_session/state/session_view.py
@@ -26,7 +26,6 @@ from marimo._messaging.notification import (
StartupLogsNotification,
StorageNamespacesNotification,
UIElementMessageNotification,
- UpdateCellIdsNotification,
VariablesNotification,
VariableValue,
VariableValuesNotification,
@@ -132,7 +131,6 @@ class SessionView:
"""A representation of a session state for replay and serialization.
Of note, a SessionView stores:
- * the last-seen notebook-order of Cell IDs
* a mapping from cell IDs to their last seen notification of interest,
such as an output, status, or console output
* various other state needed for replay
@@ -143,8 +141,6 @@ class SessionView:
"""
def __init__(self) -> None:
- # Last seen notebook-order of cell IDs
- self.cell_ids: Optional[UpdateCellIdsNotification] = None
# A mapping from cell (IDs) to their last seen notification
self.cell_notifications: dict[CellId_t, CellNotification] = {}
# The most recent datasets notification.
@@ -387,9 +383,6 @@ class SessionView:
sql_table_list_preview.tables,
)
- elif isinstance(notification, UpdateCellIdsNotification):
- self.cell_ids = notification
-
elif isinstance(notification, UIElementMessageNotification):
# TODO: Consider reducing to a single message per element
# (similar to ModelReplayState) instead of keeping the full
@@ -536,8 +529,6 @@ class SessionView:
@property
def notifications(self) -> list[NotificationMessage]:
all_notifications: list[NotificationMessage] = []
- if self.cell_ids:
- all_notifications.append(self.cell_ids)
if self.variable_notifications.variables:
all_notifications.append(self.variable_notifications)
if self.variable_values:
diff --git a/packages/openapi/api.yaml b/packages/openapi/api.yaml
index 53c68bb6a2..d93d404b21 100644
--- a/packages/openapi/api.yaml
+++ b/packages/openapi/api.yaml
@@ -2571,7 +2571,6 @@ components:
- $ref: '#/components/schemas/CacheClearedNotification'
- $ref: '#/components/schemas/CacheInfoNotification'
- $ref: '#/components/schemas/FocusCellNotification'
- - $ref: '#/components/schemas/UpdateCellIdsNotification'
- $ref: '#/components/schemas/NotebookDocumentTransactionNotification'
discriminator:
mapping:
@@ -2610,7 +2609,6 @@ components:
storage-download-ready: '#/components/schemas/StorageDownloadReadyNotification'
storage-entries: '#/components/schemas/StorageEntriesNotification'
storage-namespaces: '#/components/schemas/StorageNamespacesNotification'
- update-cell-ids: '#/components/schemas/UpdateCellIdsNotification'
validate-sql-result: '#/components/schemas/ValidateSQLResultNotification'
variable-values: '#/components/schemas/VariableValuesNotification'
variables: '#/components/schemas/VariablesNotification'
@@ -5100,32 +5098,6 @@ components:
- configs
title: UpdateCellConfigRequest
type: object
- UpdateCellIdsNotification:
- description: "Updates cell ordering in notebook.\n\n Attributes:\n \
- \ cell_ids: Complete ordered list of cell IDs."
- properties:
- cell_ids:
- items:
- $ref: '#/components/schemas/CellId'
- type: array
- op:
- enum:
- - update-cell-ids
- required:
- - op
- - cell_ids
- title: UpdateCellIdsNotification
- type: object
- UpdateCellIdsRequest:
- properties:
- cellIds:
- items:
- type: string
- type: array
- required:
- - cellIds
- title: UpdateCellIdsRequest
- type: object
UpdateCellOutputsRequest:
properties:
cellIdsToOutput:
@@ -6642,26 +6614,6 @@ paths:
schema:
$ref: '#/components/schemas/SuccessResponse'
description: Send input to the stdin stream
- /api/kernel/sync/cell_ids:
- post:
- parameters:
- - in: header
- name: Marimo-Session-Id
- required: true
- schema:
- type: string
- requestBody:
- content:
- application/json:
- schema:
- $ref: '#/components/schemas/UpdateCellIdsRequest'
- responses:
- 200:
- content:
- application/json:
- schema:
- $ref: '#/components/schemas/SuccessResponse'
- description: Sync cell ids
/api/kernel/takeover:
post:
parameters:
diff --git a/packages/openapi/src/api.ts b/packages/openapi/src/api.ts
index c579ed2a23..9c0c85cc57 100644
--- a/packages/openapi/src/api.ts
+++ b/packages/openapi/src/api.ts
@@ -2526,47 +2526,6 @@ export interface paths {
patch?: never;
trace?: never;
};
- "/api/kernel/sync/cell_ids": {
- parameters: {
- query?: never;
- header?: never;
- path?: never;
- cookie?: never;
- };
- get?: never;
- put?: never;
- post: {
- parameters: {
- query?: never;
- header: {
- "Marimo-Session-Id": string;
- };
- path?: never;
- cookie?: never;
- };
- requestBody?: {
- content: {
- "application/json": components["schemas"]["UpdateCellIdsRequest"];
- };
- };
- responses: {
- /** @description Sync cell ids */
- 200: {
- headers: {
- [name: string]: unknown;
- };
- content: {
- "application/json": components["schemas"]["SuccessResponse"];
- };
- };
- };
- };
- delete?: never;
- options?: never;
- head?: never;
- patch?: never;
- trace?: never;
- };
"/api/kernel/takeover": {
parameters: {
query?: never;
@@ -4886,7 +4845,6 @@ export interface components {
| components["schemas"]["CacheClearedNotification"]
| components["schemas"]["CacheInfoNotification"]
| components["schemas"]["FocusCellNotification"]
- | components["schemas"]["UpdateCellIdsNotification"]
| components["schemas"]["NotebookDocumentTransactionNotification"];
};
/**
@@ -6428,22 +6386,6 @@ export interface components {
[key: string]: Record<string, any>;
};
};
- /**
- * UpdateCellIdsNotification
- * @description Updates cell ordering in notebook.
- *
- * Attributes:
- * cell_ids: Complete ordered list of cell IDs.
- */
- UpdateCellIdsNotification: {
- cell_ids: components["schemas"]["CellId"][];
- /** @enum {unknown} */
- op: "update-cell-ids";
- };
- /** UpdateCellIdsRequest */
- UpdateCellIdsRequest: {
- cellIds: string[];
- };
/** UpdateCellOutputsRequest */
UpdateCellOutputsRequest: {
cellIdsToOutput: {
diff --git a/packages/openapi/src/session.ts b/packages/openapi/src/session.ts
index 5163351569..d08655759d 100644
--- a/packages/openapi/src/session.ts
+++ b/packages/openapi/src/session.ts
@@ -52,6 +52,8 @@ export interface components {
| "application/vnd.marimo+mimebundle"
| "application/vnd.vega.v5+json"
| "application/vnd.vegalite.v5+json"
+ | "application/vnd.vega.v6+json"
+ | "application/vnd.vegalite.v6+json"
| "application/vnd.jupyter.widget-view+json"
| "image/png"
| "image/svg+xml"
@@ -64,6 +66,7 @@ export interface components {
| "video/mpeg"
| "text/html"
| "text/plain"
+ | "text/password"
| "text/markdown"
| "text/latex"
| "text/csv";
@@ -81,6 +84,8 @@ export interface components {
| "application/vnd.marimo+mimebundle"
| "application/vnd.vega.v5+json"
| "application/vnd.vegalite.v5+json"
+ | "application/vnd.vega.v6+json"
+ | "application/vnd.vegalite.v6+json"
| "application/vnd.jupyter.widget-view+json"
| "image/png"
| "image/svg+xml"
@@ -93,6 +98,7 @@ export interface components {
| "video/mpeg"
| "text/html"
| "text/plain"
+ | "text/password"
| "text/markdown"
| "text/latex"
| "text/csv"
diff --git a/scripts/generate_schemas.py b/scripts/generate_schemas.py
index dbea1ddaa7..3c54ab9fb0 100755
--- a/scripts/generate_schemas.py
+++ b/scripts/generate_schemas.py
@@ -64,7 +64,6 @@ with app.setup:
o.SecretKeysResultNotification,
o.CacheClearedNotification,
o.CacheInfoNotification,
- o.UpdateCellIdsNotification,
]
diff --git a/tests/_ai/tools/tools/test_errors_tool.py b/tests/_ai/tools/tools/test_errors_tool.py
index 88f48bcead..d87e0f2f19 100644
--- a/tests/_ai/tools/tools/test_errors_tool.py
+++ b/tests/_ai/tools/tools/test_errors_tool.py
@@ -32,15 +32,9 @@ class MockConsoleOutput:
data: object
-@dataclass
-class MockUpdateCellIdsRequest:
- cell_ids: list[str]
-
-
@dataclass
class MockSessionView:
cell_notifications: dict | None = None
- cell_ids: MockUpdateCellIdsRequest | None = None
def __post_init__(self) -> None:
if self.cell_notifications is None:
diff --git a/tests/_internal/snapshots/internal_api.txt b/tests/_internal/snapshots/internal_api.txt
index 08bea94058..c23a88f91c 100644
--- a/tests/_internal/snapshots/internal_api.txt
+++ b/tests/_internal/snapshots/internal_api.txt
@@ -94,7 +94,6 @@ notifications
SecretKeysResultNotification
StartupLogsNotification
UIElementMessageNotification
- UpdateCellIdsNotification
ValidateSQLResultNotification
VariableDeclarationNotification
VariableValue
diff --git a/tests/_server/api/endpoints/test_kiosk.py b/tests/_server/api/endpoints/test_kiosk.py
index 5787a94890..5961f84ba8 100644
--- a/tests/_server/api/endpoints/test_kiosk.py
+++ b/tests/_server/api/endpoints/test_kiosk.py
@@ -37,46 +37,24 @@ async def test_connect_kiosk_with_session(client: TestClient) -> None:
data, create_response({"kiosk": True, "resumed": True})
)
- # Send sync cell_ids
+ # Send document transaction to reorder cells
response = client.post(
- "/api/kernel/sync/cell_ids",
- headers=HEADERS,
- json={"cell_ids": ["cell-123"]},
- )
- assert response.status_code == 200, response.text
-
- # Assert kiosk session received the sync cell_ids
- data = other_websocket.receive_json()
- assert data == {
- "op": "update-cell-ids",
- "data": {"cell_ids": ["cell-123"]},
- }
-
- # Send run cell
- response = client.post(
- "/api/kernel/run",
+ "/api/document/transaction",
headers=HEADERS,
json={
- "cell_ids": ["cell-1", "cell-2"],
- "codes": [
- "print('Hello, cell-1')",
- "print('Hello, cell-2')",
+ "changes": [
+ {
+ "type": "reorder-cells",
+ "cellIds": ["cell-123"],
+ }
],
},
)
+ assert response.status_code == 200, response.text
- # Assert kiosk session received the updated cell codes
+ # Assert kiosk session received the document transaction
data = other_websocket.receive_json()
- assert data == {
- "op": "update-cell-codes",
- "data": {
- "cell_ids": ["cell-1", "cell-2"],
- "codes": [
- "print('Hello, cell-1')",
- "print('Hello, cell-2')",
- ],
- },
- }
+ assert data["op"] == "notebook-document-transaction"
# Send run single cell
response = client.post(
@@ -88,17 +66,7 @@ async def test_connect_kiosk_with_session(client: TestClient) -> None:
},
)
- # Assert kiosk session received the updated cell codes
- data = _receive_until("update-cell-codes", other_websocket)
- assert data == {
- "op": "update-cell-codes",
- "data": {
- "cell_ids": ["cell-3"],
- "codes": ["print('Hello, cell-3')"],
- "code_is_stale": False,
- },
- }
- # And a focused cell
+ # Assert kiosk session received a focused cell notification
data = _receive_until("focus-cell", other_websocket)
assert data == {
"op": "focus-cell",
diff --git a/tests/_server/api/endpoints/test_ws.py b/tests/_server/api/endpoints/test_ws.py
index bd809441c3..a6eb1f08be 100644
--- a/tests/_server/api/endpoints/test_ws.py
+++ b/tests/_server/api/endpoints/test_ws.py
@@ -302,7 +302,7 @@ async def test_connects_to_existing_session_with_same_file(
# This can/may change if implementation changes, but this is a snapshot to
# make sure it doesn't change when we don't expect it to
assert len(messages1) == 14
- assert messages1[0]["op"] == "update-cell-ids"
+ assert messages1[0]["op"] == "notebook-document-transaction"
# Connect second client - should connect to same session
with client.websocket_connect(ws_2) as websocket2:
@@ -315,11 +315,11 @@ async def test_connects_to_existing_session_with_same_file(
assert_parse_ready_response(data2)
assert data2["data"]["resumed"] is True
- messages2 = flush_messages(websocket2, at_least=4)
+ messages2 = flush_messages(websocket2, at_least=3)
# This can/may change if implementation changes, but this is a snapshot to
# make sure it doesn't change when we don't expect it to
- assert len(messages2) == 4
- assert messages2[0]["op"] == "update-cell-ids"
+ assert len(messages2) == 3
+ assert messages2[0]["op"] == "variables"
def flush_messages(
diff --git a/tests/_server/export/test_pdf_raster.py b/tests/_server/export/test_pdf_raster.py
index 54d8465a58..ae1b24a93a 100644
--- a/tests/_server/export/test_pdf_raster.py
+++ b/tests/_server/export/test_pdf_raster.py
@@ -6,10 +6,7 @@ from unittest.mock import AsyncMock, patch
from marimo._ast.app import App, InternalApp
from marimo._messaging.cell_output import CellChannel, CellOutput
-from marimo._messaging.notification import (
- CellNotification,
- UpdateCellIdsNotification,
-)
+from marimo._messaging.notification import CellNotification
from marimo._server.export import _pdf_raster
from marimo._session.state.session_view import SessionView
@@ -102,8 +99,8 @@ def test_collect_pdf_png_fallbacks_mixed_targets_use_static_by_default() -> (
"text/plain": "vega",
},
)
- session_view.cell_ids = UpdateCellIdsNotification(cell_ids=["3", "2", "1"])
app = InternalApp(App())
+ app.cell_manager.cell_ids = lambda: ["3", "2", "1"] # type: ignore[assignment]
live_capture_mock = AsyncMock(
side_effect=AssertionError(
"live capture should not run for default static mode"
@@ -197,8 +194,8 @@ def test_collect_pdf_png_fallbacks_static_only_uses_static_capture() -> None:
"text/plain": "vega",
},
)
- session_view.cell_ids = UpdateCellIdsNotification(cell_ids=["1"])
app = InternalApp(App())
+ app.cell_manager.cell_ids = lambda: ["1"] # type: ignore[assignment]
class _FakeServer:
base_url = "http://127.0.0.1:1234"
@@ -285,8 +282,8 @@ def test_collect_pdf_png_fallbacks_live_mode_uses_live_capture() -> None:
mimetype="text/html",
data="<marimo-slider></marimo-slider>",
)
- session_view.cell_ids = UpdateCellIdsNotification(cell_ids=["2", "1"])
app = InternalApp(App())
+ app.cell_manager.cell_ids = lambda: ["2", "1"] # type: ignore[assignment]
static_capture_mock = AsyncMock(
side_effect=AssertionError(
diff --git a/tests/_session/state/test_session_view.py b/tests/_session/state/test_session_view.py
index dadb559cff..2994f51727 100644
--- a/tests/_session/state/test_session_view.py
+++ b/tests/_session/state/test_session_view.py
@@ -31,7 +31,6 @@ from marimo._messaging.notification import (
SQLTableListPreviewNotification,
SQLTablePreviewNotification,
StartupLogsNotification,
- UpdateCellIdsNotification,
VariableDeclarationNotification,
VariablesNotification,
VariableValue,
@@ -67,19 +66,6 @@ initial_status: RuntimeStateType = "running"
updated_status: RuntimeStateType = "running"
-def test_cell_ids(session_view: SessionView) -> None:
- assert session_view.cell_ids is None
-
- session_view.add_notification(
- UpdateCellIdsNotification(
- cell_ids=[cell_id],
- )
- )
- operation = session_view.notifications[0]
- assert isinstance(operation, UpdateCellIdsNotification)
- assert operation.cell_ids == [cell_id]
-
-
def test_session_view_cell_notification(session_view: SessionView) -> None:
# Create initial CellNotification
initial_cell_notification = CellNotification(