feat(plot): addjgd graphics device integration#1706
Conversation
Embed the JGD (JSON Graphics Device) VS Code extension directly into vscode-R so users only need the `jgd` R package for interactive, Canvas2D-rendered plots with history, navigation, and PNG/SVG export. Add `r.plot.backend` enum setting (auto/standard/httpgd/jgd) with backward compatibility for existing `r.plot.useHttpgd` configurations. The JGD socket server starts eagerly on activation when the backend is set to "jgd", passing JGD_SOCKET to R terminals via env vars. Closes REditorSupport#1679 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
In auto mode, the JGD socket server starts eagerly and R-side hooks try jgd > httpgd > standard based on package availability. Users who install the jgd R package get interactive plots with zero config. r.plot.useHttpgd: true still forces httpgd for backward compatibility. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
I haven't had a chance to use jgd, will let @renkun-ken review it. Anyway, great work! |
👍
The IMHO the handling of setting |
|
No handling = no tinkering (touching, deleting, etc.) of setting
This actually breaks forward compatibility. What I intend to do: My default {
"r.bracketedPaste": true,
"r.plot.useHttpgd": true,
"r.plot.backend": "auto",
"r.rterm.linux": "/usr/local/bin/radian",
"r.rterm.option": [
"--no-save",
"--no-restore"
],
"r.workspaceViewer.showObjectSize": true,
}This will lead to the following behaviour:
|
|
@grantmcdermott I am just realising that my detailed comments at #1679 have caused more confusion than clarity. Sorry about that. |
eitsupi
left a comment
There was a problem hiding this comment.
I haven't looked at the details, but based on the description, I think it would be better to do it this way.
- Delete old setting
r.plot.useHttpgd - In auto mode, the priority is set to httpgd, then jgd.
This means that in older environments where httpgd is installed, httpgd will continue to be used automatically.
I'm also wondering if we could remove the svglite backend for simplification.
At the very least, I don't think it should be a hard dependency of the sess package.
I believe jgd is lighter than svglite.
|
Thanks for the quick comments. I don't want to respond to everything until @renkun-ken has had a chance to review. But just quickly:
|
If it is implemented as @eitsupi suggests, IMHO everything will continue to work as usual. |
Closes #1679
Embeds the jgd VS Code extension code directly into
vscode-R. Users only need thejgdR package installed on their system---and there's a graceful fallback otherwise---with no separate extension required.Details
Adds a new
r.plot.backendenum setting (auto|standard|httpgd|jgd). Default isauto, which tries the best available backend at runtime:r.plot.useHttpgdistrue→ httpgd (ensures backwards compatability)This means users who
install.packages("jgd")get interactive plots with zero configuration. (Note: I didn't want to presume that thejgdR package becomes a hard dependency, but am happy to adjust if others feel differently.)When
jgdis active:JGD_SOCKETandSESS_PLOT_BACKENDenv vars are passed to R terminalssess::register_hooks()setsjgd::jgd()as the default deviceNew files ported from the (currently standalone)
jgdVSC extension:src/plotViewer/jgdPlotHistory.ts— multi-session plot history with eviction and resize-after-delete protectionsrc/plotViewer/jgdSocketServer.ts— socket server managing concurrent R sessions and JSONL routingsrc/plotViewer/jgdViewer.ts—JgdManager+JgdViewer(Canvas2D webview with font metrics pipeline)JGD-specific settings:
r.plot.jgd.historyLimit,r.plot.jgd.exportWidth,r.plot.jgd.exportHeight,r.plot.jgd.exportDpi.R-side changes:
sess::connect()andsess::register_hooks()gain ause_jgdparameter. The hook priority is jgd > httpgd > standard, gated on package availability andJGD_SOCKETbeing set.Backward compatibility:
r.plot.useHttpgdis deprecated but still respected. Whenr.plot.backendisauto(default) andr.plot.useHttpgdistrue, httpgd is forced. Existing Docker images and devcontainer configs will continue to work without changes.Screenshots