--- a/src/features/artifact/review/components/SubmitForApprovalModal.tsx +++ b/src/features/artifact/review/components/SubmitForApprovalModal.tsx @@ -42,8 +42,9 @@ } from "@/components/ui/avatar"; import { Badge } from "@/components/ui/badge"; import { Button } from "@/components/ui/button"; import { Input } from "@/components/ui/input"; +import { Textarea } from "@/components/ui/textarea"; import { LazyVideoStill } from "@/components/common/lazy-video-still"; import { Modal, ModalContent, @@ -100,8 +101,10 @@ artifactIsAudio?: boolean; /** When present the modal edits this open request with a PATCH instead of creating one. */ editing?: { approvalId: string; + caption?: string | null; + note?: string | null; approverIds: string[]; // already ordered by stage approvalMode: "parallel" | "sequential"; requiredApprovals: number; }; @@ -120,8 +123,11 @@ // Lazy initializers: `editing` only seeds state on mount, never re-applies on rerender. const [approverIds, setApproverIds] = useState( () => editing?.approverIds ?? [] ); + const [caption, setCaption] = useState(() => editing?.caption ?? ""); + const [senderNote, setSenderNote] = useState(() => editing?.note ?? ""); + const contextId = useId(); const [search, setSearch] = useState(""); /** How many of those asked must say yes; `null` means everyone, and is the default. */ const [quorum, setQuorum] = useState(() => { if (!editing) return null; @@ -343,8 +349,16 @@ const submit = useMutation({ meta: { handlesOwnError: true }, mutationFn: async (): Promise<{ failed: number }> => { const input = { + ...(caption.trim() || + (editing?.caption && caption.trim() !== editing.caption.trim()) + ? { caption: caption.trim() } + : {}), + ...(senderNote.trim() || + (editing?.note && senderNote.trim() !== editing.note.trim()) + ? { note: senderNote.trim() } + : {}), approverIds, approvalMode: mode, // The server forces `requiredApprovals` to the panel size for sequential, // so it is only sent for parallel. @@ -717,8 +731,43 @@ ) ); + const contextFields = ( +
+ + {t("contextTitle")} + +

{t("contextHint")}

+
+ +