@@ -11,13 +11,13 @@ import { TooltipProvider } from "@/components/ui/tooltip";
1111import {
1212 fetchAgentList ,
1313 updateAgent ,
14- importAgent ,
1514 deleteAgent ,
1615 exportAgent ,
1716 searchAgentInfo ,
1817 searchToolConfig ,
1918 updateToolConfig ,
2019} from "@/services/agentConfigService" ;
20+ import { useAgentImport } from "@/hooks/useAgentImport" ;
2121import {
2222 Agent ,
2323 AgentSetupOrchestratorProps ,
@@ -1541,6 +1541,31 @@ export default function AgentSetupOrchestrator({
15411541 }
15421542 } ;
15431543
1544+ // Use unified import hooks - one for normal import, one for force import
1545+ const { importFromData : runNormalImport } = useAgentImport ( {
1546+ onSuccess : ( ) => {
1547+ message . success ( t ( "businessLogic.config.error.agentImportSuccess" ) ) ;
1548+ refreshAgentList ( t , false ) ;
1549+ } ,
1550+ onError : ( error ) => {
1551+ log . error ( t ( "agentConfig.agents.importFailed" ) , error ) ;
1552+ message . error ( t ( "businessLogic.config.error.agentImportFailed" ) ) ;
1553+ } ,
1554+ forceImport : false ,
1555+ } ) ;
1556+
1557+ const { importFromData : runForceImport } = useAgentImport ( {
1558+ onSuccess : ( ) => {
1559+ message . success ( t ( "businessLogic.config.error.agentImportSuccess" ) ) ;
1560+ refreshAgentList ( t , false ) ;
1561+ } ,
1562+ onError : ( error ) => {
1563+ log . error ( t ( "agentConfig.agents.importFailed" ) , error ) ;
1564+ message . error ( t ( "businessLogic.config.error.agentImportFailed" ) ) ;
1565+ } ,
1566+ forceImport : true ,
1567+ } ) ;
1568+
15441569 const runAgentImport = useCallback (
15451570 async (
15461571 agentPayload : any ,
@@ -1549,31 +1574,19 @@ export default function AgentSetupOrchestrator({
15491574 ) => {
15501575 setIsImporting ( true ) ;
15511576 try {
1552- const result = await importAgent ( agentPayload , options ) ;
1553-
1554- if ( result . success ) {
1555- message . success (
1556- translationFn ( "businessLogic.config.error.agentImportSuccess" )
1557- ) ;
1558- // Don't clear tools when importing to avoid triggering false unsaved changes indicator
1559- await refreshAgentList ( translationFn , false ) ;
1560- return true ;
1577+ if ( options ?. forceImport ) {
1578+ await runForceImport ( agentPayload ) ;
1579+ } else {
1580+ await runNormalImport ( agentPayload ) ;
15611581 }
1562-
1563- message . error (
1564- result . message ||
1565- translationFn ( "businessLogic.config.error.agentImportFailed" )
1566- ) ;
1567- return false ;
1582+ return true ;
15681583 } catch ( error ) {
1569- log . error ( translationFn ( "agentConfig.agents.importFailed" ) , error ) ;
1570- message . error ( translationFn ( "businessLogic.config.error.agentImportFailed" ) ) ;
15711584 return false ;
15721585 } finally {
15731586 setIsImporting ( false ) ;
15741587 }
15751588 } ,
1576- [ message , refreshAgentList ]
1589+ [ runNormalImport , runForceImport ]
15771590 ) ;
15781591
15791592 // Handle importing agent
0 commit comments