Skip to content

Conversation

@feruzm
Copy link
Member

@feruzm feruzm commented Feb 11, 2026

Summary by CodeRabbit

  • Bug Fixes

    • Fixed authentication type reported for private-key logins.
  • Improvements

    • More consistent and accurate discussion updates when replying across all sort orders.
    • Faster, more reliable immediate UI feedback for new replies with improved optimistic handling and automatic cleanup on failure; drafts persist until confirmation and are cleaned up after submission.
    • Predicate-based invalidation improves cache refresh reliability.
  • Chores

    • Updated SDK and wallet package versions and changelogs.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 11, 2026

Caution

Review failed

The pull request is closed.

📝 Walkthrough

Walkthrough

Centralizes discussions cache key computation, passes root post context into comment payloads, changes optimistic-update handling to use a separate discussions optimistic entry and flip is_optimistic on confirmation, expands predicate-based cache invalidation, and maps loginType === 'privateKey' to emitted authType = 'key'.

Changes

Cohort / File(s) Summary
Create-reply mutation
apps/web/src/api/mutations/create-reply.ts
Adds getDiscussionsCacheKey; includes rootAuthor/rootPermlink in comment payload; replaces hard-coded cache keys with helper; creates a separate optimistic discussions entry (is_optimistic = true); flips is_optimistic on success and removes optimistic entry on failure using the helper.
Web broadcast adapter
apps/web/src/providers/sdk/web-broadcast-adapter.ts
Maps loginType === 'privateKey'authType = 'key'; extends invalidateQueries to accept array entries and predicate-based invalidation, iterating entries and skipping null/undefined.
SDK comment mutation
packages/sdk/src/modules/posts/mutations/use-comment.ts
Adds optional rootAuthor? and rootPermlink? to CommentPayload; reply invalidation now uses a predicate based on root (or fallback to parent) author+permlink to invalidate discussions across sort orders and still invalidates the parent entry.
SDK changelog & packages
packages/sdk/CHANGELOG.md, packages/sdk/package.json, packages/wallets/CHANGELOG.md, packages/wallets/package.json
Bumps @ecency/sdk to 2.0.1 and packages/wallets to 1.5.29; adds changelog entry noting optimistic updates fix and related notes.

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant DiscussionsCache
  participant EntryCache
  participant SDK
  participant Blockchain

  Client->>DiscussionsCache: insert optimistic discussion (is_optimistic = true)
  Client->>EntryCache: insert optimistic entry for pending tx
  Client->>SDK: call create-comment (includes rootAuthor/rootPermlink)
  SDK->>Blockchain: submit transaction (fire-and-forget)
  Blockchain-->>SDK: confirmation/event
  SDK->>EntryCache: confirm/update entry (retain/update optimistic entry)
  SDK->>DiscussionsCache: flip is_optimistic on matching discussion / invalidate predicate
  DiscussionsCache-->>Client: refreshed/confirmed discussions
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Suggested labels

patch

Poem

🐇 I tapped the thread with a curious hop,
Gave roots to replies so threads could grow top to top,
One hopeful hop shown as is_optimistic = true,
Then the ledger thumped steady and flipped it anew —
Hooray, the garden's tidy; onwards I bop. 🌿

🚥 Pre-merge checks | ✅ 1 | ❌ 2
❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title 'Optimistic updates fix' is vague and generic, lacking specificity about which optimistic update mechanism or component is being fixed. Consider using a more descriptive title that specifies what aspect of optimistic updates is being fixed, such as 'Fix optimistic updates for nested replies cache invalidation' or 'Fix optimistic entry flipping in discussions cache'.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

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

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

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.

coderabbitai[bot]

This comment was marked as resolved.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@apps/web/src/api/mutations/create-reply.ts`:
- Around line 120-126: The cache update is matching entries by permlink only
which can corrupt discussions cache because permlinks are only unique per
author; update all places that call
queryClient.setQueryData(getDiscussionsCacheKey(), ...) — including the .then()
branch that sets is_optimistic to false, the .catch() branch that removes
optimistic entries, and the onError handler — to compare both r.permlink ===
permlink AND r.author === author when mapping or filtering entries (use the
existing permlink and author variables) so only the intended author's entry is
modified or removed.

@feruzm feruzm added the patch:sdk Patch bump for @ecency/sdk label Feb 12, 2026
@feruzm feruzm merged commit ad926d2 into develop Feb 12, 2026
@feruzm feruzm deleted the mutation branch February 12, 2026 06:43
@coderabbitai coderabbitai bot mentioned this pull request Feb 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

patch:sdk Patch bump for @ecency/sdk

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant