Repository navigation
Widget: a Download on each figure a run shows - #505
Merged
Merged
Conversation
Contributor
Preview Deployment
This preview will be updated automatically when you push new commits. |
14 of 24 tasks
neuromechanist
force-pushed
the
feature/issue-491-run-code
branch
from
September 25, 2026 00:53
5b0c894 to
ef106ee
Compare
neuromechanist
force-pushed
the
feature/issue-492-figure-download
branch
from
September 25, 2026 00:56
97dd342 to
af98c70
Compare
Member
Author
Review responseRebased onto #503's updated branch (
Skipped: the click-time recount could in theory diverge from the rendered label if a record changed without a re-render. Every change to a run's figures goes through Widget suites: tools 424, pop-out 140, capsule 133, color scheme 128, notebook tab 168, first paint 82, dataset questions 60. |
Each figure gets a Download button over its corner that saves its exact PNG, built from the run record's base64, as <dataset>-run-<n>-figure-<k>.png, k counting the figures shown. It is a real, labeled button; the figure's alt text is numbered to match. The echo under an open editor names the reader's run. Tested: bun frontend/test-widget-tools.js (407 passed, 22 new); ten mutations each caught and restored; a real Enter press on it saved the PNG byte for byte in headless Chrome.
Tested: docs only.
The button moves from over the figure's top-right corner, where matplotlib often puts a legend, to a right-aligned row under it, in the panel's colors like the code block's bar. Label, aria-label and numbering are unchanged. Tested: bun frontend/test-widget-tools.js (424 passed); placing it back over the figure, dropping the right alignment, putting it before the figure, or fixing its colors each fail it; checked in Chrome.
Tested: docs only.
neuromechanist
force-pushed
the
feature/issue-492-figure-download
branch
from
September 25, 2026 01:01
af98c70 to
e3c87fa
Compare
The attribute-escaping drift test flagged the three data-* indices. String() first, since happy-dom renders textContent = 0 as empty. Tested: pytest 2923 passed (drift test green), every Bun suite (tools 424), ruff
2 tasks
This was referenced Sep 25, 2026
Merged
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Closes #492
Stacked on #503 (issue #491): its base is
feature/issue-491-run-code, because it reuses that PR'ssaveFiledownload helper andrunFileStemnaming, and the run markup it adds figures' buttons to. The diff below is this issue's alone; once #503 merges I will rebase this ontodevelopand retarget it.What
Each figure a run shows gets a Download button in a right-aligned row under it (never over the figure, where a legend often sits), which saves that figure's PNG, byte for byte, as
<dataset>-run-<n>-figure-<k>.png(for examplenm000132-run-3-figure-1.png).pngBytes), in animage/pngBlob throughsaveFile. The click re-reads the record bydata-msg-index/data-run-index/data-image-indexand re-checksisShowableImage, so a stale button saves nothing rather than other bytes under a.pngname.<k>is the figure's number among the figures the run shows (a figure the widget will not show is skipped), as the workspace names a run'sfigure-K.png;<dataset>-run-<n>is Widget: show a run's code in place, with Copy and Download #491's run name.<button type="button">with visible text ("Download"), anaria-labelnaming the figure and the file (Download figure 1 as nm000132-run-3-figure-1.png), and atitle. The figure's alternative text is numbered to match (Figure 1 produced by the code, wasFigure produced by the code).fit-content), so the row ends where the figure does, however narrow it is.executionsHtmlwithoutmsgIndex) the figures render exactly as before, with no wrapper or button.Done when
frontend/test-widget-tools.js, 22 new checks (407 in all): the markup for a run with an unshowable figure ahead of two PNGs (only ours, one button per shown figure, numbered 1 and 2, labels and alt text, real buttons with visible text); the bytes of each saved file equal its PNG's decoded base64, signature included, asimage/png, namednm000132-run-2-figure-2.pngand-figure-1.png; a stale button saves nothing; the echo's figure namednm000132-run-3-figure-1.pngand saving its PNG; no button without a reply to act on or without figures.docs/community-widget.md("A run in the chat") and CHANGELOG updated.Also checked by hand in headless Chrome 153 against
widget_e2e.py(scripted "plot", real Pyodide): the figure's Download takes focus, a real Enter key press on it (Input.dispatchKeyEventwithtext: '\r') started a download suggested asnm000132-run-1-figure-1.png, and the saved file equals the figure's base64, byte for byte (41,625 bytes). Not committed, since it needs the network for Pyodide.Mutation checks
Each applied alone, the suite run, restored, and the restore confirmed by comparing
git diff --statbefore and after. All 10 caught:aria-labeltabindex="-1"Other suites
Widget suites: tools 407, capsule 133, color scheme 128, notebook tab 168, first paint 82, dataset questions 60, pop-out 132; the runtime bundle is current. No Python change.