fix(collab): rename useRoomActivity param provider_url → providerUrl#1485
fix(collab): rename useRoomActivity param provider_url → providerUrl#1485leecalcote wants to merge 1 commit intomasterfrom
Conversation
Aligns the UseRoomActivityParams interface and CollaborationConfigParams interface with the canonical camelCase wire-format contract defined in meshery/schemas. All internal usages of provider_url throughout the hook implementation (destructuring, guards, effect dependency array, and forwarding to getCollaborationConfig) are updated to providerUrl. Note: user_map in UserMapChangeMessage is intentionally left as-is — it is an incoming WebSocket message field name dictated by the server protocol, not a hook parameter. Signed-off-by: Lee Calcote <leecalcote@gmail.com>
|
Closing as duplicate — PR #1484 covers the identical change and already has all CI checks passing. |
There was a problem hiding this comment.
Code Review
This pull request renames the provider_url property to providerUrl throughout the useRoomActivity hook and its associated interfaces to follow camelCase naming conventions. The review feedback identifies a potential performance issue where including unmemoized functions in the useEffect dependency array could lead to frequent WebSocket reconnections. Additionally, a critical race condition was found in the cleanup logic: the cleanup function captures the WebSocket reference before the asynchronous subscribeToRoomActivity function updates the ref, which may result in the WebSocket failing to close when the component unmounts or the effect re-runs.
| } | ||
| }; | ||
| }, [provider_url, getUserProfile, getUserAccessToken]); | ||
| }, [providerUrl, getUserProfile, getUserAccessToken]); |
There was a problem hiding this comment.
The useEffect dependency array now includes providerUrl, getUserProfile, and getUserAccessToken. While this rename is correct, including these functions in the dependency array can lead to frequent WebSocket reconnections if the caller does not memoize them (e.g., using useCallback). Furthermore, there is a race condition in the cleanup logic (lines 210-217). The ws variable is captured from wsRef.current synchronously when the effect runs, but subscribeToRoomActivity is asynchronous and updates the ref later. This means the cleanup function may capture null and fail to close the newly opened WebSocket when the effect re-runs or the component unmounts. Consider refactoring the cleanup to access wsRef.current directly inside the returned function.
There was a problem hiding this comment.
Pull request overview
This PR updates the public collaboration hook/API surface to use camelCase (providerUrl) instead of snake_case (provider_url), aligning the hook parameters with the canonical camelCase contract used across Meshery/Layer5 schemas and callers.
Changes:
- Renamed
provider_url→providerUrlin theUseRoomActivityParamshook parameter type and updated the hook’s internal usage (guards, forwarding, effect deps). - Renamed
provider_url→providerUrlin theCollaborationConfigParamstype and updatedgetCollaborationConfig/subscription plumbing accordingly.
| interface UseRoomActivityParams { | ||
| provider_url?: string; | ||
| providerUrl?: string; | ||
| getUserProfile?: () => Promise<{ data: UserProfile }>; | ||
| getUserAccessToken?: () => Promise<{ data: string }>; | ||
| } |
| @@ -116,7 +116,7 @@ export const getCollaborationConfig = async ({ | |||
| }; | |||
|
|
|||
| return { | |||
| signalingUrl: [getSignalingUrlFromProviderUrl(provider_url)], | |||
| signalingUrl: [getSignalingUrlFromProviderUrl(providerUrl)], | |||
| user: userProfile, | |||
Summary
provider_url→providerUrlin theUseRoomActivityParamsinterface (public hook API)provider_url→providerUrlin theCollaborationConfigParamsinterface (exportedgetCollaborationConfigAPI)getCollaborationConfigMotivation
The
provider_urlsnake_case parameter violates the canonical camelCase wire-format contract defined inmeshery/schemas. All hook parameters must becamelCaseper that contract (providerUrl, notprovider_url).This unblocks meshery-extensions#4228 (merged 2026-05-06), which canonicalized all
provider_urlreads in Kanvas toproviderUrland left a single intentional call-site workaround pending this sistent rename:Notes
user_mapinUserMapChangeMessageis intentionally not renamed — it is an incoming WebSocket message field name dictated by the server protocol, not a hook parameter.useRoomActivitydirectly; the 48 existing unit tests all pass.Test plan
npm testpasses (48 tests, 17 suites)layer5labs/meshery-extensionsfollow-up PR