Date: 2026-02-05 Branch: positron-nb-add-raw-cells Commit reviewed: 1150081e7e (Add raw cell support to Positron Notebooks) Scope: 12 files (2 new, 10 modified)
Overall the implementation is clean. One medium-priority consistency issue was found; two low-priority items noted for awareness.
The "Insert Raw Cell Above/Below" menu actions in positronNotebook.contribution.ts bypass the delegation chain used by code and markdown cell insertion.
Code/markdown pattern (established):
contribution action
-> cell.insertCodeCellAbove() (PositronNotebookCell.ts:370)
-> instance.insertCodeCellAndFocusContainer('above', this) (PositronNotebookInstance.ts:1162)
-> instance._insertCellAndFocusContainer(CellKind.Code, ...) (PositronNotebookInstance.ts:1138)
-> instance.addCell(type, computedIndex, false)
Raw cell pattern (current -- inconsistent):
contribution action
-> notebook.addCell(CellKind.Code, cell.index, true, '', 'raw') (positronNotebook.contribution.ts:687)
- Raw actions call
notebook.addCell()directly with hand-computed index (cell.indexorcell.index + 1) instead of delegating through_insertCellAndFocusContainer. - Raw actions pass
enterEditMode: true, while the shared helper passesfalse. This may be intentional or an oversight -- needs verification. - If insertion logic changes (undo grouping, animations, focus behavior), raw cell paths won't pick up those changes.
File 1: IPositronNotebookCell.ts -- add after insertMarkdownCellBelow() (line 126):
/**
* Insert a new raw cell above this cell
*/
insertRawCellAbove(): void;
/**
* Insert a new raw cell below this cell
*/
insertRawCellBelow(): void;File 2: IPositronNotebookInstance.ts -- add after insertMarkdownCellAndFocusContainer (line 275):
/**
* Inserts a new raw cell either above or below the current selection
* and focuses the container.
*
* @param aboveOrBelow Whether to insert the cell above or below the current selection
* @param referenceCell Optional cell to insert relative to. If not provided, uses the currently selected cell
*/
insertRawCellAndFocusContainer(aboveOrBelow: 'above' | 'below', referenceCell?: IPositronNotebookCell): void;File 3: PositronNotebookInstance.ts -- thread language through private helper and add public method:
Update _insertCellAndFocusContainer (line 1138) to accept an optional language parameter:
private _insertCellAndFocusContainer(type: CellKind, aboveOrBelow: 'above' | 'below', referenceCell?: IPositronNotebookCell, language?: string): void {
let index: number | undefined;
this._assertTextModel();
if (referenceCell) {
const cellIndex = referenceCell.index;
index = cellIndex >= 0 ? cellIndex : undefined;
} else {
index = getActiveCell(this.selectionStateMachine.state.get())?.index;
}
if (index === undefined) {
return;
}
this.addCell(type, index + (aboveOrBelow === 'above' ? 0 : 1), false, '', language);
}Add after insertMarkdownCellAndFocusContainer (line 1168):
insertRawCellAndFocusContainer(aboveOrBelow: 'above' | 'below', referenceCell?: IPositronNotebookCell): void {
this._insertCellAndFocusContainer(CellKind.Code, aboveOrBelow, referenceCell, 'raw');
}File 4: PositronNotebookCell.ts -- add after insertMarkdownCellBelow() (line 384):
insertRawCellAbove(): void {
this._instance.insertRawCellAndFocusContainer('above', this);
}
insertRawCellBelow(): void {
this._instance.insertRawCellAndFocusContainer('below', this);
}File 5: positronNotebook.contribution.ts -- simplify raw cell actions:
Replace lines 683-689 (Insert Raw Cell Above action body):
override runNotebookAction(notebook: IPositronNotebookInstance, _accessor: ServicesAccessor) {
const state = notebook.selectionStateMachine.state.get();
const cell = getActiveCell(state);
if (cell) {
cell.insertRawCellAbove();
}
}Replace lines 708-714 (Insert Raw Cell Below action body):
override runNotebookAction(notebook: IPositronNotebookInstance, _accessor: ServicesAccessor) {
const state = notebook.selectionStateMachine.state.get();
const cell = getActiveCell(state);
if (cell) {
cell.insertRawCellBelow();
}
}The current raw cell actions pass enterEditMode: true to addCell(). The shared _insertCellAndFocusContainer passes false. Verify which is correct for raw cells before applying this fix. If raw cells should enter edit mode on insert, the _insertCellAndFocusContainer helper may need an additional parameter, or the raw cell path can set it separately.
NotebookRawCell.css lines 11-17 define .positron-notebook-editor-section flex layout rules that partially overlap with NotebookCodeCell.css. The differences are justified by the editor-only layout, so no action needed now. If more cell types are added, consider extracting a shared base .positron-notebook-cell-contents class.
NotebookCellWrapper.tsx:69 uses cell.isCodeCell() || cell.isRawCell() to mean "cell has a persistent editor." Currently appears only once. If this pattern appears in more places, add an isEditableCell() helper to the cell interface. No action needed now -- just monitor.
- No significant code duplication between
NotebookRawCell.tsxand existing cell components - Type guards (
isRawCell,isCodeCell,isMarkdownCell) are correctly mutually exclusive - Cell routing in
PositronNotebookComponent.tsxis correctly ordered (raw before code) - Execution filter in
notebookExecutionServiceImpl.tsis in the right architectural location NotebookRawCell.tsxcorrectly reusesNotebookCellWrapperandCellEditorMonacoWidget