From f4d38291d46752927664ce5c04a90f535cc69082 Mon Sep 17 00:00:00 2001 From: Manoj Pawar <185208487+ManojPawar2@users.noreply.github.com> Date: Wed, 24 Jun 2026 10:38:21 +0530 Subject: [PATCH] fix: persist raw permissions in ref to restore change-detection in useFetchChatData `fetchAndSetPermissions` guarded its work by comparing the freshly fetched permissions against `permissionsRef.current.raw`, but the ref was only ever assigned `{ map }`. With `.raw` left undefined, the guard `JSON.stringify(permissions) !== JSON.stringify(permissionsRef.current.raw)` always evaluated to true. As a result the permissions map was rebuilt and `applyPermissions` ran on every call, firing all six Zustand permission setters and triggering needless state updates and re-renders even when permissions had not changed. Store the raw permissions alongside the map so the comparison can short-circuit and skip the redundant work when nothing has changed. Closes #1317 --- packages/react/src/hooks/useFetchChatData.js | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/react/src/hooks/useFetchChatData.js b/packages/react/src/hooks/useFetchChatData.js index 57a564a18..ee8ae10c5 100644 --- a/packages/react/src/hooks/useFetchChatData.js +++ b/packages/react/src/hooks/useFetchChatData.js @@ -106,6 +106,7 @@ const useFetchChatData = (showRoles) => { const permissionsMap = createPermissionsMap(permissions); permissionsRef.current = { + raw: permissions, map: permissionsMap, };