Skip to content

(feat) Make plot viewer session-aware. #1780

Description

@Fred-Wu

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 Viewer command could not restore the plot viewer if VS Code reloads.

Activity

  1. added this to the 3.x milestone on Sep 26, 2026
  2. added theissue type on Sep 27, 2026
  3. renkun-ken commented on Oct 6, 2026

    @renkun-ken
    Member

    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.

  4. Fred-Wu commented on Oct 10, 2026

    @Fred-Wu
    ContributorAuthor

    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?

  5. eitsupi commented on Oct 10, 2026

    @eitsupi
    Member

    Since I implemented jgd's historical snapshot and plotIndex replay 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/plotIndex protocol. 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions