Conversation
Expose reusable group and application context hooks in mero-react so apps can rely on the shared admin surface instead of wiring raw SDK calls themselves. Point local testing at the local mero-js package and add focused hook coverage for the new context discovery and group management flows. Made-with: Cursor
| }, | ||
| "dependencies": { | ||
| "@calimero-network/mero-js": "^1.2.1" | ||
| "@calimero-network/mero-js": "file:../mero-js" |
There was a problem hiding this comment.
Local file path dependency committed to package.json
High Severity
The @calimero-network/mero-js dependency was changed from ^1.2.1 (npm registry) to file:../mero-js (local path). This breaks pnpm install for anyone cloning the repo who doesn't have a sibling mero-js directory, and would produce a broken package on npm publish. The same issue applies to the tsconfig.json paths entry pointing at ../mero-js/dist/index.d.ts. The PR description confirms these changes were intended only for local testing.
Additional Locations (1)
| } | ||
|
|
||
| await sleep(pollIntervalMs); | ||
| } |
There was a problem hiding this comment.
Discovery polling loop continues after component unmount
Medium Severity
The useContextDiscovery polling loop does not check mountedRef.current between iterations. If the component unmounts while discover() is running, the loop keeps making API calls (lookupContextAlias and getContextsForApplication) on each poll cycle until the timeout expires (default 30 seconds). State updates are guarded, but the unnecessary network requests continue.
Added new hooks for context and group management, including create, delete, invite, and join functionalities. Updated the index files to export these hooks and their types, improving the overall API for easier integration. Enhanced test coverage for the new hooks to ensure reliability and correctness.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
There are 3 total unresolved issues (including 2 from previous reviews).
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
| options.pollIntervalMs, | ||
| options.targetAlias, | ||
| options.timeoutMs, | ||
| ]); |
There was a problem hiding this comment.
Redundant dependency defeats serialized key stabilization purpose
Low Severity
The discover callback's dependency array includes both knownContextIdsKey (the serialized string) and options.knownContextIds (the raw array). Including the raw array reference defeats the purpose of serializing it into knownContextIdsKey for stable comparison, since the callback will still be recreated whenever the array reference changes. The useSubscription hook in the same file demonstrates the correct pattern — only including the serialized contextIdsKey.


Summary
mero-reacthooks for application context discovery, group listing, group membership, invitations, joining, and capabilities managementuseContexts(applicationId)to use the application-scoped admin API instead of fetching all contexts and filtering client-sidemero-reacttesting at the localmero-jspackage and add focused hook tests for the new flowsTest plan
cd mero-react && pnpm testcd mero-react && pnpm typecheckcd mero-react && pnpm buildDocumentation update
Made with Cursor
Note
Medium Risk
Medium risk because it expands the public hook surface area and changes
useContextsfetching behavior to call a different admin API, which could affect consumers’ data loading patterns. Logic is mostly additive and covered by new hook tests, but correctness depends onmero-jsadmin API contracts (including alias lookup/polling).Overview
Adds a new set of React hooks for group and context administration (listing groups, fetching members/contexts, creating/joining/inviting, updating member capabilities, syncing/deleting groups, and creating/deleting/joining contexts), with shared unmount-safe async handling.
Updates
useContextsto useadmin.getContextsForApplication(applicationId)instead of fetching all contexts and filtering client-side, and introducesuseContextDiscoveryto poll for a newly created context (optionally via alias lookup) with timeout/error reporting.Exports the new hooks and related types (
ApplicationContextRecord,ContextDiscoveryOptions/State) from the package entrypoint, and adds a comprehensive jsdom-based test suite for the new hook flows; dev setup now points@calimero-network/mero-jsat a localfile:dependency and adds TS path mapping for local typings.Written by Cursor Bugbot for commit 4afae67. This will update automatically on new commits. Configure here.