Right-click / double-click on an image in the message body: add “Open” (default viewer, e.g. Preview on macOS)

The Problem

On macOS (Mailspring 1.26.0), right-clicking an image inside a message body shows only “Save Image…” and “Copy Image” (screenshot attached). There is no “Open” or “Open in Preview”, and double-clicking the image does nothing. To look at an image at full size or annotate it, I have to save it, go to Finder and open it from there.

For the email in my screenshot, the image also has no attachment chip under the message. So the attachment context menu (Open / Preview / Save, added in 1.6.3, #1548) isn’t available either.

Proposed Solution

  • Add an “Open” item to the context menu for images in the message body. It opens the image in the system default viewer, which is Preview on a default macOS setup. On macOS it could be labelled “Open in Preview” when Preview is the default app.
  • Optionally, make double-click on a body image do the same, matching double-click on an attachment chip.

Alternative Solutions

  • “Save Image…” and then opening the saved file. This is what I do now, and it takes several steps.
  • A built-in image viewer with zoom, as proposed in #923 / #234 (closed on GitHub when issues moved here). That would be nicer but is a much bigger feature. The simple “Open in default app” item would solve most of my use case.

Context

I couldn’t find an existing request for the context-menu / double-click variant, but I couldn’t search this forum with automated tools. Apologies if it’s a duplicate.

Notes from reading the 1.26.0 source (I haven’t run or tested any of this):

  • The body-image menu is built in app/src/components/evented-iframe.tsx (_onIFrameContextualMenu, around lines 309-469). The image branch adds only “Save Image…” and “Copy Image”.
  • The iframe subscribes to click, key*, mouse* and contextmenu (around lines 160-167). There is no dblclick listener, and I found no other dblclick handling for message bodies.
  • Inline cid: images are rewritten to file://<AttachmentStore path> in message-item-body.tsx (around line 159). Files referenced from the body are excluded from the attachment list in message-item.tsx (around lines 125-127). That would explain why there is no chip, and it means the item has to be added to the iframe menu rather than reusing the attachment one.
  • For file:// sources, calling shell.openPath on the local path (as attachment-store.ts already does for attachments) looks like it would be enough.

Open questions / caveats:

  • I haven’t confirmed whether the image in my screenshot is an inline cid: attachment or a remotely loaded image. The file:// shortcut above only applies to the former.
  • For remote (http/https) images there is no local file, so “Open” would presumably need to download to a temp file first. I haven’t looked at how or where remote images are cached, or whether the menu behaves differently for them.
  • I haven’t checked whether the downloaded file:// path could be cleaned up or replaced while an external app has it open.
  • “Opens in Preview” depends on the user’s default app for the file type.
  • No other mail client comparison: I haven’t verified how Thunderbird or Apple Mail handle this, so I’m not claiming parity with either.