Skip to content

feat(ui): save a screenshot with the 's' hotkey - #133

Merged
petercorke merged 2 commits into
jhavl:mainfrom
petercorke:feat/screenshot-hotkey
Aug 22, 2026
Merged

feat(ui): save a screenshot with the 's' hotkey#133
petercorke merged 2 commits into
jhavl:mainfrom
petercorke:feat/screenshot-hotkey

Conversation

@petercorke

Copy link
Copy Markdown
Collaborator

Summary

  • Pressing s anywhere in the browser tab (outside a text input) saves a PNG of the current view, named swift-YYYY-MM-DD_HH-MM-SS.png
  • Ctrl/Cmd/Alt+S is left alone so the browser's own "Save Page As" still works
  • Same download mechanism env.screenshot() already uses (canvas → dataURL → synthetic <a download> click), just triggered client-side with no Python round-trip
  • Extracted saveScreenshot() and the new timestamp helper out of main.js into their own screenshot.js module, matching how ui.js/comms.js are already split out for unit testing under node --testmain.js itself has DOM/WebGL side effects at import time that make it untestable directly
  • Documented the new hotkey in README.md and docs/source/intro.rst's "Playback controls" sections, alongside the existing spacebar/speed-selector bullets

Test plan

  • node --test src/swift/public/js/*.test.js — new screenshot.test.js covers the timestamp format and the download-link wiring
  • pytest — no regressions (one pre-existing, unrelated failure: test_add_path_sends_points_radius_and_linewidth, caused by the installed spatialgeometry PyPI release lagging behind an unreleased Polyline rename)
  • Manual check in a real browser tab: press s, confirm a swift-<timestamp>.png downloads

🤖 Generated with Claude Code

Pressing 's' anywhere in the browser tab (outside a text input, and not
combined with Ctrl/Cmd/Alt so the browser's own Save-Page-As still works)
saves a PNG of the current view, named swift-YYYY-MM-DD_HH-MM-SS.png --
the same download mechanism env.screenshot() already uses, just triggered
client-side.

Extracted saveScreenshot()/the new timestamp helper out of main.js into
their own screenshot.js module, matching how ui.js/comms.js are already
split out for unit testing -- main.js itself has DOM/WebGL side effects
at import time that make it untestable directly under node:test.
@petercorke
petercorke merged commit e942b08 into jhavl:main Aug 22, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant