Skip to content

Commit a3a0ec0

Browse files
committed
Bugfix: Refactor tool config save logic and fix array parameter comparison
1 parent f51be41 commit a3a0ec0

1 file changed

Lines changed: 33 additions & 1 deletion

File tree

frontend/stores/agentConfigStore.ts

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,39 @@ const isToolsDirty = (baselineAgent: EditableAgent | null, editedAgent: Editable
252252
// Compare each param's name and value
253253
for (const baseParam of baseParams) {
254254
const editParam = editParams.find(p => p.name === baseParam.name);
255-
if (!editParam || baseParam.value !== editParam.value) {
255+
if (!editParam) {
256+
return true;
257+
}
258+
259+
// Deep comparison for array and object values
260+
const baseValue = baseParam.value;
261+
const editValue = editParam.value;
262+
263+
// If both are arrays, compare their contents
264+
if (Array.isArray(baseValue) && Array.isArray(editValue)) {
265+
if (baseValue.length !== editValue.length) {
266+
return true;
267+
}
268+
// Sort and compare array elements
269+
const sortedBase = [...baseValue].sort();
270+
const sortedEdit = [...editValue].sort();
271+
if (JSON.stringify(sortedBase) !== JSON.stringify(sortedEdit)) {
272+
return true;
273+
}
274+
}
275+
// If both are objects (but not arrays), compare their JSON representation
276+
else if (
277+
baseValue !== null &&
278+
editValue !== null &&
279+
typeof baseValue === 'object' &&
280+
typeof editValue === 'object'
281+
) {
282+
if (JSON.stringify(baseValue) !== JSON.stringify(editValue)) {
283+
return true;
284+
}
285+
}
286+
// For primitive values, use strict equality
287+
else if (baseValue !== editValue) {
256288
return true;
257289
}
258290
}

0 commit comments

Comments
 (0)