Repository navigation
Send the final update for a plot page when the next page starts while the device is held - #1481
Merged
Merged
Conversation
… the device is held
juliasilge
marked this pull request as ready for review
November 13, 2026 01:12
jmcphers
approved these changes
Nov 14, 2026
jmcphers
left a comment
Contributor
There was a problem hiding this comment.
This is working great! Thank you!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Addresses posit-dev/positron#17240
In notebook sessions, a plot page now keeps all of its layers when the same statement starts another page. Before this change, Quarto inline output showed the first page without the layers that were added last. For example,
plot(gof_fit)from ergm showed the model page as a bare boxplot.This base R example can be used to see the problem:
local({ plot(1:10) points(5, 5, col = "red", pch = 16, cex = 4) plot(1:5) points(3, 3, col = "blue", pch = 16, cex = 4) })The first plot would not show the red point before this change. If you write the same calls as separate top-level statements, the red point always shows.
plot.default()andbxp()calldev.hold()before they callplot.new(), so when the second page starts, thebefore.plot.newhook records the first page with the red point. The device is on hold, though, so ark defers the notification and then thenewPagecallback gives the device a new plot ID. When the hold is released, ark sent the deferred notification for the new page only and the first page never got its final update.Changes
update_display_data; in console mode, it is an update on the plot comm. The Plots pane already rendered the complete plot when it asked for one, but it now also gets the final image when the hold is released.dev.hold()still hides the pages between a hold and a flush.The frontend gets the new page before the update for the old page. To render the old page, ark replays its recording on another device. This change of device starts
process_changes()again, and that call sends the new page first. Frontends match an update to its plot by display ID or comm ID, so the order doesn't have an effect. Positron's Quarto inline output (posit-dev/positron#17171) and.ipynbnotebooks both replace the old output.Tests
test_notebook_plot_layers_kept_when_next_page_starts_in_same_requestinkernel_notebook.rs: the example above sendsdisplay_datafor each page, thenupdate_display_datafor page 1 and for page 2. The image in the update for page 1 is different from the first image for page 1.test_positron_held_layers_update_previous_pageinplots.rs: in console mode, the same code sends anupdateevent with a rendered image on the plot comm of page 1.recv_iopub_update_display_data_content, returns the content of anupdate_display_datamessage.Both new tests fail without the fix. The existing
dev.hold()tests still pass. I also tested the ergm example from the issue:Positron Release Notes
New Features
Bug Fixes
plot()on a gof object from ergm (Bug: some, not all R plot layers are shown in Quarto inline output positron#17240)