diff --git a/client/src/components/SidePanel/Agents/ActionsInput.tsx b/client/src/components/SidePanel/Agents/ActionsInput.tsx index f1bc3aecd10..a40be180d1f 100644 --- a/client/src/components/SidePanel/Agents/ActionsInput.tsx +++ b/client/src/components/SidePanel/Agents/ActionsInput.tsx @@ -16,10 +16,10 @@ import type { ActionAuthForm } from '~/common'; import type { Spec } from './ActionsTable'; import { ActionsTable, columns } from './ActionsTable'; import { useUpdateAgentAction } from '~/data-provider'; -import { cn, removeFocusOutlines } from '~/utils'; import { useToastContext } from '~/Providers'; import useLocalize from '~/hooks/useLocalize'; import { Spinner } from '~/components/svg'; +import { logger } from '~/utils'; const debouncedValidation = debounce( (input: string, callback: (result: ValidationResult) => void) => { @@ -56,12 +56,13 @@ export default function ActionsInput({ const [functions, setFunctions] = useState(null); useEffect(() => { - if (!action?.metadata?.raw_spec) { + const rawSpec = action?.metadata.raw_spec ?? ''; + if (!rawSpec) { return; } - setInputValue(action.metadata.raw_spec); - debouncedValidation(action.metadata.raw_spec, handleResult); - }, [action?.metadata?.raw_spec]); + setInputValue(rawSpec); + debouncedValidation(rawSpec, handleResult); + }, [action?.metadata.raw_spec]); useEffect(() => { if (!validationResult || !validationResult.status || !validationResult.spec) { @@ -94,15 +95,16 @@ export default function ActionsInput({ }, onError(error) { showToast({ - message: (error as Error)?.message ?? localize('com_assistants_update_actions_error'), + message: (error as Error).message || localize('com_assistants_update_actions_error'), status: 'error', }); }, }); const saveAction = handleSubmit((authFormData) => { - console.log('authFormData', authFormData); - if (!agent_id) { + logger.log('actions', 'saving action', authFormData); + const currentAgentId = agent_id ?? ''; + if (!currentAgentId) { // alert user? return; } @@ -171,7 +173,7 @@ export default function ActionsInput({ action_id, metadata, functions, - agent_id, + agent_id: currentAgentId, }); }); @@ -186,17 +188,34 @@ export default function ActionsInput({ debouncedValidation(newValue, handleResult); }; + const getButtonContent = () => { + if (updateAgentAction.isLoading) { + return ; + } + + if (action?.action_id != null && action.action_id) { + return localize('com_ui_update'); + } + + return localize('com_ui_create'); + }; + return ( <>
- +
{/* */}
-
+