From 32409c12bfc6d5031cfe19bc89d3dbd1edda14d7 Mon Sep 17 00:00:00 2001 From: Ignacio Cervino Date: Mon, 19 Jan 2026 23:40:17 -0300 Subject: [PATCH 1/2] Add attachment hover previews --- .../components/ComposerAttachments.tsx | 33 ++++++++++-- .../ComposerInput.attachments.test.tsx | 4 ++ src/styles/composer.css | 52 +++++++++++++++++++ 3 files changed, 86 insertions(+), 3 deletions(-) diff --git a/src/features/composer/components/ComposerAttachments.tsx b/src/features/composer/components/ComposerAttachments.tsx index e9496be4e..a9da9fee6 100644 --- a/src/features/composer/components/ComposerAttachments.tsx +++ b/src/features/composer/components/ComposerAttachments.tsx @@ -1,3 +1,4 @@ +import { convertFileSrc } from "@tauri-apps/api/core"; import { Image, X } from "lucide-react"; type ComposerAttachmentsProps = { @@ -18,6 +19,20 @@ function fileTitle(path: string) { return parts.length ? parts[parts.length - 1] : path; } +function attachmentPreviewSrc(path: string) { + if (path.startsWith("data:")) { + return path; + } + if (path.startsWith("http://") || path.startsWith("https://")) { + return path; + } + try { + return convertFileSrc(path); + } catch { + return ""; + } +} + export function ComposerAttachments({ attachments, disabled, @@ -32,15 +47,27 @@ export function ComposerAttachments({ {attachments.map((path) => { const title = fileTitle(path); const titleAttr = path.startsWith("data:") ? "Pasted image" : path; + const previewSrc = attachmentPreviewSrc(path); return (
- - - + {previewSrc && ( + + + + )} + {previewSrc ? ( + + + + ) : ( + + + + )} {title}