Skip to content

Add screenshot export feature#9

Open
AbdullahSAhmad wants to merge 2 commits intomasterfrom
strata/wi-1-9d1e
Open

Add screenshot export feature#9
AbdullahSAhmad wants to merge 2 commits intomasterfrom
strata/wi-1-9d1e

Conversation

@AbdullahSAhmad
Copy link
Collaborator

Summary

  • Adds a new Screenshot Export feature that captures the Pixi.js canvas as a PNG image
  • Supports viewport (current view) and full-world (all 9 zones) capture modes via a toggle in the preview modal
  • Preview modal shows the captured image with Download PNG and Copy to Clipboard actions
  • Accessible via Shift+E keyboard shortcut, command palette entry, and camera button in zoom controls

Files Changed

  • NEW packages/client/src/ui/screenshot-export.ts — Core capture logic + preview modal (210 lines)
  • packages/client/src/main.ts — Wire up module, action handler, keyboard shortcut, cleanup
  • packages/client/src/ui/command-palette.ts — Add screenshot command entry
  • packages/client/src/ui/shortcuts-help.ts — Add Shift+E shortcut documentation
  • packages/client/index.html — Add camera button to zoom controls
  • packages/client/styles/modals.css — Add screenshot export modal styles

Technical Details

  • Viewport capture: Uses canvas.toBlob() for direct canvas-to-PNG conversion
  • Full-world capture: Temporarily resets camera to fit-to-view, renders a frame, captures, then restores camera state
  • Clipboard: Uses navigator.clipboard.write() with ClipboardItem for image copy; falls back to opening in new tab
  • Follows existing patterns: modal structure matches SessionExport, CSS prefix sse-, consistent z-index

Test plan

  • Press Shift+E to open screenshot modal — verify viewport preview appears
  • Toggle to "Full World" — verify all 9 zones are visible in preview
  • Toggle back to "Viewport" — verify it recaptures current view
  • Click "Download PNG" — verify PNG file downloads with correct filename
  • Click "Copy to Clipboard" — verify image can be pasted
  • Click camera button in zoom controls — verify modal opens
  • Open command palette (Ctrl+K), search "screenshot" — verify command appears and works
  • Press ? — verify Shift+E shortcut is listed in help
  • Close modal via backdrop click, X button, and Escape key

🤖 Generated with Claude Code

Strata Agent and others added 2 commits March 19, 2026 14:07
Captures the Pixi canvas as PNG with viewport/full-world toggle,
preview modal, download, and clipboard copy. Accessible via Shift+E,
command palette, and camera button in zoom controls.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Set up vitest + jsdom test infrastructure in the client package and add 33 tests covering the ScreenshotExport class: DOM structure, open/close/toggle lifecycle, viewport and full-world capture modes, download with filename patterns, clipboard copy with fallback, close triggers, dispose cleanup, and preview image display.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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