@@ -395,11 +395,15 @@ export const ToolInput = memo(function ToolInput({
395395 const { collaborativeSetBlockCanonicalMode, collaborativeSetBlockCanonicalModes } =
396396 useCollaborativeWorkflow ( )
397397 const reindexCanonicalModesOnMutate = useCallback (
398- ( oldTools : StoredTool [ ] , newTools : StoredTool [ ] ) => {
398+ ( oldTools : StoredTool [ ] , newTools : StoredTool [ ] , persistedTools = newTools ) => {
399399 const next = reindexToolCanonicalModes ( oldTools , newTools , canonicalModeOverrides )
400- if ( next ) collaborativeSetBlockCanonicalModes ( blockId , next )
400+ if ( ! next ) return false
401+ collaborativeSetBlockCanonicalModes ( blockId , next , {
402+ [ subBlockId ] : { id : subBlockId , type : 'tool-input' , value : persistedTools } ,
403+ } )
404+ return true
401405 } ,
402- [ canonicalModeOverrides , collaborativeSetBlockCanonicalModes , blockId ]
406+ [ canonicalModeOverrides , collaborativeSetBlockCanonicalModes , blockId , subBlockId ]
403407 )
404408
405409 const value = isPreview ? previewValue : storeValue
@@ -857,8 +861,9 @@ export const ToolInput = memo(function ToolInput({
857861 ( toolIndex : number ) => {
858862 if ( isPreview || disabled ) return
859863 const updatedTools = selectedTools . filter ( ( _ , index ) => index !== toolIndex )
860- reindexCanonicalModesOnMutate ( selectedTools , updatedTools )
861- setStoreValue ( updatedTools )
864+ if ( ! reindexCanonicalModesOnMutate ( selectedTools , updatedTools ) ) {
865+ setStoreValue ( updatedTools )
866+ }
862867 } ,
863868 [ isPreview , disabled , selectedTools , reindexCanonicalModesOnMutate , setStoreValue ]
864869 )
@@ -869,8 +874,9 @@ export const ToolInput = memo(function ToolInput({
869874 const updatedTools = selectedTools . filter (
870875 ( t ) => ! ( t . type === 'mcp' && t . params ?. serverId === serverId )
871876 )
872- reindexCanonicalModesOnMutate ( selectedTools , updatedTools )
873- setStoreValue ( updatedTools )
877+ if ( ! reindexCanonicalModesOnMutate ( selectedTools , updatedTools ) ) {
878+ setStoreValue ( updatedTools )
879+ }
874880 } ,
875881 [ isPreview , disabled , selectedTools , reindexCanonicalModesOnMutate , setStoreValue ]
876882 )
@@ -900,8 +906,9 @@ export const ToolInput = memo(function ToolInput({
900906 } )
901907
902908 if ( updatedTools . length !== selectedTools . length ) {
903- reindexCanonicalModesOnMutate ( selectedTools , updatedTools )
904- setStoreValue ( updatedTools )
909+ if ( ! reindexCanonicalModesOnMutate ( selectedTools , updatedTools ) ) {
910+ setStoreValue ( updatedTools )
911+ }
905912 }
906913 } ,
907914 [ selectedTools , customTools , reindexCanonicalModesOnMutate , setStoreValue ]
@@ -1077,8 +1084,9 @@ export const ToolInput = memo(function ToolInput({
10771084 newTools . splice ( adjustedDropIndex , 0 , draggedTool )
10781085 }
10791086
1080- reindexCanonicalModesOnMutate ( selectedTools , newTools )
1081- setStoreValue ( newTools )
1087+ if ( ! reindexCanonicalModesOnMutate ( selectedTools , newTools ) ) {
1088+ setStoreValue ( newTools )
1089+ }
10821090 setDraggedIndex ( null )
10831091 setDragOverIndex ( null )
10841092 }
@@ -1177,8 +1185,9 @@ export const ToolInput = memo(function ToolInput({
11771185 ...filteredTools . map ( ( tool ) => ( { ...tool , isExpanded : false } ) ) ,
11781186 serverBinding ,
11791187 ]
1180- reindexCanonicalModesOnMutate ( selectedTools , filteredTools )
1181- setStoreValue ( nextTools )
1188+ if ( ! reindexCanonicalModesOnMutate ( selectedTools , filteredTools , nextTools ) ) {
1189+ setStoreValue ( nextTools )
1190+ }
11821191 setMcpServerDrilldown ( null )
11831192 setOpen ( false )
11841193 } ,
0 commit comments