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: preserve cell config (hidden/disabled) on undo delete (#8483)

Myles Scolnick12b4f4e1f6c3
diff --git a/frontend/src/components/editor/chrome/panels/outline/floating-outline.tsx b/frontend/src/components/editor/chrome/panels/outline/floating-outline.tsx
index f7c78a656a..fe00b8bee4 100644
--- a/frontend/src/components/editor/chrome/panels/outline/floating-outline.tsx
+++ b/frontend/src/components/editor/chrome/panels/outline/floating-outline.tsx
@@ -30,7 +30,7 @@ export const FloatingOutline: React.FC = () => {
onMouseEnter={() => setIsHovered(true)}
onMouseLeave={() => setIsHovered(false)}
className={cn(
- "fixed top-[25vh] right-8 z-10000",
+ "fixed top-[25vh] right-8 z-10000 print:hidden",
// Hide on small screens
"hidden md:block",
)}
diff --git a/frontend/src/core/cells/__tests__/cells.test.ts b/frontend/src/core/cells/__tests__/cells.test.ts
index c6e3d7fea3..4e5957ff4f 100644
--- a/frontend/src/core/cells/__tests__/cells.test.ts
+++ b/frontend/src/core/cells/__tests__/cells.test.ts
@@ -279,6 +279,36 @@ describe("cell reducer", () => {
`);
});
+ it("undo delete restores cell config (hide_code, disabled)", () => {
+ actions.createNewCell({
+ cellId: firstCellId,
+ before: false,
+ code: "x = 1",
+ });
+ const newCellId = state.cellIds.getColumns()[0].atOrThrow(1);
+
+ // Set config to hidden and disabled
+ actions.updateCellConfig({
+ cellId: newCellId,
+ config: { hide_code: true, disabled: true },
+ });
+ expect(state.cellData[newCellId].config.hide_code).toBe(true);
+ expect(state.cellData[newCellId].config.disabled).toBe(true);
+
+ // Delete the cell
+ actions.deleteCell({ cellId: newCellId });
+ expect(state.cellIds.inOrderIds).not.toContain(newCellId);
+
+ // Undo delete
+ actions.undoDeleteCell();
+ const restoredCellId =
+ state.cellIds.inOrderIds[state.cellIds.inOrderIds.length - 1];
+
+ // Config should be preserved
+ expect(state.cellData[restoredCellId].config.hide_code).toBe(true);
+ expect(state.cellData[restoredCellId].config.disabled).toBe(true);
+ });
+
it("can update a cell", () => {
actions.updateCellCode({
cellId: firstCellId,
diff --git a/frontend/src/core/cells/cells.ts b/frontend/src/core/cells/cells.ts
index 7fa26e869c..f0c879c83d 100644
--- a/frontend/src/core/cells/cells.ts
+++ b/frontend/src/core/cells/cells.ts
@@ -84,6 +84,7 @@ export interface NotebookState {
column: CellColumnId;
index: CellIndex;
isSetupCell: boolean;
+ config: CellConfig;
}[];
/**
* Key of cell to scroll to; typically set by actions that re-order the cell
@@ -590,17 +591,19 @@ const {
// release the granular atom(s) created for this cell
releaseCellAtoms(cellId);
+ const prevData = state.cellData[cellId];
return {
...state,
cellIds: state.cellIds.deleteById(cellId),
history: [
...state.history,
{
- name: state.cellData[cellId].name,
+ name: prevData.name,
serializedEditorState: serializedEditorState,
column: column.id,
index: cellIndex,
isSetupCell: cellId === SETUP_CELL_ID,
+ config: prevData.config,
},
],
scrollKey: scrollKey,
@@ -619,6 +622,7 @@ const {
column,
index,
isSetupCell,
+ config,
} = mostRecentlyDeleted;
const cellId = isSetupCell ? SETUP_CELL_ID : CellId.create();
@@ -628,6 +632,7 @@ const {
code: serializedEditorState.doc,
edited: serializedEditorState.doc.trim().length > 0,
serializedEditorState,
+ config,
});
return {