Open-source, local-first AI agent for real work.
TypeScript agent-toolsai-agentbyokcoding-agentcross-platformdesktop-appdeveloper-toolselectronharnessknowledge-basellmwikilocal-firstmcpplugin-systemprivacy-firstskillstypescriptvettaworkflow-automation
import { StageDialogContent } from "@vetta-org/theme-ui/shared";
import { Dialog } from "radix-ui";
import { useState } from "react";
import { useTranslation } from "react-i18next";
import type { BrowserCapture } from "../../../shared/browser-capture";
import { toVettaFileUrl } from "@shared/lib/utils";
import { Button } from "./ui/button";
import { Textarea } from "./ui/textarea";
export function BrowserCaptureDialog({
capture,
onCancel,
onSave,
editing,
onCloseAutoFocus,
}: {
capture: BrowserCapture;
onCancel: () => void;
/** 不传即只读:对话历史里点开已发送的截图,只看不改。 */
onSave?: (note: string) => void;
editing?: boolean;
onCloseAutoFocus?: (event: Event) => void;
}) {
const { t } = useTranslation("chat");
const [note, setNote] = useState(capture.note);
return (
<Dialog.Root
open
onOpenChange={(open) => {
if (!open) onCancel();
}}
>
<StageDialogContent
onCloseAutoFocus={onCloseAutoFocus}
artwork={
<img
className="max-h-[75vh] w-[min(60vw,900px)] max-w-full rounded-xl object-contain"
src={toVettaFileUrl(capture.imagePath)}
alt={t("browserCapture.preview")}
/>
}
>
<Dialog.Title className="break-words text-xl font-semibold">
{capture.title || t("browserCapture.preview")}
</Dialog.Title>
<Dialog.Description className="mt-2 break-all text-xs text-muted-foreground">{capture.url}</Dialog.Description>
<p className="my-4 text-xs tabular-nums">
{capture.width} × {capture.height} PNG
</p>
{onSave ? (
<>
<label className="space-y-2 text-sm">
{t("browserCapture.note")}
<Textarea value={note} maxLength={10000} onChange={(event) => setNote(event.target.value)} />
</label>
<Button variant="primary" className="mt-6" onClick={() => onSave(note)}>
{t(editing ? "browserCapture.save" : "browserCapture.add")}
</Button>
<Button variant="ghost" className="mt-2" onClick={onCancel}>
{t("browserCapture.cancel")}
</Button>
</>
) : (
<>
{capture.note ? (
<p className="whitespace-pre-wrap break-words text-sm leading-relaxed">{capture.note}</p>
) : null}
<Button variant="secondary" className="mt-6" onClick={onCancel}>
{t("browserCapture.close")}
</Button>
</>
)}
</StageDialogContent>
</Dialog.Root>
);
}