@@ -9,6 +9,7 @@ import { ToolParam, ToolConfigModalProps } from "@/types/agentConfig";
99import {
1010 updateToolConfig ,
1111 searchToolConfig ,
12+ loadLastToolConfig ,
1213} from "@/services/agentConfigService" ;
1314import log from "@/lib/logger" ;
1415
@@ -122,6 +123,36 @@ export default function ToolConfigModal({
122123 setCurrentParams ( newParams ) ;
123124 } ;
124125
126+ // load last tool config
127+ const handleLoadLastConfig = async ( ) => {
128+ if ( ! tool ) return ;
129+
130+ try {
131+ const result = await loadLastToolConfig ( parseInt ( tool . id ) ) ;
132+ if ( result . success && result . data ) {
133+ // Parse the last config data
134+ const lastConfig = result . data ;
135+
136+ // Update current params with last config values
137+ const updatedParams = currentParams . map ( ( param ) => {
138+ const lastValue = lastConfig [ param . name ] ;
139+ return {
140+ ...param ,
141+ value : lastValue !== undefined ? lastValue : param . value ,
142+ } ;
143+ } ) ;
144+
145+ setCurrentParams ( updatedParams ) ;
146+ message . success ( t ( "toolConfig.message.loadLastConfigSuccess" ) ) ;
147+ } else {
148+ message . warning ( t ( "toolConfig.message.loadLastConfigNotFound" ) ) ;
149+ }
150+ } catch ( error ) {
151+ log . error ( t ( "toolConfig.message.loadLastConfigFailed" ) , error ) ;
152+ message . error ( t ( "toolConfig.message.loadLastConfigFailed" ) ) ;
153+ }
154+ } ;
155+
125156 const handleSave = async ( ) => {
126157 if ( ! tool || ! checkRequiredFields ( ) ) return ;
127158
@@ -257,26 +288,36 @@ export default function ToolConfigModal({
257288 title = {
258289 < div className = "flex justify-between items-center w-full pr-8" >
259290 < span > { `${ tool ?. name } ` } </ span >
260- < Tag
261- color = {
262- tool ?. source === "mcp"
263- ? "blue"
291+ < div className = "flex items-center gap-2" >
292+ < button
293+ onClick = { handleLoadLastConfig }
294+ className = "px-2 py-1 text-xs bg-blue-500 text-white rounded hover:bg-blue-600 disabled:opacity-50 disabled:cursor-not-allowed transition-colors duration-200"
295+ >
296+ { t ( "toolConfig.message.loadLastConfig" ) }
297+ </ button >
298+ < Tag
299+ color = {
300+ tool ?. source === "mcp"
301+ ? "blue"
302+ : tool ?. source === "langchain"
303+ ? "orange"
304+ : "green"
305+ }
306+ >
307+ { tool ?. source === "mcp"
308+ ? t ( "toolPool.tag.mcp" )
264309 : tool ?. source === "langchain"
265- ? "orange"
266- : "green"
267- }
268- >
269- { tool ?. source === "mcp"
270- ? t ( "toolPool.tag.mcp" )
271- : tool ?. source === "langchain"
272- ? t ( "toolPool.tag.langchain" )
273- : t ( "toolPool.tag.local" ) }
274- </ Tag >
310+ ? t ( "toolPool.tag.langchain" )
311+ : t ( "toolPool.tag.local" ) }
312+ </ Tag >
313+ </ div >
275314 </ div >
276315 }
277316 open = { isOpen }
278317 onCancel = { onCancel }
279318 onOk = { handleSave }
319+ okText = { t ( "common.button.save" ) }
320+ cancelText = { t ( "common.button.cancel" ) }
280321 width = { 600 }
281322 confirmLoading = { isLoading }
282323 >
0 commit comments