Skip to content

feat: Add screenshot export with Ctrl/Cmd+P#7

Merged
rsthornton merged 1 commit intomainfrom
claude/review-bert-pr-01Nrjfo1F8Y7wgnHsMXrQoe2
Dec 26, 2025
Merged

feat: Add screenshot export with Ctrl/Cmd+P#7
rsthornton merged 1 commit intomainfrom
claude/review-bert-pr-01Nrjfo1F8Y7wgnHsMXrQoe2

Conversation

@rsthornton
Copy link
Contributor

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, SaveSuccessEvent integration for toast notifications, and the Ctrl+P keybinding. 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:

Aspect Original PR #6 This PR
Timestamps chrono crate js_sys::Date (WASM-compatible)
File output save_to_disk() native I/O web_sys::Blob + anchor download
Platform gates #[cfg(not(wasm32))] None (runs in WASM)
Dependencies In desktop-only section In main [dependencies]

Why the changes were needed:

BERT's desktop build uses Tauri, which wraps a WASM webview - meaning target_arch is wasm32 even 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:

Note: Uses Ctrl+P (not Cmd+P on Mac), consistent with existing save shortcut behavior.

Closes #1

Test plan

  • Run trunk serve and press Ctrl+P - PNG downloads via browser
  • Run cargo tauri dev and press Ctrl+P - PNG saves to Downloads folder
  • Verify toast shows "Screenshot saved to Downloads: [filename]"
  • Verify timestamp format in filename

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
@rsthornton rsthornton force-pushed the claude/review-bert-pr-01Nrjfo1F8Y7wgnHsMXrQoe2 branch from 7d520a6 to 163037c Compare December 26, 2025 17:35
@rsthornton rsthornton merged commit 75ceaa8 into main Dec 26, 2025
1 check failed
@rsthornton rsthornton deleted the claude/review-bert-pr-01Nrjfo1F8Y7wgnHsMXrQoe2 branch December 26, 2025 17:42
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.

Add Screenshot Export Functionality

2 participants