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
Bypass delete confirmation for empty cells (#5804)
Trevor Manz41ecf9ef5809
diff --git a/frontend/src/core/cells/pending-delete-service.ts b/frontend/src/core/cells/pending-delete-service.tsindex 5439b904fc..8d187a9511 100644--- a/frontend/src/core/cells/pending-delete-service.ts+++ b/frontend/src/core/cells/pending-delete-service.ts@@ -32,18 +32,30 @@ export function usePendingDeleteService() {const submit = useCallback((cellIds: CellId[]) => {- const entries = new Map<CellId, PendingDeleteEntry>();+ const emptyCells = new Set(+ notebook.cellIds.inOrderIds.filter(+ (id) => notebook.cellData[id].code.trim() === "",+ ),+ );+ const entries = new Map<CellId, PendingDeleteEntry>();for (const cellId of cellIds) {+ if (emptyCells.has(cellId)) {+ // Empty cells indicate user intent to delete already+ entries.set(cellId, { cellId, type: "simple" });+ continue;+ }+const runtimeInfo = notebook.cellRuntime[cellId];// Build defs map for this cellconst defs = new Map<VariableName, readonly CellId[]>();for (const variable of Object.values(variables)) {- if (- variable.declaredBy.includes(cellId) &&- variable.usedBy.length > 0- ) {+ const declaredByThisCell = variable.declaredBy.includes(cellId);+ const usedByNonEmptyCell = variable.usedBy.some(+ (cellId) => !emptyCells.has(cellId),+ );+ if (declaredByThisCell && usedByNonEmptyCell) {defs.set(variable.name, variable.usedBy);}}