@@ -930,6 +930,7 @@ export const useTree = (currentUser) => {
930930
931931 const renameItem = useCallback (
932932 async ( itemId , newLabel ) => {
933+ const startTime = performance . now ( ) ;
933934 const trimmedLabel = newLabel ?. trim ( ) ;
934935 if ( ! trimmedLabel || ! itemId )
935936 return { success : false , error : "Invalid ID or name." } ;
@@ -944,10 +945,14 @@ export const useTree = (currentUser) => {
944945 }
945946
946947 try {
948+ console . log ( '[TIMING] Starting rename API request' ) ;
949+ const beforeFetch = performance . now ( ) ;
947950 const updatedItemFromServer = await authFetch ( `/items/${ itemId } ` , {
948951 method : "PATCH" ,
949952 body : JSON . stringify ( { label : trimmedLabel } ) ,
950953 } ) ;
954+ const fetchTime = performance . now ( ) - beforeFetch ;
955+ console . log ( `[TIMING] API request completed in ${ fetchTime . toFixed ( 2 ) } ms` ) ;
951956
952957 const mapRecursiveRename = ( items , id , serverUpdates ) =>
953958 items . map ( ( i ) =>
@@ -960,15 +965,22 @@ export const useTree = (currentUser) => {
960965 }
961966 : i
962967 ) ;
968+ const beforeTreeUpdate = performance . now ( ) ;
963969 const newTreeState = mapRecursiveRename (
964970 tree ,
965971 itemId ,
966972 updatedItemFromServer
967973 ) ;
968974 setTreeWithUndo ( newTreeState ) ;
975+ const treeUpdateTime = performance . now ( ) - beforeTreeUpdate ;
976+ const totalTime = performance . now ( ) - startTime ;
977+ console . log ( `[TIMING] Local tree update completed in ${ treeUpdateTime . toFixed ( 2 ) } ms` ) ;
978+ console . log ( `[TIMING] ========== TOTAL FRONTEND RENAME TIME: ${ totalTime . toFixed ( 2 ) } ms ==========` ) ;
969979 return { success : true , item : updatedItemFromServer } ;
970980 } catch ( error ) {
981+ const errorTime = performance . now ( ) - startTime ;
971982 console . error ( "renameItem API error:" , error ) ;
983+ console . error ( `[TIMING] Request failed after ${ errorTime . toFixed ( 2 ) } ms` ) ;
972984
973985 // If we get a "not found" error, the client tree might be out of sync
974986 // Refresh the tree to get the latest server state
0 commit comments