Skip to content

Commit

Permalink
fix: avoid excessive form resets (#1852)
Browse files Browse the repository at this point in the history
  • Loading branch information
ivyjeong13 authored Feb 25, 2025
1 parent aa8a0e3 commit 3b5cb44
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 14 deletions.
4 changes: 0 additions & 4 deletions ui/admin/app/components/agent/AgentForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,6 @@ export function AgentForm({
},
});

useEffect(() => {
if (agent) form.reset(agent);
}, [agent, form]);

useEffect(() => {
return form.watch((values) => {
if (!onChange) return;
Expand Down
12 changes: 2 additions & 10 deletions ui/admin/app/components/agent/AgentIntroForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,11 @@ export function AgentIntroForm({
resolver: zodResolver(formSchema),
mode: "onChange",
defaultValues: {
introductionMessage: "",
starterMessages: [],
introductionMessage: agent.introductionMessage ?? "",
starterMessages: agent.starterMessages ?? [],
},
});

useEffect(() => {
if (agent)
form.reset({
introductionMessage: agent.introductionMessage ?? "",
starterMessages: agent.starterMessages ?? [],
});
}, [agent, form]);

useEffect(() => {
return form.watch((values) => {
if (!onChange) return;
Expand Down

0 comments on commit 3b5cb44

Please sign in to comment.