Skip to content

Wallets simplified, SDK Mutations unified#653

Open
feruzm wants to merge 7 commits intodevelopfrom
sdkmutation
Open

Wallets simplified, SDK Mutations unified#653
feruzm wants to merge 7 commits intodevelopfrom
sdkmutation

Conversation

@feruzm
Copy link
Member

@feruzm feruzm commented Feb 12, 2026

Summary by CodeRabbit

  • Refactor
    • Migrated comment deletion, post muting, community subscription, and profile update operations to SDK-based mutations for improved stability and consistency.
    • Added optimistic UI updates for comment deletion and profile modifications to provide faster user feedback.
    • Enhanced error messaging and success notifications with localization support across all updated operations.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 12, 2026

📝 Walkthrough

Walkthrough

This PR introduces SDK-backed mutation hooks across web and SDK layers. Web-specific mutation wrappers are created that delegate to new SDK mutations via broadcast adapters. SDK mutations are added for comment deletion, post muting, and community subscription/unsubscription with post-broadcast cache invalidation. Export barrels are extended to expose these mutations.

Changes

Cohort / File(s) Summary
Web Mutations → SDK
apps/web/src/api/mutations/delete-comment.ts, mute-post.ts, subscribe-to-community.ts, update-profile.ts
Refactored to use SDK mutations via wrappers instead of direct operations. Added optimistic cache updates (delete-comment), removed broadcast/invalidation logic (now SDK-handled), simplified mutation flow. Updated mutation keys and callbacks.
Web SDK Mutation Wrappers
apps/web/src/api/sdk-mutations/use-delete-comment-mutation.ts, use-mute-post-mutation.ts, use-subscribe-community-mutation.ts, use-unsubscribe-community-mutation.ts, use-update-profile-mutation.ts
New web-specific hooks that wrap SDK mutations, fetch active user context, create broadcast adapters, and delegate mutation execution. Provide integration between web auth flows and SDK mutations.
Web SDK Mutations Export
apps/web/src/api/sdk-mutations/index.ts
Added exports for five new mutation hooks to extend public API surface.
SDK Community Mutations
packages/sdk/src/modules/communities/mutations/use-subscribe-community.ts, use-unsubscribe-community.ts, use-mute-post.ts, index.ts
packages/sdk/src/modules/communities/index.ts
New mutation hooks with payload types for community operations. Include post-broadcast cache invalidation for user subscriptions and community data. Updated module exports to expose mutations.
SDK Post Mutations
packages/sdk/src/modules/posts/mutations/use-delete-comment.ts, index.ts
New hook for deleting posts/comments with payload type including optional parent/root metadata. Implements cache invalidation for feeds, blogs, parent entries, and discussions using auth adapter. Updated module exports.
SDK Account Mutations
packages/sdk/src/modules/accounts/mutations/use-account-update.ts
Updated to accept AuthContextV2 instead of AuthContext. Added optimistic cache updates for account data and post-broadcast cache invalidation via auth adapter for account/full queries.

Sequence Diagram(s)

sequenceDiagram
    participant WebComponent
    participant WebMutationWrapper as Web Mutation<br/>(useDeleteCommentMutation)
    participant SDKMutation as SDK Mutation<br/>(useDeleteComment)
    participant BroadcastAdapter
    participant QueryCache

    WebComponent->>WebMutationWrapper: mutate(payload)
    WebMutationWrapper->>WebMutationWrapper: getActiveUser()
    WebMutationWrapper->>WebMutationWrapper: createWebBroadcastAdapter()
    WebMutationWrapper->>SDKMutation: mutate(username, auth)
    SDKMutation->>BroadcastAdapter: buildDeleteCommentOp()
    SDKMutation->>BroadcastAdapter: broadcast(operation)
    BroadcastAdapter-->>SDKMutation: success
    SDKMutation->>QueryCache: invalidateQueries(feeds)
    SDKMutation->>QueryCache: invalidateQueries(discussions)
    SDKMutation->>QueryCache: invalidateQueries(parent)
    SDKMutation-->>WebMutationWrapper: result
    WebMutationWrapper->>WebComponent: onSuccess(callback)
Loading
sequenceDiagram
    participant WebComponent
    participant WebMutationWrapper as Web Mutation<br/>(updateProfile)
    participant SDKMutation as SDK Mutation<br/>(useAccountUpdate)
    participant BroadcastAdapter
    participant QueryCache

    WebComponent->>WebMutationWrapper: mutate(profile)
    WebMutationWrapper->>WebMutationWrapper: getActiveUser()
    WebMutationWrapper->>WebMutationWrapper: createWebBroadcastAdapter()
    WebMutationWrapper->>SDKMutation: mutate(username, auth)
    SDKMutation->>QueryCache: optimisticUpdate(FullAccount)
    SDKMutation->>BroadcastAdapter: buildAccountUpdateOp()
    SDKMutation->>BroadcastAdapter: broadcast(operation)
    BroadcastAdapter-->>SDKMutation: success
    SDKMutation->>QueryCache: invalidateQueries(accounts/full)
    SDKMutation-->>WebMutationWrapper: result
    WebMutationWrapper->>WebComponent: onSuccess()
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~75 minutes

Possibly related PRs

  • SDK improvements #650 — Introduces SDK mutation and broadcast/auth infrastructure changes that directly enable the mutation hooks and adapters used throughout this PR.
  • SDK mutation hooks and adapters #648 — Adds and exports the same SDK mutation hooks (useDeleteComment, useMutePost, useSubscribeCommunity, useUpdateProfile) that are wrapped and integrated in this PR.
  • Convert op, optimistic commenting fixes #613 — Modifies apps/web/src/api/mutations/delete-comment.ts with related optimistic cache and discussions invalidation logic.

Suggested labels

patch:sdk

Poem

🐰 Hops through mutations, hare does dare,
SDK wraps each web affair,
From cache to broadcast, adapters glare,
Comments delete, profiles laid bare!
Web and SDK, a perfect pair! 🎯

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Title check ❓ Inconclusive The title 'Wallets simplified, SDK Mutations unified' is vague and does not clearly summarize the main changes in the changeset, which involve migrating multiple mutations (delete-comment, mute-post, subscribe-to-community, update-profile) to SDK-based implementations. Consider a more specific title that clearly describes the primary change, such as 'Migrate delete-comment, mute-post, and community mutations to SDK-based implementations' or 'Consolidate mutations to use SDK implementation layer'.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch sdkmutation

Tip

Issue Planner is now in beta. Read the docs and try it out! Share your feedback on Discord.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

coderabbitai[bot]

This comment was marked as resolved.

@feruzm feruzm changed the title More SDK Mutations, mute, subscribe, unsubscribe, account update, delete comment Wallets simplified, SDK Mutations unified Feb 16, 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