SmythOS Studio: Open-Source Visual AI Agent Builder and deployable runtime stack from SmythOS. Start with an intuitive drag-and-drop workspace, extend with custom code, and deploy your agents anywhere — local, cloud, or edge — with full governance and control.
JavaScript a2aagentic-aiai-agentsdevtoolsmcp-clientn8n-alternativeno-codeopen-sourceorchestrationsmythosvisual-builder
Refactor OverviewWidgetsContainer for improved form value synchronization
Muhammad Hamza Khan03093e60ecf2
diff --git a/packages/app/src/react/features/agent-settings/components/OverviewWidgetsContainer/index.tsx b/packages/app/src/react/features/agent-settings/components/OverviewWidgetsContainer/index.tsxindex 58aa7bbb..b4d6917e 100644--- a/packages/app/src/react/features/agent-settings/components/OverviewWidgetsContainer/index.tsx+++ b/packages/app/src/react/features/agent-settings/components/OverviewWidgetsContainer/index.tsx@@ -252,13 +252,14 @@ const OverviewWidgetsContainer = ({ isWriteAccess }: { isWriteAccess: boolean })const handleWorkSpaceChange = useCallback(() => {if (workspace?.agent?.data) {+ console.log('syncing workspace with form');// Immediately update form with workspace valuesformik.resetForm({values: {chatGptModel: currentFormValues.current.chatGptModel, // Keep existing model- behavior: workspace.agent.data.behavior,- name: workspace.agent.name,- shortDescription: workspace.agent.data.shortDescription,+ behavior: currentFormValues.current.behavior,+ name: currentFormValues.current.name,+ shortDescription: currentFormValues.current.shortDescription,},});@@ -292,6 +293,10 @@ const OverviewWidgetsContainer = ({ isWriteAccess }: { isWriteAccess: boolean })const behaviorChanged: boolean =currentFormValues.current.behavior?.trim() !== initialFormValues.current.behavior;+ // store the initial form values in a temporary variable+ const tempInitialFormValues = { ...initialFormValues.current };+ initialFormValues.current = { ...currentFormValues.current };+if (chatGptModelChanged) {promises.push(saveAgentSettingByKey(@@ -382,8 +387,6 @@ const OverviewWidgetsContainer = ({ isWriteAccess }: { isWriteAccess: boolean })updateAgentSettingsCache(currentFormValues.current.chatGptModel);updateAgentDataSettingsCache();- initialFormValues.current = { ...currentFormValues.current };-setSavingStatus('saved');const timeout = setTimeout(() => {setSavingStatus('idle');@@ -400,6 +403,8 @@ const OverviewWidgetsContainer = ({ isWriteAccess }: { isWriteAccess: boolean })errorToast('Failed to save settings');}+ initialFormValues.current = { ...tempInitialFormValues };+ currentFormValues.current = { ...tempInitialFormValues };setSavingStatus('idle');} finally {if (lockId) {@@ -483,17 +488,16 @@ const OverviewWidgetsContainer = ({ isWriteAccess }: { isWriteAccess: boolean })const timeoutId = setTimeout(() => {console.log('triggering timeout');formik.submitForm();+ clearTimeout(timeoutId);}, 500);return () => clearTimeout(timeoutId);}, [formik,+ formik.setValues,isWriteAccess,savingStatus,agentQuery.data,- handleSave,- defaultModel,- workspace,settingsQuery.isFetching,agentQuery.isFetching,]);