Skip to content

Commit

Permalink
correct execution count
Browse files Browse the repository at this point in the history
  • Loading branch information
prasunanand committed Dec 21, 2024
1 parent 2f99675 commit 90233a7
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions ui/src/ide/editor/notebook/NotebookEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,21 @@ export default function NotebookEditor(props) {
if(message.hasOwnProperty('execution_state')){
setKernelStatus(message.execution_state)
}

if (message.hasOwnProperty('execution_count')) {
setNotebook((prevNotebook) => {
const updatedCells = prevNotebook.cells.map((cell) => {
if (cell.id === message.msg_id) {
const updatedCell = { ...cell };
updatedCell.execution_count = message.execution_count;
return updatedCell;
}
return cell;
});

return { ...prevNotebook, cells: updatedCells };
});
}
if (message.hasOwnProperty('traceback')) {
setNotebook((prevNotebook) => {
const updatedCells = prevNotebook.cells.map((cell) => {
Expand All @@ -174,7 +189,6 @@ export default function NotebookEditor(props) {
traceback: message.traceback
}];
}
updatedCell.execution_count = message.execution_count;
return updatedCell;
}
return cell;
Expand All @@ -195,7 +209,6 @@ export default function NotebookEditor(props) {
if (message.hasOwnProperty('traceback')) {
updatedCell.outputs = [message.traceback];
}
updatedCell.execution_count = message.execution_count;
return updatedCell;
}
return cell;
Expand All @@ -215,7 +228,6 @@ export default function NotebookEditor(props) {
const cleanedArray = removeAnsiCodes(traceback);
updatedCell.outputs = [{"text": cleanedArray}];
}
updatedCell.execution_count = message.execution_count;
return updatedCell;
}
return cell;
Expand Down

0 comments on commit 90233a7

Please sign in to comment.