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: Prevent matching by cell_id (#7072)

Dylan Madisettif8d5df9d0907
diff --git a/frontend/src/core/cells/__tests__/session.test.ts b/frontend/src/core/cells/__tests__/session.test.ts
index 19801acc98..5a49178826 100644
--- a/frontend/src/core/cells/__tests__/session.test.ts
+++ b/frontend/src/core/cells/__tests__/session.test.ts
@@ -397,14 +397,8 @@ describe("notebookStateFromSession", () => {
},
serializedEditorState: null,
});
- expect(result.cellRuntime[CELL_1].consoleOutputs).toEqual([
- {
- channel: "stdout",
- data: "output",
- mimetype: "text/plain",
- timestamp: 0,
- },
- ]);
+ // Null result means no output.
+ expect(result.cellRuntime[CELL_1].consoleOutputs).toEqual([]);
});
it("creates state when cell order differs but same cells", () => {
diff --git a/frontend/src/core/cells/session.ts b/frontend/src/core/cells/session.ts
index 985087d780..ae13e02d1d 100644
--- a/frontend/src/core/cells/session.ts
+++ b/frontend/src/core/cells/session.ts
@@ -82,9 +82,10 @@ function mergeSessionAndNotebookCells(
notebook.cells,
(sessionCell, notebookCell) => {
const sessionCodeHash = sessionCell.code_hash;
- // If the code hash is null, default to comparing ids
+ // If the code hash is null, always return false, since reordering the
+ // cells can get things out of sync, and creates a poor user experience.
if (!sessionCodeHash) {
- return sessionCell.id === notebookCell.id;
+ return false;
}
// Compare session cell code_hash with notebook cell code
const notebookCodeHash = notebookCell.code_hash;