Skip to content

PositroNB-untitled-notebook-support #8608

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 13 commits into
base: main
Choose a base branch
from

Conversation

nstrayer
Copy link
Contributor

@nstrayer nstrayer commented Jul 21, 2025

Addresses #3492.

@:notebooks

Fixes errors when creating new notebooks with Positron Notebooks enabled by intercepting untitled notebook files and routing them to the appropriate Positron notebook editor. This change ensures that new Jupyter notebooks created via "New File > Jupyter Notebook" properly initialize without console errors and maintain kernel connectivity.

Release Notes

New Features

  • N/A

Bug Fixes

  • Fixed errors and kernel connectivity issues when creating new notebooks with Positron Notebooks enabled

QA Notes

Enable the Positron Notebooks configuration setting and create a new notebook file. The notebook should open without errors and maintain proper kernel connectivity.

  1. Right click on a notebook file and then "Open With..." -> "Configure default editor for '*.ipynb'..." -> "Positron Notebook".
  2. Create a Jupyter Notebook via New File > Jupyter Notebook
  3. Verify the notebook opens without console errors
  4. Verify the kernel connects properly
# Test that the notebook can execute code
print("Hello from Positron Notebooks!")

Expected: The notebook should open cleanly, show no errors in the developer console, and successfully execute the test code.

@nstrayer nstrayer self-assigned this Jul 21, 2025
Copy link

github-actions bot commented Jul 21, 2025

E2E Tests 🚀
This PR will run tests tagged with: @:critical @:notebooks

readme  valid tags

@nstrayer nstrayer requested review from austin3dickey and seeM July 22, 2025 16:43
Copy link
Contributor

@austin3dickey austin3dickey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Go to Settings and enable positron.notebooks.usePositronNotebooks

This isn't correct anymore, right? When testing this change I first used "Open with..." on an existing notebook and did "configure default editor". Then when I created a new notebook it successfully opened in the PositroNB editor.

}
} catch (error) {
// Fallback to the original approach if the above fails
console.warn('Failed to open notebook via vscode.open, falling back to workspace API:', error);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a better log than console here? (I'm still trying to figure out when to use what logger 😂)

]);
await vscode.workspace.applyEdit(edit);
}
} catch (error) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(adding a line comment so we can use a thread)

I'm seeing some strange behavior around saving these untitled notebooks. Sometimes when I save, the editor closes, which is unexpected. Sometimes it doesn't close, but the filename doesn't change (it stays untitled), and the saved file doesn't have any content in it, even if my editor does have content. Can you reproduce?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, if I have an Untitled-1.ipynb in the workspace, and I open a new untitled notebook, its name is also Untitled-1.ipynb, which is probably not great.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here's a recording with all 3 problems:

  1. new Untitled-1.ipynb with an Untitled-1.ipynb already in the workspace
  2. when I save asdasd-1.ipynb, it closes (leaving the phantom vs code nb from Run-all button when using positron notebooks causes another tab to open with vsc notebooks #8535 on the screen)
  3. then when I create a new one and save as asdasdasd-1.ipynb (sorry for the naming lol) it saves it as an empty file even though the untitled file I had up had 1 cell in it
Screen.Recording.2025-07-22.at.13.36.26.mov

@nstrayer nstrayer force-pushed the positroNB-untitled-notebook-support branch from 475215d to c6095f5 Compare July 22, 2025 21:24
nstrayer added 4 commits July 23, 2025 06:17
Remove global state and complex counter management in favor of simple collision detection starting from 1. Eliminates memory leaks and race conditions while maintaining standard VS Code numbering behavior.
- Properly dispose editor model reference in PositronNotebookEditorInput
- Fix model reference leak by disposing immediately after getting resolved resource
- Remove unused Event import in positronNotebook.contribution.ts
Test verifies that multiple untitled Positron notebooks get unique URIs
and that URIs are properly reused when notebooks are closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants