Skip to content

Conversation

@vivekyadav-3
Copy link

@vivekyadav-3 vivekyadav-3 commented Jan 25, 2026

Problem

  1. Performance: [useFetchChatData] was performing heavy permission re-calculations on every render because the memoization check for the raw permission object was missing its reference point.
    2.Efficiency: The member role reduction logic was using an immutable spread pattern inside a reduce, leading to O(N^2) complexity.
  2. Consistency: Video recording did not update the global isRecordingMessage state, allowing users to still interact with the chat input while recording.
  3. Reliability: A typo in the store (toogleRecordingMessage) led to inconsistencies across hooks.

Solution

  • Fixed Memoization: Correctly updated permissionsRef.current.raw to ensure the early-exit logic works, preventing redundant state updates.
  • Optimized Performance: Replaced the object spread with direct mutation in the roles.reduce logic for O(N) performance.
  • Improved Consistency: Integrated [toggleRecordingMessage] into the Video Recorder to match behavior with the Audio Recorder.
  • Code Health: Fixed the "toogle" typo globally and added null-safety to the admins' array mapping.
    Testing
  • Build passes successfully (npm run build).
  • Verified state synchronization between Audio/Video recorders.
  • Verified permission caching logic correctly prevents unnecessary re-renders.
  • Quote Logic Refactor: Fixed a bug in [ChatInput.js] where multiple quoted messages were incorrectly duplicated due to a mutation error in a partial string build. Now uses a deterministic array-based join.

Copilot AI review requested due to automatic review settings January 25, 2026 16:34
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR optimizes performance and fixes consistency issues in the recording functionality and permission handling.

Changes:

  • Fixed a typo (toogleRecordingMessagetoggleRecordingMessage) and integrated video recording state management to match audio recording behavior
  • Optimized permission memoization to prevent unnecessary re-renders
  • Improved role processing performance from O(N²) to O(N) and added null-safety to admin username mapping

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
packages/react/src/views/ChatInput/VideoMessageRecoder.js Added toggleRecordingMessage calls to synchronize global recording state, ensuring UI elements are properly disabled during video recording
packages/react/src/views/ChatInput/AudioMessageRecorder.js Fixed typo in function name from toogleRecordingMessage to toggleRecordingMessage
packages/react/src/store/messageStore.js Fixed typo in store method name from toogleRecordingMessage to toggleRecordingMessage
packages/react/src/hooks/useFetchChatData.js Fixed permission memoization by storing raw permissions, optimized roles reduce from O(N²) to O(N), and added null-safety for admin usernames mapping

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@vivekyadav-3 vivekyadav-3 changed the title refactor: optimize permissions fetch, fix admins state, and resolve r… refactor: performance, recording consistency, and quote logic fixes Jan 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant