feat: Add screenshot export with Ctrl/Cmd+P#7
Merged
rsthornton merged 1 commit intomainfrom Dec 26, 2025
Merged
Conversation
Implements screenshot capture functionality that works across all BERT deployment contexts (web browser and Tauri desktop). Key implementation details: - Uses web APIs (Blob + anchor download) instead of native file I/O - Works in WASM since BERT's Tauri desktop build uses a webview - Timestamps via js_sys::Date for WASM compatibility - PNG encoding via image crate - Integrates with existing SaveSuccessEvent for toast notifications This implementation builds on the approach proposed in PR #6 by @NehharShah, adapted for BERT's Tauri+WASM architecture where target_arch is always wasm32 even on desktop. Closes #1
7d520a6 to
163037c
Compare
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.
Summary
Adds screenshot capture functionality for BERT diagrams, triggered by
Ctrl+P. Screenshots are saved as timestamped PNG files to your Downloads folder (e.g.,bert_screenshot_2025-01-15_14-30-00.png).This implementation builds directly on the foundational work by @NehharShah in #6. Their PR established the core approach: Bevy 0.15's observer pattern for screenshot capture, timestamped filenames,
SaveSuccessEventintegration for toast notifications, and theCtrl+Pkeybinding. Without their initiative, this feature wouldn't have gotten started.The changes here adapt their implementation for BERT's specific architecture (see below).
What changed from #6:
chronocratejs_sys::Date(WASM-compatible)save_to_disk()native I/Oweb_sys::Blob+ anchor download#[cfg(not(wasm32))][dependencies]Why the changes were needed:
BERT's desktop build uses Tauri, which wraps a WASM webview - meaning
target_archiswasm32even on desktop. The original#[cfg(not(target_arch = "wasm32"))]gates prevented the code from compiling in any BERT context. This is a non-obvious architectural detail that caught us both!Technical approach:
js_sys::Datefor WASM-compatible timestampsweb_sys::Blob+HtmlAnchorElementfor browser downloadsSaveSuccessEventfor toast notifications (from feat: Add desktop screenshot export with Ctrl/Cmd+P shortcut #6)Note: Uses
Ctrl+P(notCmd+Pon Mac), consistent with existing save shortcut behavior.Closes #1
Test plan
trunk serveand pressCtrl+P- PNG downloads via browsercargo tauri devand pressCtrl+P- PNG saves to Downloads folder