Skip to content

repl: Render SVG cell outputs - #61718

Closed
ArneshBanerjee wants to merge 1 commit into
zed-industries:mainfrom
ArneshBanerjee:pr/notebook-svg-output
Closed

repl: Render SVG cell outputs#61718
ArneshBanerjee wants to merge 1 commit into
zed-industries:mainfrom
ArneshBanerjee:pr/notebook-svg-output

Conversation

@ArneshBanerjee

Copy link
Copy Markdown
Contributor

Fixes #61717

SVG outputs from kernels (image/svg+xml) were showing "Unsupported media type" instead of the image. matplotlib, plotly, and other libraries commonly emit SVG, so this was a visible gap for data science users. This came up in discussion #25936.

This renders SVG outputs through GPUI's SVG renderer, reusing the existing ImageView with a from_svg constructor. It also ranks SVG above raster images so a kernel that provides both shows the scalable version.

I added a unit test that checks an SVG renders at its intrinsic size. This caught a scale factor bug where SVGs were rendering at twice their size. I also tested it locally on macOS and a cell producing image/svg+xml now renders the vector image inline.

SVG output rendered inline

Release Notes:

  • Added rendering of SVG outputs in the REPL and notebook editor

SVG outputs (image/svg+xml) previously fell through to "Unsupported
media type". Render them through GPUI's SVG renderer, reusing the
existing ImageView via a from_svg constructor, and rank SVG above
raster images so a kernel that offers both shows the scalable version.
@cla-bot cla-bot Bot added the cla-signed The user has signed the Contributor License Agreement label Jul 27, 2026
@MrSubidubi

Copy link
Copy Markdown
Member

Thanks for this!

Curious a bit, as #44512 proposed some more changes, were you aware of that PR and/or had a look?

@MrSubidubi MrSubidubi added the area:repl repl, jupyter, notebooks, etc label Jul 27, 2026
@ArneshBanerjee

Copy link
Copy Markdown
Contributor Author

No, I hadn't seen #44512, thanks for the pointer. I looked through the open issues but not the closed PRs, so I missed it.

The main blocker in that PR was that image/svg+xml was being parsed as a generic image and dropped, so it needed a cargo patch to jupyter_protocol. That looks fixed in the version Zed uses now (jupyter-protocol 1.4.0), so no patch is needed here. I tested it and SVG cells render fine.

The other difference is I reused the existing ImageView through a from_svg constructor instead of adding a separate SVGView, to keep the change small.

@ArneshBanerjee

Copy link
Copy Markdown
Contributor Author

Adding onto that, I also saw another issue #60203 regarding the same was opened.

@MrSubidubi

Copy link
Copy Markdown
Member
image

Thanks for getting back, yet still seems this is currenty abandoned.

Would definitely be nice to see this, so if you feel like picking it up again, feel free to resubmit this with all issues taken care of. Thank you!

@MrSubidubi MrSubidubi closed this Aug 19, 2026
@ArneshBanerjee

Copy link
Copy Markdown
Contributor Author

@MrSubidubi thanks! I have pushed a fix to this branch.

The CI failure was mine: the rank change for SVG broke two existing tests in outputs.rs (test_rank_mime_type_ordering and test_rank_mime_type_unsupported_returns_zero, which asserted that SVG ranks 0). Both are updated now. Also rebased on main, and repl tests, clippy and fmt pass locally.

One thing worth a second opinion: I rank SVG above PNG, so a kernel that sends both shows the vector version. Happy to flip it if you would rather keep PNG first.

Could you reopen this PR, or would you prefer I open a new one?

@MrSubidubi

Copy link
Copy Markdown
Member
image

Cannot reopen, GitHub does still not work well with closed PRs and pushes.. Feel free to open a fresh PR, please

@ArneshBanerjee

Copy link
Copy Markdown
Contributor Author

@MrSubidubi no problem, opened a fresh one: #62889. Same branch and same commit, so the test fixes and the rebase are included.

Thanks for taking the time to look at this one.

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

Labels

area:repl repl, jupyter, notebooks, etc cla-signed The user has signed the Contributor License Agreement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SVG cell outputs render as Unsupported media type in the REPL and notebook editor

2 participants