From a04a94f268e06245c5d81e01ce3a3681147de8dd Mon Sep 17 00:00:00 2001 From: Avi Gaba Date: Mon, 30 Mar 2026 13:54:37 +0530 Subject: [PATCH 1/4] Refine agent visibility controls and browsing filters --- components/Agents/AgentEditDialog.tsx | 30 +++++++++------ components/Agents/AgentVisibilityControl.tsx | 38 +++++++++++++++++++ components/Agents/Agents.tsx | 36 +++++++++++++++--- components/Agents/CreateAgentDialog.tsx | 16 +++++++- components/Agents/CreateAgentForm.tsx | 40 ++++++-------------- components/Agents/PrivacySection.tsx | 40 +++++++++++--------- components/Agents/TagSelector.tsx | 19 +++++++++- components/Agents/useAgentForm.ts | 30 +++++++++++++++ 8 files changed, 182 insertions(+), 67 deletions(-) create mode 100644 components/Agents/AgentVisibilityControl.tsx create mode 100644 components/Agents/useAgentForm.ts diff --git a/components/Agents/AgentEditDialog.tsx b/components/Agents/AgentEditDialog.tsx index 703151aaa..80bbb5209 100644 --- a/components/Agents/AgentEditDialog.tsx +++ b/components/Agents/AgentEditDialog.tsx @@ -14,6 +14,7 @@ import { useMutation, useQueryClient } from "@tanstack/react-query"; import { useUserProvider } from "@/providers/UserProvder"; import type { AgentTemplateRow } from "@/types/AgentTemplates"; import { useState, useEffect } from "react"; +import { useAgentForm } from "./useAgentForm"; interface AgentEditDialogProps { agent: AgentTemplateRow; @@ -24,6 +25,14 @@ const AgentEditDialog: React.FC = ({ agent }) => { const { userData } = useUserProvider(); const queryClient = useQueryClient(); const [currentSharedEmails, setCurrentSharedEmails] = useState(agent.shared_emails || []); + const form = useAgentForm({ + title: agent.title, + description: agent.description, + prompt: agent.prompt, + tags: agent.tags ?? [], + isPrivate: agent.is_private, + shareEmails: [], + }); const editTemplate = useMutation({ mutationFn: async (values: { @@ -81,8 +90,16 @@ const AgentEditDialog: React.FC = ({ agent }) => { useEffect(() => { if (open) { setCurrentSharedEmails(agent.shared_emails || []); + form.reset({ + title: agent.title, + description: agent.description, + prompt: agent.prompt, + tags: agent.tags ?? [], + isPrivate: agent.is_private, + shareEmails: [], + }); } - }, [open, agent.shared_emails]); + }, [open, agent, form]); return ( @@ -97,16 +114,9 @@ const AgentEditDialog: React.FC = ({ agent }) => { Update the agent template details. = ({ agent }) => { }; export default AgentEditDialog; - - diff --git a/components/Agents/AgentVisibilityControl.tsx b/components/Agents/AgentVisibilityControl.tsx new file mode 100644 index 000000000..d0eacbda0 --- /dev/null +++ b/components/Agents/AgentVisibilityControl.tsx @@ -0,0 +1,38 @@ +import { UseFormReturn } from "react-hook-form"; +import { Switch } from "@/components/ui/switch"; +import { CreateAgentFormData } from "./schemas"; + +interface AgentVisibilityControlProps { + form: UseFormReturn; +} + +const AgentVisibilityControl = ({ form }: AgentVisibilityControlProps) => { + const isPrivate = form.watch("isPrivate"); + + return ( +
+ + Public + + + form.setValue("isPrivate", checked, { + shouldDirty: true, + shouldValidate: true, + }) + } + /> + + Private + +
+ ); +}; + +export default AgentVisibilityControl; diff --git a/components/Agents/Agents.tsx b/components/Agents/Agents.tsx index f9f12c672..16d8219fa 100644 --- a/components/Agents/Agents.tsx +++ b/components/Agents/Agents.tsx @@ -1,12 +1,12 @@ import { useRouter } from "next/navigation"; import React from "react"; +import { cn } from "@/lib/utils"; import AgentTags from "./AgentTags"; import AgentCard from "./AgentCard"; import { useAgentData } from "./useAgentData"; import { useAgentToggleFavorite } from "./useAgentToggleFavorite"; import type { Agent } from "./useAgentData"; import CreateAgentButton from "./CreateAgentButton"; -import { Switch } from "@/components/ui/switch"; import AgentsSkeleton from "./AgentsSkeleton"; const Agents = () => { @@ -35,11 +35,35 @@ const Agents = () => { Agents
-
- - {isPrivate ? "Private" : "Public"} - - togglePrivate()} /> +
+ +
diff --git a/components/Agents/CreateAgentDialog.tsx b/components/Agents/CreateAgentDialog.tsx index bbcac6a10..cce58ac16 100644 --- a/components/Agents/CreateAgentDialog.tsx +++ b/components/Agents/CreateAgentDialog.tsx @@ -7,10 +7,11 @@ import { DialogTrigger, } from "@/components/ui/dialog"; import CreateAgentForm from "./CreateAgentForm"; -import { useState } from "react"; +import { useEffect, useState } from "react"; import { type CreateAgentFormData } from "./schemas"; import { useMutation, useQueryClient } from "@tanstack/react-query"; import { useUserProvider } from "@/providers/UserProvder"; +import { useAgentForm } from "./useAgentForm"; interface CreateAgentDialogProps { children: React.ReactNode; @@ -20,6 +21,7 @@ const CreateAgentDialog = ({ children }: CreateAgentDialogProps) => { const [open, setOpen] = useState(false); const { userData } = useUserProvider(); const queryClient = useQueryClient(); + const form = useAgentForm(); const createTemplate = useMutation({ mutationFn: async (values: CreateAgentFormData) => { @@ -44,6 +46,12 @@ const CreateAgentDialog = ({ children }: CreateAgentDialogProps) => { createTemplate.mutate(values); }; + useEffect(() => { + if (!open) { + form.reset(); + } + }, [form, open]); + return ( {children} @@ -56,7 +64,11 @@ const CreateAgentDialog = ({ children }: CreateAgentDialogProps) => { Create a new intelligent agent to help manage your roster tasks. - + ); diff --git a/components/Agents/CreateAgentForm.tsx b/components/Agents/CreateAgentForm.tsx index 03ceb38b4..8a48f21f5 100644 --- a/components/Agents/CreateAgentForm.tsx +++ b/components/Agents/CreateAgentForm.tsx @@ -1,45 +1,27 @@ -import { useForm } from "react-hook-form"; -import { zodResolver } from "@hookform/resolvers/zod"; -import { useEffect } from "react"; -import { createAgentSchema, type CreateAgentFormData } from "./schemas"; +import { UseFormReturn } from "react-hook-form"; +import { type CreateAgentFormData } from "./schemas"; import FormFields from "./FormFields"; import TagSelector from "./TagSelector"; import PrivacySection from "./PrivacySection"; import SubmitButton from "./SubmitButton"; interface CreateAgentFormProps { + form: UseFormReturn; onSubmit: (values: CreateAgentFormData) => void; isSubmitting?: boolean; - initialValues?: Partial; submitLabel?: string; existingSharedEmails?: string[]; onExistingEmailsChange?: (emails: string[]) => void; } -const CreateAgentForm = ({ onSubmit, isSubmitting, initialValues, submitLabel, existingSharedEmails, onExistingEmailsChange }: CreateAgentFormProps) => { - const form = useForm({ - resolver: zodResolver(createAgentSchema), - defaultValues: { - title: initialValues?.title ?? "", - description: initialValues?.description ?? "", - prompt: initialValues?.prompt ?? "", - tags: initialValues?.tags ?? [], - isPrivate: initialValues?.isPrivate ?? false, - shareEmails: initialValues?.shareEmails ?? [], - }, - }); - - const isPrivate = form.watch("isPrivate"); - - // Ensure shareEmails is initialized when private is toggled - useEffect(() => { - if (!isPrivate) { - form.setValue("shareEmails", []); - } else if (!form.getValues("shareEmails")) { - form.setValue("shareEmails", []); - } - }, [isPrivate, form]); - +const CreateAgentForm = ({ + form, + onSubmit, + isSubmitting, + submitLabel, + existingSharedEmails, + onExistingEmailsChange, +}: CreateAgentFormProps) => { return (
diff --git a/components/Agents/PrivacySection.tsx b/components/Agents/PrivacySection.tsx index 8b6a64141..f95aba8ed 100644 --- a/components/Agents/PrivacySection.tsx +++ b/components/Agents/PrivacySection.tsx @@ -1,8 +1,8 @@ import { UseFormReturn } from "react-hook-form"; import { Label } from "@/components/ui/label"; -import { Switch } from "@/components/ui/switch"; import { CreateAgentFormData } from "./schemas"; import EmailShareInput from "./EmailShareInput"; +import AgentVisibilityControl from "./AgentVisibilityControl"; interface PrivacySectionProps { form: UseFormReturn; @@ -14,27 +14,31 @@ const PrivacySection = ({ form, existingSharedEmails = [], onExistingEmailsChang const isPrivate = form.watch("isPrivate"); return ( - <> -
- form.setValue("isPrivate", checked)} - /> - +
+
+ +
{isPrivate && ( - { - form.setValue("shareEmails", emails, { shouldDirty: true, shouldValidate: true }); - }} - onExistingEmailsChange={onExistingEmailsChange} - /> +
+

+ Add email addresses for the people who should be able to view this private agent. +

+ + { + form.setValue("shareEmails", emails, { shouldDirty: true, shouldValidate: true }); + }} + onExistingEmailsChange={onExistingEmailsChange} + /> +
)} - +
); }; diff --git a/components/Agents/TagSelector.tsx b/components/Agents/TagSelector.tsx index 70190e640..3966590a7 100644 --- a/components/Agents/TagSelector.tsx +++ b/components/Agents/TagSelector.tsx @@ -4,12 +4,29 @@ import { Badge } from "@/components/ui/badge"; import { useAgentData } from "./useAgentData"; import { CreateAgentFormData } from "./schemas"; +const FALLBACK_TAGS = [ + "Create", + "Connect", + "Report", + "Plan", + "onboarding", + "role:manager", + "role:label", + "role:marketing", + "role:artist", + "role:pr", + "Research", +]; + interface TagSelectorProps { form: UseFormReturn; } const TagSelector = ({ form }: TagSelectorProps) => { const { tags } = useAgentData(); + const availableTags = Array.from( + new Set([...tags.filter((t) => t !== "Recommended"), ...FALLBACK_TAGS]) + ); const selectedTags = form.watch("tags") ?? []; const toggleTag = (tag: string) => { @@ -24,7 +41,7 @@ const TagSelector = ({ form }: TagSelectorProps) => {
- {tags.filter((t) => t !== "Recommended").map((tag) => { + {availableTags.map((tag) => { const isSelected = selectedTags.includes(tag); return ( ) { + const form = useForm({ + resolver: zodResolver(createAgentSchema), + defaultValues: { + title: initialValues?.title ?? "", + description: initialValues?.description ?? "", + prompt: initialValues?.prompt ?? "", + tags: initialValues?.tags ?? [], + isPrivate: initialValues?.isPrivate ?? false, + shareEmails: initialValues?.shareEmails ?? [], + }, + }); + + const isPrivate = form.watch("isPrivate"); + + useEffect(() => { + if (!isPrivate) { + form.setValue("shareEmails", []); + } else if (!form.getValues("shareEmails")) { + form.setValue("shareEmails", []); + } + }, [isPrivate, form]); + + return form; +} From a88961067bd4ea3bd686673aff0518743aefae93 Mon Sep 17 00:00:00 2001 From: Avi Gaba Date: Mon, 30 Mar 2026 14:37:21 +0530 Subject: [PATCH 2/4] Fix agent dialog review regressions --- components/Agents/AgentEditDialog.tsx | 5 +++-- components/Agents/AgentVisibilityControl.tsx | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/components/Agents/AgentEditDialog.tsx b/components/Agents/AgentEditDialog.tsx index 80bbb5209..7054a1d4f 100644 --- a/components/Agents/AgentEditDialog.tsx +++ b/components/Agents/AgentEditDialog.tsx @@ -86,7 +86,8 @@ const AgentEditDialog: React.FC = ({ agent }) => { setCurrentSharedEmails(emails); }; - // Reset current shared emails when dialog opens or agent changes + // Reset form state when the dialog opens for a specific agent, but do not + // clobber in-progress edits on background refetches. useEffect(() => { if (open) { setCurrentSharedEmails(agent.shared_emails || []); @@ -99,7 +100,7 @@ const AgentEditDialog: React.FC = ({ agent }) => { shareEmails: [], }); } - }, [open, agent, form]); + }, [open, agent.id, form]); return ( diff --git a/components/Agents/AgentVisibilityControl.tsx b/components/Agents/AgentVisibilityControl.tsx index d0eacbda0..de41dc15c 100644 --- a/components/Agents/AgentVisibilityControl.tsx +++ b/components/Agents/AgentVisibilityControl.tsx @@ -19,6 +19,7 @@ const AgentVisibilityControl = ({ form }: AgentVisibilityControlProps) => { form.setValue("isPrivate", checked, { shouldDirty: true, From 2a2d67052dfbc7aca13a55b0b0b2a9d4d63746cc Mon Sep 17 00:00:00 2001 From: Avi Gaba Date: Tue, 31 Mar 2026 01:52:21 +0530 Subject: [PATCH 3/4] Refactor agents visibility and form ownership --- components/Agents/AgentEditDialog.tsx | 65 ++++---------------- components/Agents/AgentVisibilityControl.tsx | 2 +- components/Agents/Agents.tsx | 36 ++--------- components/Agents/AgentsVisibilityFilter.tsx | 52 ++++++++++++++++ components/Agents/CreateAgentDialog.tsx | 2 +- components/Agents/EmailShareInput.tsx | 4 ++ components/Agents/PrivacySection.tsx | 8 +-- components/Agents/TagSelector.tsx | 18 +----- {components/Agents => hooks}/useAgentForm.ts | 5 +- hooks/useEditAgentTemplate.ts | 52 ++++++++++++++++ 10 files changed, 132 insertions(+), 112 deletions(-) create mode 100644 components/Agents/AgentsVisibilityFilter.tsx rename {components/Agents => hooks}/useAgentForm.ts (90%) create mode 100644 hooks/useEditAgentTemplate.ts diff --git a/components/Agents/AgentEditDialog.tsx b/components/Agents/AgentEditDialog.tsx index 7054a1d4f..86016bdb6 100644 --- a/components/Agents/AgentEditDialog.tsx +++ b/components/Agents/AgentEditDialog.tsx @@ -10,11 +10,11 @@ import { import { Button } from "@/components/ui/button"; import { Pencil } from "lucide-react"; import CreateAgentForm from "./CreateAgentForm"; -import { useMutation, useQueryClient } from "@tanstack/react-query"; -import { useUserProvider } from "@/providers/UserProvder"; import type { AgentTemplateRow } from "@/types/AgentTemplates"; import { useState, useEffect } from "react"; -import { useAgentForm } from "./useAgentForm"; +import { type CreateAgentFormData } from "./schemas"; +import { useAgentForm } from "@/hooks/useAgentForm"; +import { useEditAgentTemplate } from "@/hooks/useEditAgentTemplate"; interface AgentEditDialogProps { agent: AgentTemplateRow; @@ -22,9 +22,9 @@ interface AgentEditDialogProps { const AgentEditDialog: React.FC = ({ agent }) => { const [open, setOpen] = useState(false); - const { userData } = useUserProvider(); - const queryClient = useQueryClient(); - const [currentSharedEmails, setCurrentSharedEmails] = useState(agent.shared_emails || []); + const [currentSharedEmails, setCurrentSharedEmails] = useState( + agent.shared_emails || [] + ); const form = useAgentForm({ title: agent.title, description: agent.description, @@ -33,55 +33,12 @@ const AgentEditDialog: React.FC = ({ agent }) => { isPrivate: agent.is_private, shareEmails: [], }); - - const editTemplate = useMutation({ - mutationFn: async (values: { - title?: string; - description?: string; - prompt?: string; - tags?: string[]; - isPrivate?: boolean; - shareEmails?: string[]; - }) => { - // Combine existing emails (after removals) with new emails - const finalShareEmails = values.shareEmails && values.shareEmails.length > 0 - ? [...currentSharedEmails, ...values.shareEmails] - : currentSharedEmails; - - const res = await fetch("/api/agent-templates", { - method: "PATCH", - headers: { "Content-Type": "application/json" }, - body: JSON.stringify({ - id: agent.id, - userId: userData?.id, - title: values.title, - description: values.description, - prompt: values.prompt, - tags: values.tags, - isPrivate: values.isPrivate, - shareEmails: finalShareEmails, - }), - }); - if (!res.ok) throw new Error("Failed to update template"); - return res.json(); - }, - onSuccess: () => { - queryClient.invalidateQueries({ queryKey: ["agent-templates"] }); - setOpen(false); - }, + const editTemplate = useEditAgentTemplate({ + agent, + currentSharedEmails, + onSuccess: () => setOpen(false), }); - const onSubmit = (values: { - title: string; - description: string; - prompt: string; - tags: string[]; - isPrivate: boolean; - shareEmails?: string[]; - }) => { - editTemplate.mutate(values); - }; - const handleExistingEmailsChange = (emails: string[]) => { setCurrentSharedEmails(emails); }; @@ -116,7 +73,7 @@ const AgentEditDialog: React.FC = ({ agent }) => { editTemplate.mutate(values)} isSubmitting={editTemplate.isPending} existingSharedEmails={currentSharedEmails} onExistingEmailsChange={handleExistingEmailsChange} diff --git a/components/Agents/AgentVisibilityControl.tsx b/components/Agents/AgentVisibilityControl.tsx index de41dc15c..6872dcdb5 100644 --- a/components/Agents/AgentVisibilityControl.tsx +++ b/components/Agents/AgentVisibilityControl.tsx @@ -19,7 +19,7 @@ const AgentVisibilityControl = ({ form }: AgentVisibilityControlProps) => { form.setValue("isPrivate", checked, { shouldDirty: true, diff --git a/components/Agents/Agents.tsx b/components/Agents/Agents.tsx index 16d8219fa..a6e8be113 100644 --- a/components/Agents/Agents.tsx +++ b/components/Agents/Agents.tsx @@ -1,6 +1,5 @@ import { useRouter } from "next/navigation"; import React from "react"; -import { cn } from "@/lib/utils"; import AgentTags from "./AgentTags"; import AgentCard from "./AgentCard"; import { useAgentData } from "./useAgentData"; @@ -8,6 +7,7 @@ import { useAgentToggleFavorite } from "./useAgentToggleFavorite"; import type { Agent } from "./useAgentData"; import CreateAgentButton from "./CreateAgentButton"; import AgentsSkeleton from "./AgentsSkeleton"; +import AgentsVisibilityFilter from "./AgentsVisibilityFilter"; const Agents = () => { const { push } = useRouter(); @@ -35,36 +35,10 @@ const Agents = () => { Agents
-
- - -
+
diff --git a/components/Agents/AgentsVisibilityFilter.tsx b/components/Agents/AgentsVisibilityFilter.tsx new file mode 100644 index 000000000..f3905ad46 --- /dev/null +++ b/components/Agents/AgentsVisibilityFilter.tsx @@ -0,0 +1,52 @@ +import { cn } from "@/lib/utils"; + +interface AgentsVisibilityFilterProps { + isPrivate: boolean; + togglePrivate: () => void; +} + +const AgentsVisibilityFilter = ({ + isPrivate, + togglePrivate, +}: AgentsVisibilityFilterProps) => { + return ( +
+ + +
+ ); +}; + +export default AgentsVisibilityFilter; diff --git a/components/Agents/CreateAgentDialog.tsx b/components/Agents/CreateAgentDialog.tsx index cce58ac16..c406ad264 100644 --- a/components/Agents/CreateAgentDialog.tsx +++ b/components/Agents/CreateAgentDialog.tsx @@ -11,7 +11,7 @@ import { useEffect, useState } from "react"; import { type CreateAgentFormData } from "./schemas"; import { useMutation, useQueryClient } from "@tanstack/react-query"; import { useUserProvider } from "@/providers/UserProvder"; -import { useAgentForm } from "./useAgentForm"; +import { useAgentForm } from "@/hooks/useAgentForm"; interface CreateAgentDialogProps { children: React.ReactNode; diff --git a/components/Agents/EmailShareInput.tsx b/components/Agents/EmailShareInput.tsx index 90196d4f1..e2e9ca7ac 100644 --- a/components/Agents/EmailShareInput.tsx +++ b/components/Agents/EmailShareInput.tsx @@ -57,6 +57,10 @@ const EmailShareInput = ({ emails, existingSharedEmails = [], onEmailsChange, on return (
+

+ Add email addresses for the people who should be able to view this + private agent. +

{isPrivate && ( -
-

- Add email addresses for the people who should be able to view this private agent. -

- - { @@ -36,7 +31,6 @@ const PrivacySection = ({ form, existingSharedEmails = [], onExistingEmailsChang }} onExistingEmailsChange={onExistingEmailsChange} /> -
)}
); diff --git a/components/Agents/TagSelector.tsx b/components/Agents/TagSelector.tsx index 3966590a7..18c371899 100644 --- a/components/Agents/TagSelector.tsx +++ b/components/Agents/TagSelector.tsx @@ -4,29 +4,13 @@ import { Badge } from "@/components/ui/badge"; import { useAgentData } from "./useAgentData"; import { CreateAgentFormData } from "./schemas"; -const FALLBACK_TAGS = [ - "Create", - "Connect", - "Report", - "Plan", - "onboarding", - "role:manager", - "role:label", - "role:marketing", - "role:artist", - "role:pr", - "Research", -]; - interface TagSelectorProps { form: UseFormReturn; } const TagSelector = ({ form }: TagSelectorProps) => { const { tags } = useAgentData(); - const availableTags = Array.from( - new Set([...tags.filter((t) => t !== "Recommended"), ...FALLBACK_TAGS]) - ); + const availableTags = tags.filter((tag) => tag !== "Recommended"); const selectedTags = form.watch("tags") ?? []; const toggleTag = (tag: string) => { diff --git a/components/Agents/useAgentForm.ts b/hooks/useAgentForm.ts similarity index 90% rename from components/Agents/useAgentForm.ts rename to hooks/useAgentForm.ts index 240ac58c7..31a128ced 100644 --- a/components/Agents/useAgentForm.ts +++ b/hooks/useAgentForm.ts @@ -1,7 +1,10 @@ import { useEffect } from "react"; import { useForm } from "react-hook-form"; import { zodResolver } from "@hookform/resolvers/zod"; -import { createAgentSchema, type CreateAgentFormData } from "./schemas"; +import { + createAgentSchema, + type CreateAgentFormData, +} from "@/components/Agents/schemas"; export function useAgentForm(initialValues?: Partial) { const form = useForm({ diff --git a/hooks/useEditAgentTemplate.ts b/hooks/useEditAgentTemplate.ts new file mode 100644 index 000000000..fcc7fcb66 --- /dev/null +++ b/hooks/useEditAgentTemplate.ts @@ -0,0 +1,52 @@ +import { useMutation, useQueryClient } from "@tanstack/react-query"; +import { useUserProvider } from "@/providers/UserProvder"; +import type { AgentTemplateRow } from "@/types/AgentTemplates"; +import type { CreateAgentFormData } from "@/components/Agents/schemas"; + +interface UseEditAgentTemplateOptions { + agent: AgentTemplateRow; + currentSharedEmails: string[]; + onSuccess: () => void; +} + +export function useEditAgentTemplate({ + agent, + currentSharedEmails, + onSuccess, +}: UseEditAgentTemplateOptions) { + const { userData } = useUserProvider(); + const queryClient = useQueryClient(); + + return useMutation({ + mutationFn: async (values: CreateAgentFormData) => { + const finalShareEmails = values.isPrivate + ? [...currentSharedEmails, ...(values.shareEmails ?? [])] + : []; + + const res = await fetch("/api/agent-templates", { + method: "PATCH", + headers: { "Content-Type": "application/json" }, + body: JSON.stringify({ + id: agent.id, + userId: userData?.id, + title: values.title, + description: values.description, + prompt: values.prompt, + tags: values.tags, + isPrivate: values.isPrivate, + shareEmails: finalShareEmails, + }), + }); + + if (!res.ok) { + throw new Error("Failed to update template"); + } + + return res.json(); + }, + onSuccess: () => { + queryClient.invalidateQueries({ queryKey: ["agent-templates"] }); + onSuccess(); + }, + }); +} From 81b617909835a6ad0e27bc81efa30ae6c2395b39 Mon Sep 17 00:00:00 2001 From: Avi Gaba Date: Tue, 31 Mar 2026 02:08:01 +0530 Subject: [PATCH 4/4] Document intentional agent edit reset dependencies --- components/Agents/AgentEditDialog.tsx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/components/Agents/AgentEditDialog.tsx b/components/Agents/AgentEditDialog.tsx index 86016bdb6..d96ac363b 100644 --- a/components/Agents/AgentEditDialog.tsx +++ b/components/Agents/AgentEditDialog.tsx @@ -57,6 +57,9 @@ const AgentEditDialog: React.FC = ({ agent }) => { shareEmails: [], }); } + // Reset only when the dialog opens for a different agent identity. + // Depending on all agent fields would wipe in-progress edits on background refetch. + // eslint-disable-next-line react-hooks/exhaustive-deps }, [open, agent.id, form]); return (