Open-source Grok Bot alternative for named AI teammates. Local-first desktop, web, and mobile clients with per-bot tools, instructions, and memory. Independent fork of T3 Code.
export interface ExpandedImageItem {
/** The chat attachment id, or a draft id for images not yet sent. */
id: string;
src: string;
name: string;
}
export interface ExpandedImagePreview {
images: ExpandedImageItem[];
index: number;
}
export function buildExpandedImagePreview(
images: ReadonlyArray<{ id: string; name: string; previewUrl?: string }>,
selectedImageId: string,
): ExpandedImagePreview | null {
const previewableImages = images.flatMap((image) =>
image.previewUrl ? [{ id: image.id, src: image.previewUrl, name: image.name }] : [],
);
if (previewableImages.length === 0) {
return null;
}
const selectedIndex = previewableImages.findIndex((image) => image.id === selectedImageId);
if (selectedIndex < 0) {
return null;
}
return {
images: previewableImages.map((image) => ({
id: image.id,
src: image.src,
name: image.name,
})),
index: selectedIndex,
};
}