Skip to content

fix(collab): rename useRoomActivity param provider_url → providerUrl#1485

Closed
leecalcote wants to merge 1 commit intomasterfrom
fix/use-room-activity-provider-url-camel
Closed

fix(collab): rename useRoomActivity param provider_url → providerUrl#1485
leecalcote wants to merge 1 commit intomasterfrom
fix/use-room-activity-provider-url-camel

Conversation

@leecalcote
Copy link
Copy Markdown
Member

Summary

  • Renames provider_urlproviderUrl in the UseRoomActivityParams interface (public hook API)
  • Renames provider_urlproviderUrl in the CollaborationConfigParams interface (exported getCollaborationConfig API)
  • Updates all internal usages throughout the hook: destructuring, null-guard, effect dependency array, and forwarding to getCollaborationConfig

Motivation

The provider_url snake_case parameter violates the canonical camelCase wire-format contract defined in meshery/schemas. All hook parameters must be camelCase per that contract (providerUrl, not provider_url).

This unblocks meshery-extensions#4228 (merged 2026-05-06), which canonicalized all provider_url reads in Kanvas to providerUrl and left a single intentional call-site workaround pending this sistent rename:

// Before (workaround in ExpandedDesignerDrawer/index.tsx):
useRoomActivity({ provider_url: providerUrl, ... })
// After (follow-up PR in extensions):
useRoomActivity({ providerUrl, ... })

Notes

  • user_map in UserMapChangeMessage is intentionally not renamed — it is an incoming WebSocket message field name dictated by the server protocol, not a hook parameter.
  • No test or story files call useRoomActivity directly; the 48 existing unit tests all pass.

Test plan

  • npm test passes (48 tests, 17 suites)
  • TypeScript compiles without errors (pre-commit hook clean)
  • Callers updated in layer5labs/meshery-extensions follow-up PR

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>
Copilot AI review requested due to automatic review settings May 6, 2026 06:52
@leecalcote
Copy link
Copy Markdown
Member Author

Closing as duplicate — PR #1484 covers the identical change and already has all CI checks passing.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

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]);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

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.

Copy link
Copy Markdown
Contributor

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 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_urlproviderUrl in the UseRoomActivityParams hook parameter type and updated the hook’s internal usage (guards, forwarding, effect deps).
  • Renamed provider_urlproviderUrl in the CollaborationConfigParams type and updated getCollaborationConfig/subscription plumbing accordingly.

Comment on lines 49 to 53
interface UseRoomActivityParams {
provider_url?: string;
providerUrl?: string;
getUserProfile?: () => Promise<{ data: UserProfile }>;
getUserAccessToken?: () => Promise<{ data: string }>;
}
Comment on lines 102 to 120
@@ -116,7 +116,7 @@ export const getCollaborationConfig = async ({
};

return {
signalingUrl: [getSignalingUrlFromProviderUrl(provider_url)],
signalingUrl: [getSignalingUrlFromProviderUrl(providerUrl)],
user: userProfile,
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.

2 participants