Repository navigation
(feat) Make plot viewer session-aware. #1780
Description
Activity
Session-specific plots are now retained in persistent Interactive transcripts through #1805 / #1830.
The standalone plot-viewer request here is still outstanding. The ordinary plot manager keeps one standard plot viewer, and its plot_latest request uses the active session rather than a session retained by that panel. Interactive plot history therefore does not establish session switching or reload restoration for the standalone viewer.
Keeping this open.
In the situation of VS Code reload, vscode-R can save JSON frames and restore them after a reload, so the plot viewer can retain JGD plot history with the current package.
A useful improvement in JGD package would be to reconnect the existing graphics device while preserving its plot snapshots, and expose the available plot IDs. vscode-R could then request historical plots on demand rather than relying on saved frames for older plots.
@grantmcdermott is this something you could help with?
Since I implemented jgd's historical snapshot and
plotIndexreplay support, I'd like to clarify what is already possible and where the remaining work belongs.- jgd: A live device already retains up to 50 historical R graphics snapshots and supports replaying them at a requested size via the existing
resize/plotIndexprotocol. It does not currently provide an API to enumerate retained plot IDs or reconnect an existing device to a new socket. These could be useful improvements, but they are not prerequisites for restoring previously received JSON frames. - vscode-R: The jgd viewer already maintains per-session JSON plot history in memory. To address this issue, the standalone plot viewer should support explicit session selection and restore saved frames after reload, rather than relying on the currently active session.
I would prefer to keep viewer-side plot history and persistence in the server layer (currently vscode-R), rather than expanding the responsibilities of the jgd R package.
R-side snapshots are useful for re-rendering plots at different sizes, but replay requires the original R device to remain alive and connected. Once the device is closed, those snapshots are lost. In contrast, retaining the rendered JSON frames server-side allows plots to be displayed independently of the R session. Persisting those frames to disk would also allow history to survive a VS Code window reload. This keeps plot history independent of R's graphics device lifecycle.
Reconnecting a live device while preserving its R snapshots is a separate improvement. It would also require coordinating with sess's device lifecycle, since sess currently closes managed devices on disconnect.
- jgd: A live device already retains up to 50 historical R graphics snapshots and supports replaying them at a requested size via the existing
The plot system currently is not session-aware. For concurrent sessions, the plot viewer would be replaced in one session if you make plots in another session. The last session plot cannot be switched back until you make another plot on it.
Also
R Plot: Show Viewercommand could not restore the plot viewer if VS Code reloads.