Revert "fix: default new cell type to markdown instead of code"#80
Conversation
This reverts commit cd4891e.
There was a problem hiding this comment.
Pull request overview
This PR reverts changes from PR #78, restoring the default behavior of creating code cells instead of markdown cells when adding new cells to a notebook. The revert removes the markup cell creation methods and their associated tests, and changes the Actions component to use code cells by default.
Changes:
- Removed markup cell creation methods (
addMarkupCellBefore,appendMarkupCell,createMarkupCell) fromNotebookDataclass - Reverted
CellData.run()method signature from returningstringtovoid - Updated Actions component to create code cells instead of markup cells, with fallback logic for empty notebooks
- Removed markup cell tests and vitest environment directive
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| app/src/lib/notebookData.ts | Removed markup cell methods and reverted run() signature to void |
| app/src/lib/notebookData.test.ts | Removed markup cell tests and node environment directive |
| app/src/components/Actions/Actions.tsx | Changed from markup to code cell creation with fallback logic |
Comments suppressed due to low confidence (4)
app/src/components/Actions/Actions.tsx:865
- Unused variable mountedTabs.
const [mountedTabs, setMountedTabs] = useState<Set<string>>(() => new Set());
app/src/components/Actions/Actions.tsx:866
- Unused variable runName.
const { runName } = useParams<{ runName?: string }>();
app/src/components/Actions/Actions.tsx:868
- Unused variable cellsInitialized.
const [cellsInitialized, setCellsInitialized] = useState(false);
app/src/components/Actions/Actions.tsx:868
- Unused variable setCellsInitialized.
const [cellsInitialized, setCellsInitialized] = useState(false);
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| console.log("Started run for cell", { refId: this.refId, runID }); | ||
| // Update the snapshot after running to pick up any metadata changes. | ||
| this.cachedSnapshot = this.notebook.getCellSnapshot(this.refId); | ||
| this.cachedSnapshot = this.notebook.getCellSnapshot(this.refId); |
There was a problem hiding this comment.
Trailing whitespace detected at the end of this line. This should be removed to maintain code cleanliness.
| const newCell = data.addCodeCellAfter(""); | ||
| if (!newCell) { | ||
| // Fallback: create and persist a new code cell at the end. | ||
| const cell = create(parser_pb.CellSchema, { | ||
| metadata: {}, | ||
| refId: `code_${crypto.randomUUID().replace(/-/g, "")}`, | ||
| languageId: "bash", | ||
| role: parser_pb.CellRole.USER, | ||
| kind: parser_pb.CellKind.CODE, | ||
| value: "", | ||
| }); | ||
| data.updateCell(cell); | ||
| } |
There was a problem hiding this comment.
The fallback logic here is unnecessarily complex and inconsistent with the internal cell creation logic. When addCodeCellAfter("") is called with an empty notebook, it will always return null because there's no cell with an empty refId. The fallback then manually creates a cell with languageId: "bash", but the private createCodeCell method defaults to "js". This inconsistency could lead to unexpected behavior where cells created through different code paths have different default languages. Consider either: 1) Checking if cellDatas is empty first and handling that case directly, or 2) Adding a simpler appendCodeCell() method to NotebookData that appends to the end regardless of existing cells, similar to the removed appendMarkupCell() method.
| const newCell = data.addCodeCellAfter(""); | |
| if (!newCell) { | |
| // Fallback: create and persist a new code cell at the end. | |
| const cell = create(parser_pb.CellSchema, { | |
| metadata: {}, | |
| refId: `code_${crypto.randomUUID().replace(/-/g, "")}`, | |
| languageId: "bash", | |
| role: parser_pb.CellRole.USER, | |
| kind: parser_pb.CellKind.CODE, | |
| value: "", | |
| }); | |
| data.updateCell(cell); | |
| } | |
| // Notebook is empty; create and persist a new default code cell at the end. | |
| const cell = create(parser_pb.CellSchema, { | |
| metadata: {}, | |
| refId: `code_${crypto.randomUUID().replace(/-/g, "")}`, | |
| languageId: "js", | |
| role: parser_pb.CellRole.USER, | |
| kind: parser_pb.CellKind.CODE, | |
| value: "", | |
| }); | |
| data.updateCell(cell); |
Reverts #78