Skip to content

Conversation

@lionel-
Copy link
Contributor

@lionel- lionel- commented Nov 26, 2025

This PR introduces new optional Positron-specific fields in Jupyter execute requests that contain source editor information (URI and range). This will be used by Ark to map source references to their original locations in editors. The information will also be used to figure out whether the executed code has a breakpoint in range, and inject it in that case.

Approach:

  • The workbench.action.positronConsole.executeCode action now adds codeLocation as metadata for CodeAttribution of kind Script, in case of a statement range request or of a selection request.

  • On the main thread side, execute methods take a CodeAttribution. This code attribution is converted to a vscode.Location (wrapper around Uri and Range) before being passed to runtime's execute() methods on the extension host side.

  • For consistency, the cursor location included as metadata for Script attributions was refactored to a vscode.Location with an empty range. I was really looking for a version of Location that wraps a Position instead of a Range so that the type itself encodes the invariant of a position, but this doesn't exist and using a Location to send positions seems to be the established way in the VSC codebase.

  • JupyterExecuteRequest gains a positron field. The name of that field is consistent with our existing extensions, e.g. for a language_info response.

  • The message extension introduces LSP/VSCode-like Position and Range data structures, which means they are based on a pair of line/character offsets. Compared to simple offsets in a document, which are simpler in some aspects, this approach has the advantages of side stepping any line endings issues, and of being more immediately ingestible by backends that implement an LSP.

    The main difference with the LSP data structures is that the character offset is in terms of encoding-agnostic Unicode points rather than UTF-16 offsets as in the LSP spec. This is to be consistent with how offsets are documented in the Jupyter protocol: https://jupyter-client.readthedocs.io/en/stable/messaging.html#cursor-pos-unicode-note.

Release Notes

New Features

  • N/A

Bug Fixes

  • N/A

QA Notes

Should incur no visible changes to tests and UX.

@github-actions
Copy link

github-actions bot commented Nov 26, 2025

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

readme  valid tags

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