Skip to content

Send metadata when executing cells/code#938

Open
jmcphers wants to merge 2 commits intomainfrom
feature/cell-metadata
Open

Send metadata when executing cells/code#938
jmcphers wants to merge 2 commits intomainfrom
feature/cell-metadata

Conversation

@jmcphers
Copy link
Copy Markdown
Collaborator

This change amends code/cell executions with the Quarto cell options. This will enable backends to change the way execution and rendering work based on cell options.

Note

This can't be merged until Positron 2026.05 is released. It is the first release that will include the new API parameters used here.

Comment thread apps/vscode/package.json
"engines": {
"vscode": "^1.75.0",
"positron": "^2025.12.0"
"positron": "^2026.05.0"
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@juliasilge warned me about aggressively bumping the positron version due to posit-dev/positron#11321, but I guess that's fixed now? If so, I can also remove some runtime version checks in the StatementRange code

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

If we do in fact decide to bump to 2026.04.1 like I am thinking then yep, we can remove some runtime version checks.

We do want to be aware that this means people on older versions of Positron (like on Workbench) will not be able to use this version of the Quarto extension. People with even older versions of Positron (like before posit-dev/positron#11321) will still get it promoted to them and things will go poorly. It's a pretty weighty decision to bump the version like this, but I think for this new execution metadata it's probably worth it, rather than wiring up a bunch of runtime version checks.

jmcphers added a commit to posit-dev/positron that referenced this pull request Mar 20, 2026
)

This change adds metadata to execution requests so that it is possible
for kernels to size plots to fit the viewport/DPI.

For Quarto, we add cell options (such as `fig-width` and `fig-height`)
to the execution metadata; for both Quarto inline outputs and Jupyter
editors, we add the width of the output field and the device pixel ratio
to the execution request.

In notebooks, this means that your plots render crisply on Retina
displays and are sized appropriately to your viewport:

<img width="768" height="831" alt="image"
src="https://github.com/user-attachments/assets/d2a5ac46-afb3-4a88-9b79-deab6d842b41"
/>

In Quarto inline outputs, this means that figure width/height are
respected, too, so you get a preview with the correct aspect ratio:

<img width="758" height="363" alt="image"
src="https://github.com/user-attachments/assets/98a1505a-8620-43b0-ba0a-bec65ec01daa"
/>


Requires posit-dev/ark#1119
Requires posit-dev/qa-example-content#116
Related to quarto-dev/quarto#938

Addresses #8104
Addresses #12150



### Release Notes

<!--
Optionally, replace `N/A` with text to be included in the next release
notes.
The `N/A` bullets are ignored. If you refer to one or more Positron
issues,
these issues are used to collect information about the feature or
bugfix, such
as the relevant language pack as determined by Github labels of type
`lang: `.
  The note will automatically be tagged with the language.

These notes are typically filled by the Positron team. If you are an
external
  contributor, you may ignore this section.
-->

#### New Features

- Quarto inline output for R now respects `fig-width` and `fig-height`
options (#12150)

#### Bug Fixes

- Plots in R notebooks are now sized correctly (#8104)


### QA Notes

This PR doesn't attempt to size Python plots, though it takes the first
step towards doing so by adding the right metadata. I added a hidden
magic you can use to see what is being sent to Python:

```python
%_positron_exec_metadata
```

The Ark equivalent is `.ps.internal(active_request())`.

It also doesn't apply to the Plots pane, just notebook-style execution.
We'll need to wait for a new Quarto extension to do that
(quarto-dev/quarto#938).

Test tags: `@:quarto` `@positron-notebooks` `@notebooks`
Copy link
Copy Markdown
Collaborator

@juliasilge juliasilge left a comment

Choose a reason for hiding this comment

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

This is working great!

  • Can you update the CHANGELOG with info on this, even though it's not yet a really user-facing change? Just in case we need to know moving forward
  • Can we bump the required Positron version to 2026.04.1 instead of 2026.05.0? IIUC that patch gets us to about the right spot without having to worry about the 2026.04.0 dailies that didn't have the new APIs.

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.

3 participants