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.

Generate with AI fix: use update cell code to not wait for cell editor (#7520)

Shahmir Varqhad127dbf5895c
diff --git a/frontend/src/core/ai/staged-cells.ts b/frontend/src/core/ai/staged-cells.ts
index a76290b79d..561df147b2 100644
--- a/frontend/src/core/ai/staged-cells.ts
+++ b/frontend/src/core/ai/staged-cells.ts
@@ -77,7 +77,7 @@ interface UpdateStagedCellAction {
export function useStagedCells(store: JotaiStore) {
const { addStagedCell, removeStagedCell, clearStagedCells } =
useStagedAICellsActions();
- const { createNewCell } = useCellActions();
+ const { createNewCell, updateCellCode } = useCellActions();
const deleteCellCallback = useDeleteCellCallback();
const cellCreationStream = useRef<CellCreationStream | null>(null);
@@ -103,13 +103,14 @@ export function useStagedCells(store: JotaiStore) {
return;
}
+ // Update the editor code if the cell is mounted
+ // Else, update the cell code in the notebook
const editorView = getCellEditorView(cellId);
- if (!editorView) {
- Logger.error("Editor for this cell not found", { cellId });
- return;
+ if (editorView) {
+ updateEditorCodeFromPython(editorView, code);
+ } else {
+ updateCellCode({ cellId, code, formattingChange: false });
}
- // TODO: Update the language
- updateEditorCodeFromPython(editorView, code);
};
// Delete a staged cell and the corresponding cell in the notebook.