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.

Skip scratchpad changes in document transaction sync (#9078)

Trevor Manzb26af24054ba
diff --git a/frontend/src/core/cells/document-changes.ts b/frontend/src/core/cells/document-changes.ts
index 1c623dbba9..0351a6fd62 100644
--- a/frontend/src/core/cells/document-changes.ts
+++ b/frontend/src/core/cells/document-changes.ts
@@ -25,6 +25,7 @@ import type { NotebookDocumentTransactionRequest } from "../network/types";
import { store } from "../state/jotai";
import type { CellActions, NotebookState } from "./cells";
import type { CellId } from "./ids";
+import { SCRATCH_CELL_ID } from "./ids";
import type { CellData } from "./types";
export type DocumentChange =
@@ -572,10 +573,21 @@ const flushChanges = debounce(() => {
void getRequestClient().sendDocumentTransaction({ changes });
}, 400);
+function isScratchChange(change: DocumentChange): boolean {
+ if ("cellId" in change && change.cellId === SCRATCH_CELL_ID) {
+ return true;
+ }
+ return false;
+}
+
function enqueue(change: DocumentChange) {
if (store.get(kioskModeAtom)) {
return;
}
+ // The scratchpad cell is local-only — don't sync it to the document.
+ if (isScratchChange(change)) {
+ return;
+ }
pendingChanges.push(change);
flushChanges();
}