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
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.

"engines": {
"vscode": "^1.75.0",
"positron": "^2025.12.0"
"positron": "^2026.05.0"
Copy link
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

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`
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