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.
Python artificial-intelligencedagdata-sciencedata-visualizationdataflowdeveloper-toolsmachine-learningnotebookspipelinepythonreactivesqlweb-app
fix: jump to running notebook cells only (#9707)
Kyle Goodrickc84817acae5a
diff --git a/frontend/src/core/cells/__tests__/actions.test.ts b/frontend/src/core/cells/__tests__/actions.test.tsnew file mode 100644index 0000000000..54e579727a--- /dev/null+++ b/frontend/src/core/cells/__tests__/actions.test.ts@@ -0,0 +1,48 @@+/* Copyright 2026 Marimo. All rights reserved. */++import { beforeEach, describe, expect, it, vi } from "vitest";+import { MockNotebook } from "@/__mocks__/notebook";+import { scrollAndHighlightCell } from "@/components/editor/links/cell-link";+import { notebookAtom } from "@/core/cells/cells";+import type { CellId } from "@/core/cells/ids";+import { createCellRuntimeState } from "@/core/cells/types";+import { store } from "@/core/state/jotai";+import { notebookScrollToRunning } from "../actions";++vi.mock("@/components/editor/links/cell-link", () => ({+ scrollAndHighlightCell: vi.fn(),+}));++describe("notebookScrollToRunning", () => {+ beforeEach(() => {+ vi.clearAllMocks();+ store.set(notebookAtom, MockNotebook.notebookState({ cellData: {} }));+ });++ it("scrolls to the first running cell in notebook order", () => {+ const runtimeOnlyCellId = "runtime-only" as CellId;+ const idleCellId = "idle-cell" as CellId;+ const runningCellId = "running-cell" as CellId;++ const notebook = MockNotebook.notebookState({+ cellData: {+ [idleCellId]: {},+ [runningCellId]: {},+ },+ cellRuntime: {+ [idleCellId]: { status: "idle" },+ [runningCellId]: { status: "running" },+ },+ });+ notebook.cellRuntime = {+ [runtimeOnlyCellId]: createCellRuntimeState({ status: "running" }),+ ...notebook.cellRuntime,+ };+ store.set(notebookAtom, notebook);++ notebookScrollToRunning();++ expect(scrollAndHighlightCell).toHaveBeenCalledOnce();+ expect(scrollAndHighlightCell).toHaveBeenCalledWith(runningCellId, "focus");+ });+});diff --git a/frontend/src/core/cells/actions.ts b/frontend/src/core/cells/actions.tsindex a2d2ed9a28..c5c3cee900 100644--- a/frontend/src/core/cells/actions.ts+++ b/frontend/src/core/cells/actions.ts@@ -1,7 +1,6 @@/* Copyright 2026 Marimo. All rights reserved. */import { scrollAndHighlightCell } from "@/components/editor/links/cell-link";-import { Objects } from "@/utils/objects";import { store } from "../state/jotai";import { notebookAtom } from "./cells";@@ -10,12 +9,12 @@ import { notebookAtom } from "./cells";*/export function notebookScrollToRunning() {// find cell that is currently in "running" state- const { cellRuntime } = store.get(notebookAtom);- const cell = Objects.entries(cellRuntime).find(- ([cellid, runtimestate]) => runtimestate.status === "running",+ const { cellIds, cellRuntime } = store.get(notebookAtom);+ const cellId = cellIds.inOrderIds.find(+ (id) => cellRuntime[id]?.status === "running",);- if (!cell) {+ if (!cellId) {return;}- scrollAndHighlightCell(cell[0], "focus");+ scrollAndHighlightCell(cellId, "focus");}