Skip to content

Commit

Permalink
fix: update workflow tools more consistently
Browse files Browse the repository at this point in the history
The useEffect updating on the watch is not effectively updating the tools for
workflows. This change switches back using the form.

Signed-off-by: Donnie Adams <[email protected]>
  • Loading branch information
thedadams committed Dec 19, 2024
1 parent 42adf47 commit ee2ac7e
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions ui/admin/app/components/tools/BasicToolForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export function BasicToolForm({
resolver: zodResolver(formSchema),
defaultValues: { tools: defaultValues?.tools || [] },
});
const { watch, getValues, reset } = form;
const { getValues, reset } = form;

useEffect(() => {
const unchanged = compareArrays(
Expand All @@ -50,14 +50,14 @@ export function BasicToolForm({
const toolArr = useFieldArray({ control: form.control, name: "tools" });

useEffect(() => {
return watch((values) => {
return form.watch((values) => {
const { data, success } = formSchema.safeParse(values);

if (!success) return;

onChange?.({ tools: data.tools.map((t) => t.value) });
}).unsubscribe;
}, [watch, onChange]);
}, [form, onChange]);

const removeTools = (toolsToRemove: string[]) => {
const indexes = toolsToRemove
Expand Down

0 comments on commit ee2ac7e

Please sign in to comment.