Fix image uploads using the wrong format (#2380)

* fix(app): preserve image attachment MIME types

Image intake discarded clipboard and desktop path metadata, then guessed JPEG when a later file object had no type. Resolve MIME once at the platform boundary and require it downstream.

* fix(app): honor native picker MIME metadata
This commit is contained in:
Mohamed Boudra
2026-07-24 21:11:41 +08:00
committed by GitHub
parent 967edab497
commit 21597bdc1b
13 changed files with 198 additions and 54 deletions
@@ -5,7 +5,7 @@ import { useTranslation } from "react-i18next";
import { getDesktopHost, isElectronRuntime } from "@/desktop/host";
import {
normalizePickedImageAssets,
openImagePathsWithDesktopDialog,
pickImagesWithDesktopDialog,
type PickedImageAttachmentInput,
} from "@/hooks/image-attachment-picker";
import { isWeb } from "@/constants/platform";
@@ -51,15 +51,11 @@ export function useImageAttachmentPicker(): UseImageAttachmentPickerResult {
try {
if (isWeb && isElectronRuntime()) {
const selectedPaths = await openImagePathsWithDesktopDialog(getDesktopHost()?.dialog);
if (selectedPaths.length === 0) {
const selectedImages = await pickImagesWithDesktopDialog(getDesktopHost()?.dialog);
if (selectedImages.length === 0) {
return null;
}
return selectedPaths.map((path) => ({
source: { kind: "file_uri" as const, uri: path },
mimeType: null,
fileName: null,
}));
return selectedImages;
}
const hasPermission = await ensurePermission();