diff --git a/extensions/positron-notebook-controllers/src/notebookController.ts b/extensions/positron-notebook-controllers/src/notebookController.ts index 29fa383712c..8e741ad9f4d 100644 --- a/extensions/positron-notebook-controllers/src/notebookController.ts +++ b/extensions/positron-notebook-controllers/src/notebookController.ts @@ -10,8 +10,21 @@ import { log, setHasRunningNotebookSessionContext } from './extension'; import { ResourceMap } from './map'; import { getNotebookSession, isActiveNotebookEditorUri } from './utils'; -/** The type of a Jupyter notebook cell output. */ +/** + * The type of a Jupyter notebook cell output. + * + * Used by the ipynb notebook serializer (extensions/ipynb/src/serializers.ts) to convert from + * VSCode notebook cell outputs to Jupyter notebook cell outputs. + * + * See: https://jupyter-client.readthedocs.io/en/latest/messaging.html + */ enum NotebookCellOutputType { + /** An error occurred during an execution. */ + Error = 'error', + + /** Output from one of the standard streams (stdout or stderr). */ + Stream = 'stream', + /** One of possibly many outputs related to an execution. */ DisplayData = 'display_data', @@ -600,7 +613,9 @@ async function handleRuntimeMessageStream( if (lastOutputItems && lastOutputItems.every(item => item.mime === cellOutputItem.mime)) { await execution.appendOutputItems([cellOutputItem], lastOutput); } else { - const cellOutput = new vscode.NotebookCellOutput([cellOutputItem]); + const cellOutput = new vscode.NotebookCellOutput( + [cellOutputItem], { outputType: NotebookCellOutputType.Stream }, + ); await execution.appendOutput(cellOutput); } } @@ -621,6 +636,6 @@ async function handleRuntimeMessageError( message: message.message, stack: message.traceback.join('\n'), }) - ]); + ], { outputType: NotebookCellOutputType.Error }); await execution.appendOutput(cellOutput); }