Skip to content

PNE debugging: F5 routing, no-kernel errors, and premature session termination#13807

Open
rodrigosf672 wants to merge 2 commits into
mainfrom
fixes/debugging-notebooks
Open

PNE debugging: F5 routing, no-kernel errors, and premature session termination#13807
rodrigosf672 wants to merge 2 commits into
mainfrom
fixes/debugging-notebooks

Conversation

@rodrigosf672
Copy link
Copy Markdown
Member

@rodrigosf672 rodrigosf672 commented May 27, 2026

Summary

Test plan

  • F5 with Python kernel: pauses at breakpoint, debug toolbar visible
  • F5 without kernel: kernel picker opens, no error notification
  • Debug Cell without kernel: no confusing error dialog
  • Debug Cell during active session: cell executes under existing session, no "already being debugged" error
  • Shift+F5 terminates session cleanly
  • E2E tests pass: npx playwright test test/e2e/tests/notebooks-positron/notebook-debug-fixes.test.ts --project e2e-electron

@:web @:win @:debug @:positron-notebooks

Route F5 to native notebook debugging when Positron Notebook Editor is
active, bypassing CONTEXT_DEBUGGERS_AVAILABLE which blocked activation.
When no kernel is connected, open the kernel picker instead of producing
a launch config error or unclear dialog. Keep the debug session alive
after cell execution and allow re-invoking Debug Cell during an active
session without error.

Fixes #12845, #10226, #10231.
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 27, 2026

E2E Tests 🚀
This PR will run tests tagged with: @:critical @:web @:win @:debug @:positron-notebooks

readme  valid tags

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR improves Positron notebook debugging UX by routing F5 to the native notebook debug flow in the Positron Notebook Editor, handling “no kernel” scenarios more gracefully, and allowing Debug Cell to be re-invoked during an active session without prematurely terminating that session.

Changes:

  • Add a Positron-specific F5 keybinding that starts notebook debugging (or opens the kernel picker when debugging isn’t available).
  • Update the runtime debugger extension to keep notebook debug sessions alive after cell execution and allow “Debug Cell” re-entry.
  • Add Playwright E2E coverage for the reported regressions and expected routing behavior.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
test/e2e/tests/notebooks-positron/notebook-debug-fixes.test.ts New E2E tests covering F5 routing, no-kernel behavior, and Debug Cell re-entry.
src/vs/workbench/contrib/debug/browser/debugCommands.ts Adds a Positron-specific F5 keybinding override when the Positron notebook editor is active.
extensions/positron-runtime-debugger/src/notebookDebugService.ts Reuses an existing notebook debug session by executing cells instead of starting a new session.
extensions/positron-runtime-debugger/src/notebookDebugAdapterFactory.ts Adjusts “already debugged” tracking behavior when creating adapters.
extensions/positron-runtime-debugger/src/debugCellController.ts Keeps debug session alive after cell execution completes.
extensions/positron-runtime-debugger/package.json Enables notebook.debugCell whenever the runtime supports debugging (removes “resource not in debuggedNotebooks”).

Comment on lines +85 to +88
/** Check if a debug session is active for the given notebook URI. */
function hasActiveDebugSessionForNotebook(notebookUriStr: string): boolean {
return vscode.debug.activeDebugSession?.configuration?.__notebookUri === notebookUriStr;
}
Comment on lines +66 to +71
if (hasActiveDebugSessionForNotebook(notebookUriStr)) {
await vscode.commands.executeCommand('notebook.cell.execute', {
ranges: [{ start: getCellIndex(cell), end: getCellIndex(cell) + 1 }],
document: cell.notebook.uri,
});
return;
Comment on lines +90 to +111
/** Get the cell index, handling both NotebookCell and PositronContext. */
function getCellIndex(cell: vscode.NotebookCell | PositronContext): number {
if (isNotebookCell(cell)) {
return cell.index;
}
const notebook = vscode.workspace.notebookDocuments.find(
(doc) => doc.uri.toString() === cell.notebook.uri.toString()
);
if (notebook) {
const idx = notebook.getCells().findIndex(
(c) => c.document.uri.toString() === cell.document.uri.toString()
);
if (idx >= 0) {
return idx;
}
}
return 0;
}

function isNotebookCell(cell: vscode.NotebookCell | PositronContext): cell is vscode.NotebookCell {
return typeof (cell as vscode.NotebookCell).index === 'number';
}
Comment on lines +30 to 33
// Clear any stale tracking from a previously terminated session.
if (this._debuggedNotebookUris.has(notebookUri)) {
throw new Error(vscode.l10n.t('Unexpected error: Notebook {0} is already being debugged', notebookUri.toString()));
await this._debuggedNotebookUris.delete(notebookUri);
}
const errorNotification = page.locator('.notifications-toasts .notification-toast');
const count = await errorNotification.count();
for (let i = 0; i < count; i++) {
const text = await errorNotification.nth(i).textContent();
// No error modal dialog
const dialog = page.locator('.monaco-dialog-box .dialog-message');
if (await dialog.isVisible()) {
const text = await dialog.textContent();
@rodrigosf672 rodrigosf672 requested a review from seeM May 27, 2026 18:52
@rodrigosf672 rodrigosf672 changed the title Fix F5 and Debug Cell routing for Positron notebooks Improve PNE debugging: F5 routing, no-kernel errors, and premature session termination May 27, 2026
@rodrigosf672 rodrigosf672 changed the title Improve PNE debugging: F5 routing, no-kernel errors, and premature session termination PNE debugging: F5 routing, no-kernel errors, and premature session termination May 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants