Skip to content

feat: Preview PDF attachments in the modal#81

Open
akrost wants to merge 1 commit intoRasalas:mainfrom
akrost:feat/pdf-in-modal-preview
Open

feat: Preview PDF attachments in the modal#81
akrost wants to merge 1 commit intoRasalas:mainfrom
akrost:feat/pdf-in-modal-preview

Conversation

@akrost
Copy link
Copy Markdown

@akrost akrost commented Apr 10, 2026

Summary

Clicking a PDF attachment now opens the in-app preview modal (same as images and text), instead of triggering an immediate browser download or opening an external viewer on desktop.

Changes

  • Preview routing: *.pdf files with empty, application/octet-stream, or binary/octet-stream MIME are treated as PDFs so the attachment row uses "preview" instead of "download only" (which previously led to Save As on Tauri or a forced download in the browser).
  • Rendering: PDFs are shown in the modal via an <object> pointed at a blob: URL built from decoded attachment bytes; the blob URL is revoked when switching attachments or closing the modal.
  • Desktop: Removed the Tauri-only path that opened PDFs with the system default app and dropped the open_file_with_system Rust command and openWithSystemViewer bridge helper. Explicit download still uses Save As (save_file_with_dialog) or the browser download control.
  • Tests: Jest mocks URL.createObjectURL / revokeObjectURL; unit tests cover MIME/filename PDF detection and Tauri opening the modal for PDFs.
  • Docs: AGENTS.md updated to match the above.

Verification

  • cargo check (src-tauri): success
  • npm run lint, npm test, npm run build: success

Note: npm run format fails in this repo due to an invalid Prettier arrowParens value in config (pre-existing).

Made with Cursor

- Treat .pdf files with generic binary MIME as previewable (fixes download/Save As on row click)
- Render PDF preview via Blob URL in object; revoke on navigation and close
- Remove Tauri system-viewer PDF bypass and open_file_with_system command
- Mock URL.createObjectURL in Jest setup; update tests and AGENTS.md

Made-with: Cursor
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