Файли
openidea/src/features/agents/ImagePreview.tsx
T
l0ng-ai 47bd21e315 feat(agents): show images in sent messages (#439)
Images sent to an agent were dropped from the conversation: the user message kept only text and file chips. User entries now record their images and show them as thumbnails that open full size; composer thumbnails open the same preview. Editing a sent message keeps its images (removable) and rerunning from it sends them again.
2026-10-30 19:48:55 +08:00

23 рядки
774 B
TypeScript

import type { AgentImage } from "@/bindings";
import { useTx } from "@/platform/i18n";
import { Dialog } from "@/ui";
import styles from "./ImagePreview.module.css";
export const imageSrc = (img: AgentImage) => `data:${img.mimeType};base64,${img.data}`;
/** The full image in a dialog; `null` keeps it closed. */
export function ImagePreview({ image, onClose }: { image: AgentImage | null; onClose: () => void }) {
const tx = useTx();
return (
<Dialog
open={image !== null}
onClose={onClose}
title={image?.name ?? tx("Image")}
width="min(90vw, 1000px)"
buttons={[{ label: tx("Close"), role: "cancel" }]}
>
{image && <img className={styles.full} src={imageSrc(image)} alt={image.name ?? tx("Image")} />}
</Dialog>
);
}