Errors when creating new notebook with Positron Notebooks enabled
Positron Version: 2024.06.0-50
Steps to reproduce the issue:
Pre-req: Enable the Positron Notebooks configuration setting positron.notebooks.usePositronNotebooks
via New File
- Create a Jupyter Notebook via New File > Jupyter Notebook
- An empty notebook file will open, but the kernel may not be connected and many errors will show in the developer console
via Project Wizard
- Create a Jupyter Notebook via the Project Wizard with default selections
- An empty notebook file will open, but subsequent project initialization tasks will not run and console startup hangs indefinitely
- Reloading the window restores the IDE to a usable state.
What did you expect to happen?
The behaviour should match the default notebooks (when positron.notebooks.usePositronNotebooks is disabled). There should not be a series of errors in the developer console. Via the Project Wizard, a new project should be created successfully and the selected interpreter should be selected. See #2820.
Were there any error messages in the output or Developer Tools console?
Console errors
Several ERR Illegal state: Expected notebook editor: Error: Illegal state: Expected notebook editor errors logged -- I am only including the first one in the details below.
Details
contextKeyService.ts:446 Element already has context attribute: positron-notebook-container
...
ERR Illegal state: Expected notebook editor: Error: Illegal state: Expected notebook editor
at illegalState (vscode-file://vscode-app/Users/sashimi/positron/out/vs/base/common/errors.js:149:20)
at Object.getComparisonKey (vscode-file://vscode-app/Users/sashimi/positron/out/vs/workbench/contrib/inlineChat/browser/inlineChatNotebook.js:51:53)
at InlineChatSessionServiceImpl._key (vscode-file://vscode-app/Users/sashimi/positron/out/vs/workbench/contrib/inlineChat/browser/inlineChatSessionServiceImpl.js:566:24)
at InlineChatSessionServiceImpl.getSession (vscode-file://vscode-app/Users/sashimi/positron/out/vs/workbench/contrib/inlineChat/browser/inlineChatSessionServiceImpl.js:560:30)
at EmptyCellEditorHintContribution._shouldRenderHint (vscode-file://vscode-app/Users/sashimi/positron/out/vs/workbench/contrib/codeEditor/browser/emptyTextEditorHint/emptyTextEditorHint.js:92:47)
at EmptyCellEditorHintContribution._shouldRenderHint (vscode-file://vscode-app/Users/sashimi/positron/out/vs/workbench/contrib/notebook/browser/contrib/editorHint/emptyCellEditorHint.js:33:44)
at EmptyCellEditorHintContribution.update (vscode-file://vscode-app/Users/sashimi/positron/out/vs/workbench/contrib/codeEditor/browser/emptyTextEditorHint/emptyTextEditorHint.js:110:43)
at UniqueContainer.value (vscode-file://vscode-app/Users/sashimi/positron/out/vs/workbench/contrib/codeEditor/browser/emptyTextEditorHint/emptyTextEditorHint.js:50:73)
at Emitter._deliver (vscode-file://vscode-app/Users/sashimi/positron/out/vs/base/common/event.js:889:26)
at Emitter._deliverQueue (vscode-file://vscode-app/Users/sashimi/positron/out/vs/base/common/event.js:900:22)
at Emitter.fire (vscode-file://vscode-app/Users/sashimi/positron/out/vs/base/common/event.js:923:22)
at CodeEditorWidget.setModel (vscode-file://vscode-app/Users/sashimi/positron/out/vs/editor/browser/widget/codeEditor/codeEditorWidget.js:303:36)
at vscode-file://vscode-app/Users/sashimi/positron/out/vs/workbench/contrib/positronNotebook/browser/notebookCells/CellEditorMonacoWidget.js:81:24
...
ERR Notebook Editor creation failure for document {"$mid":1,"fsPath":"Untitled-1.ipynb","external":"untitled:Untitled-1.ipynb?jupyter-notebook","path":"Untitled-1.ipynb","scheme":"untitled","query":"jupyter-notebook"}: Error: Notebook Editor creation failure for document {"$mid":1,"fsPath":"Untitled-1.ipynb","external":"untitled:Untitled-1.ipynb?jupyter-notebook","path":"Untitled-1.ipynb","scheme":"untitled","query":"jupyter-notebook"}
at ExtHostCommands._executeContributedCommand (/Users/sashimi/positron/out/vs/workbench/api/common/extHostCommands.js:211:23)
...
Positron Notebook Controllers Output
[debug] Failed to get preferred runtime for language: python No language runtimes registered for language ID 'python'.
This happens even without using the project wizard. It's due to some reused notebook code expecting the vscode notebook editor class to be the one responsible for the document.
Thanks for the additional context! I've updated the issue title and description 👍
Verified Fixed
Positron Version(s) : 2025.09.0 build 26
OS Version : Sequoia 15.5
Test scenario(s)
- Notebook can be created via New File with
positron.notebooks.usePositronNotebooksenabled, the kernel connects without console errors. - Notebook can be created via Project Wizard with default selections; project initialization completes and the selected interpreter is applied without console errors.
- Positron can be closed and reopened after creating a notebook via either method; Positron was already usable with only a quick kernel reload needed.
- Kernel can be successfully restarted in a few seconds.
Log issue for automated test in order to catch flakes of kernel not restarting (rare, but it happened once).
- Repeated the above flows with
positron.notebooks.usePositronNotebooksdisabled and confirmed behavior matched the fixed enabled state. - Created a project via Project Wizard with a non-default interpreter and confirmed it was correctly applied to the opened notebook kernel.