Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
import { useState } from "react";
import { ZoomIn } from "lucide-react";
import { AttachmentPreviewDialog, type MessageAttachmentContext, type PreviewImage } from "@/components/AttachmentPreview";
import { t } from "@/lib/i18n";
import type { Message } from "@/state/store";
export function screenFramePreview(message: MessageAttachmentContext, mime = "image/png"): PreviewImage {
const src = `/api/threads/${encodeURIComponent(message.threadId)}/messages/${encodeURIComponent(message.messageId)}/image`;
return {
src,
name: t("chat.botScreen"),
downloadUrl: src,
downloadName: mime === "image/jpeg" ? "screen.jpg" : "screen.png",
};
}
export function ScreenFrame({ threadId, message }: { threadId: string; message: Message }) {
const [open, setOpen] = useState(false);
if (!message.hasImage && !message.png) return null;
const image = screenFramePreview({ threadId, messageId: message.id }, message.mime);
return (
<div className="flex justify-start">
<button
type="button"
onClick={() => setOpen(true)}
aria-label={t("attach.previewAria", { name: image.name })}
className="group/image relative w-fit max-w-[min(var(--chat-bubble-max),var(--chat-bubble-pct))] overflow-hidden rounded-2xl border border-hairline/40 text-left focus:outline-none focus-visible:ring-2 focus-visible:ring-accent"
>
<img
src={image.src}
alt={image.name}
className="block max-w-full transition duration-200 group-hover/image:scale-[1.015]"
/>
<span
aria-hidden
className="absolute right-2 top-2 flex size-7 items-center justify-center rounded-full bg-black/55 text-white opacity-0 backdrop-blur-sm transition-opacity group-hover/image:opacity-100 group-focus-within/image:opacity-100"
>
<ZoomIn size={13} />
</span>
</button>
{open && <AttachmentPreviewDialog image={image} onClose={() => setOpen(false)} />}
</div>
);
}