Skip to content

fix(accounts): preserve legacy publication field names#29

Open
tomcasaburi wants to merge 4 commits intomasterfrom
fix/ci-browser-timeout
Open

fix(accounts): preserve legacy publication field names#29
tomcasaburi wants to merge 4 commits intomasterfrom
fix/ci-browser-timeout

Conversation

@tomcasaburi
Copy link
Member

@tomcasaburi tomcasaburi commented Mar 11, 2026

Summary

Fix the publication compatibility layer so legacy plebbit-js instances still receive fields while newer implementations keep the renamed API.

Verification

  • yarn build
  • yarn test
  • yarn test:coverage:hooks-stores (fails on existing repo-wide baseline coverage gaps unrelated to this change)

Note

Medium Risk
Touches core publishing flows (comment/vote/edit/moderation/community edit) by rewriting payload field names and how data is stored, which could cause subtle regressions in publish/update behavior across different plebbit-js versions. Changes are compatibility-focused and covered by new legacy/mixed-version tests, reducing but not eliminating risk.

Overview
Improves plebbit-js compatibility by normalizing community field names differently for the wire vs local storage. Publication payloads sent to plebbit-js are now converted to legacy subplebbit* fields (and community* removed), while stored account data is normalized back to communityAddress (and legacy fields removed).

Updates account publishing and comment-update flows to backfill communityAddress onto returned publications when older plebbit-js objects only expose subplebbitAddress, and ensures updated comments are normalized before adding short-address metadata. Community lifecycle operations now accept legacy-only plebbit instances by checking for createSubplebbit* methods.

Adds tests covering legacy-only and mixed-schema plebbit-js implementations to ensure publish actions and community create/edit/delete work and that stored state consistently uses communityAddress without leaking legacy fields.

Written by Cursor Bugbot for commit 3feea56. This will update automatically on new commits. Configure here.

Summary by CodeRabbit

  • New Features

    • Added normalization and backfill for community/sub-community addresses so publication and comment payloads are standardized before storage.
  • Bug Fixes

    • Consistent handling and display of community identifiers across publishes, edits, and comment flows; legacy sub-community fields are no longer exposed and signer/author info is stripped from stored publication data.
  • Tests

    • Added comprehensive legacy-compatibility tests for community lifecycle and publishing flows.

@coderabbitai
Copy link

coderabbitai bot commented Mar 11, 2026

📝 Walkthrough

Walkthrough

Introduces normalization/backfill utilities for mapping legacy subplebbit* fields to modern community* fields; replaces the prior legacy helper and applies these utilities across publication, comment, and community-edit flows, with tests and legacy-only plebbit mocks added to verify compatibility.

Changes

Cohort / File(s) Summary
Plebbit compatibility
src/lib/plebbit-compat.ts
Removed withLegacySubplebbitAddress; added normalizePublicationOptionsForPlebbit, normalizePublicationOptionsForStore, normalizeCommunityEditOptionsForPlebbit, backfillPublicationCommunityAddress, and related normalization utilities to coerce between subplebbit* and community* fields.
Accounts publication flows
src/stores/accounts/accounts-actions.ts, src/stores/accounts/accounts-actions-internal.ts
Publication and comment option construction now routes through plebbit-compat normalization before calling plebbit and before persisting; stored options drop legacy subplebbitAddress; results are backfilled and comment community addresses normalized for state updates.
Accounts tests
src/stores/accounts/accounts-actions.test.ts, src/stores/accounts/accounts-actions-internal.test.ts
Added legacy-mocking plebbit factories and duplicated legacy-compat test suites that assert legacy subplebbit*community* mapping and stricter created-comment payload expectations.
Communities store & tests
src/stores/communities/communities-store.ts, src/stores/communities/communities-store.test.ts
Switched capability checks to use wrapper getPlebbitCreateCommunity(...); added LegacyOnlyPlebbit scaffolding and lifecycle tests validating create/edit/delete via legacy subplebbit methods.
Public declarations
src/lib/plebbit-compat.ts
Exports updated: removed withLegacySubplebbitAddress; added new normalization/backfill function exports.

Sequence Diagram(s)

sequenceDiagram
    participant Actions as Accounts Actions
    participant Compat as plebbit-compat
    participant Plebbit as PlebbitJS Client
    participant Store as Local Store/DB

    rect rgba(200,200,255,0.5)
    Actions->>Compat: normalizePublicationOptionsForPlebbit(options)
    Compat-->>Actions: normalizedOptions
    end

    rect rgba(200,255,200,0.5)
    Actions->>Plebbit: createX(normalizedOptions)
    Plebbit-->>Actions: createdPublication
    end

    rect rgba(255,200,200,0.5)
    Actions->>Compat: backfillPublicationCommunityAddress(createdPublication, storedOptions)
    Compat-->>Actions: backfilledPublication
    Actions->>Store: persist(backfilledPublication)
    Store-->>Actions: persistedConfirmation
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

🐰 I hop through fields both old and new,
I map and backfill so quiet and true.
Comments find homes where addresses meet,
Legacy and modern now shake little feet.
thump — carrots for normalized treats.

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: preserving legacy publication field names to restore compatibility with older plebbit-js clients while maintaining internal communityAddress representation.

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

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/ci-browser-timeout

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

@tomcasaburi
Copy link
Member Author

Addressed the valid legacy-compat findings in the latest commit. This update (1) keeps communityAddress on locally stored account comments/votes/edits while still remapping wire payloads for legacy plebbit-js, and (2) makes communitiesStore accept legacy createSubplebbit/getSubplebbit clients for create/edit/delete flows. Local verification: yarn build, yarn test, focused accounts/communities store tests, and a full coverage rerun that now reaches the repo's existing 100% hooks/stores baseline failure rather than a regression in this patch.

Copy link

@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

🧹 Nitpick comments (1)
src/stores/communities/communities-store.test.ts (1)

12-35: Consider reusing one legacy-only plebbit test fixture.

This shim overlaps with LegacyOnlyPlebbit in src/stores/accounts/accounts-actions.test.ts lines 145-197. Keeping two hand-rolled compatibility mocks in sync will get brittle as the mapping rules evolve.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/stores/communities/communities-store.test.ts` around lines 12 - 35,
Replace the duplicated in-file shim by reusing the existing legacy-only plebbit
fixture instead of redefining createLegacyOnlyAccount/LegacyOnlyPlebbit here:
remove the local createLegacyOnlyAccount definition and import the shared
fixture (or move it to a shared test-fixtures module if it isn't exported) and
update tests to call that imported createLegacyOnlyAccount; ensure the symbol
names (createLegacyOnlyAccount / LegacyOnlyPlebbit) are exported from the source
module or the shared fixture module so tests can consume the same
implementation.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/lib/plebbit-compat.ts`:
- Around line 12-15: Replace the broad plebbitSupportsCommunityNaming heuristic
with per-operation detection or an explicit capability flag: stop using
plebbitSupportsCommunityNaming inside normalizePublicationOptionsForPlebbit and
normalizeCommunityEditOptionsForPlebbit and instead detect support for renamed
fields the same way getPlebbitCreateCommunity/getPlebbitGetCommunity do (or read
an explicit capability flag from the plebbit wrapper), then branch per-operation
to choose legacy subplebbit* field names or new community field names when
building publication and community-edit payloads; remove reliance on unrelated
methods like createCommunity/getCommunity/createCommunityEdit for this decision
and ensure each normalization function checks only the specific operation
capability before mutating field names.

---

Nitpick comments:
In `@src/stores/communities/communities-store.test.ts`:
- Around line 12-35: Replace the duplicated in-file shim by reusing the existing
legacy-only plebbit fixture instead of redefining
createLegacyOnlyAccount/LegacyOnlyPlebbit here: remove the local
createLegacyOnlyAccount definition and import the shared fixture (or move it to
a shared test-fixtures module if it isn't exported) and update tests to call
that imported createLegacyOnlyAccount; ensure the symbol names
(createLegacyOnlyAccount / LegacyOnlyPlebbit) are exported from the source
module or the shared fixture module so tests can consume the same
implementation.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: b558892b-4bd5-48da-949b-c51191b2ec5c

📥 Commits

Reviewing files that changed from the base of the PR and between bb8f008 and d5ecef3.

📒 Files selected for processing (5)
  • src/lib/plebbit-compat.ts
  • src/stores/accounts/accounts-actions.test.ts
  • src/stores/accounts/accounts-actions.ts
  • src/stores/communities/communities-store.test.ts
  • src/stores/communities/communities-store.ts

Comment on lines +12 to +15
const plebbitSupportsCommunityNaming = (plebbit: any) =>
typeof plebbit?.createCommunity === "function" ||
typeof plebbit?.getCommunity === "function" ||
typeof plebbit?.createCommunityEdit === "function";
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🌐 Web query:

In @plebbit/plebbit-js, is support for communityAddress/communityEditguaranteed to ship in lockstep with thecreateCommunity/getCommunity/createCommunityEditrenames, or can publication APIs still requiresubplebbit* fields while some community lifecycle methods are already renamed?

💡 Result:

No—there’s no indication that communityAddress / communityEdit is guaranteed to ship in lockstep with any createCommunity / getCommunity / createCommunityEdit renames.

On current @plebbit/plebbit-js master (package version 0.0.11), the public docs and schemas still use subplebbit* terminology:

  • The README “Schema” defines Publication.subplebbitAddress (and SubplebbitEdit, etc.), not communityAddress / communityEdit. [1]
  • The Zod schema for publication creation (CreatePublicationUserOptionsSchema) still requires subplebbitAddress. [2]

Also, ongoing rename work is being done piecemeal and can be breaking: Issue #70 proposes renaming publication.subplebbitAddress → subplebbitPublicKey and explicitly calls it a “clean break” with “no backward compatibility shim,” which implies these changes aren’t necessarily coupled to higher-level method naming consistency. [3]

So yes: it’s entirely plausible (and consistent with the repo today) that some “community lifecycle” methods could be renamed while publication APIs still require subplebbit* fields, until the publication schemas are separately updated.

Sources: [1] [2] [3]


Replace the global capability heuristic with per-operation detection or an explicit feature flag.

The plebbitSupportsCommunityNaming helper infers naming conventions by checking for createCommunity, getCommunity, and createCommunityEdit. However, upstream rename work happens piecemeal: community lifecycle methods may be renamed while publication schemas still require subplebbit* fields. This risks publishing payloads with incorrect field names if a plebbit wrapper has partial support for the renamed APIs.

This file already implements per-operation detection elsewhere (e.g., getPlebbitCreateCommunity, getPlebbitGetCommunity). Use the same pattern for normalizePublicationOptionsForPlebbit and normalizeCommunityEditOptionsForPlebbit (lines 27–44 and 58–74), or rely on an explicit capability flag from the upstream library instead of inferring from unrelated methods.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/lib/plebbit-compat.ts` around lines 12 - 15, Replace the broad
plebbitSupportsCommunityNaming heuristic with per-operation detection or an
explicit capability flag: stop using plebbitSupportsCommunityNaming inside
normalizePublicationOptionsForPlebbit and
normalizeCommunityEditOptionsForPlebbit and instead detect support for renamed
fields the same way getPlebbitCreateCommunity/getPlebbitGetCommunity do (or read
an explicit capability flag from the plebbit wrapper), then branch per-operation
to choose legacy subplebbit* field names or new community field names when
building publication and community-edit payloads; remove reliance on unrelated
methods like createCommunity/getCommunity/createCommunityEdit for this decision
and ensure each normalization function checks only the specific operation
capability before mutating field names.

@tomcasaburi
Copy link
Member Author

Addressed the substantive review findings in commit f1fe98d. This follow-up keeps legacy publication and community-edit wire payloads on subplebbit fields, but backfills returned publication and comment objects plus the internal update paths so stored account comments, votes, and edits still preserve the repo’s internal communityAddress shape. Local verification after this commit: yarn build, yarn test, focused accounts-actions, accounts-actions-internal, and hooks/accounts suites. yarn test:coverage:hooks-stores still reports the repo’s existing 100 percent baseline gaps outside this review fix. The remaining bot note about reusing a shared legacy-only test fixture is a non-blocking maintainability nit, not a correctness issue.

@tomcasaburi
Copy link
Member Author

Addressed the substantive review findings in . This follow-up keeps legacy publication/community-edit wire payloads on , but backfills returned publication/comment objects and internal update paths so stored account comments/votes/edits still preserve the repo’s internal shape. Local verification after this commit: yarn run v1.22.22
$ rm -rf dist
$ tsc --project config/tsconfig.json
Done in 2.29s., yarn run v1.22.22
$ vitest run --config config/vitest.config.js

RUN v4.0.18 /Users/Tommaso/Desktop/bitsocial/bitsocial-react-hooks/src

✓ stores/accounts/accounts-store.test.ts (6 tests) 542ms
✓ initializeAccountsStore catch when startUpdatingAccountCommentOnCommentUpdateEvents rejects 307ms
✓ stores/comments/comments-store.test.ts (10 tests) 769ms
✓ comment without timestamp registers once(update) for addCidToAccountComment 302ms
✓ addCidToAccountComment error is logged when it rejects 301ms
✓ stores/accounts/accounts-actions-internal.test.ts (37 tests) 1585ms
✓ hooks/comments.test.ts (31 tests) 500ms
✓ hooks/plebbit-rpc.test.ts (16 tests) 497ms
✓ hooks/states.test.ts (16 tests) 1977ms
✓ fetch comment 417ms
✓ fetch community 663ms
✓ fetch feed 713ms
✓ hooks/communities.test.ts (27 tests | 1 skipped) 403ms
✓ hooks/accounts/utils.test.ts (14 tests) 372ms
✓ lib/chain/chain.test.ts (9 tests | 1 skipped) 117ms
✓ stores/communities/communities-store.test.ts (14 tests) 169ms
✓ lib/plebbit-js/plebbit-js-mock.test.ts (5 tests) 113ms
✓ hooks/actions/actions.test.ts (44 tests) 3137ms
✓ publishVote with no onChallenge/onChallengeVerification completes successfully 2085ms
✓ lib/utils/utils.test.ts (13 tests) 57ms
✓ stores/accounts/accounts-database.test.ts (53 tests) 58ms
✓ hooks/authors/author-avatars.test.ts (35 tests) 52ms
✓ stores/accounts/utils.test.ts (28 tests) 18ms
✓ stores/replies-pages/replies-pages-store.test.ts (19 tests) 4015ms
✓ addNextRepliesPageToStore skips when existing fresher (branch 116) 405ms
✓ add next pages from comment.replies.pageCids 1414ms
✓ add next pages from comment.replies.pages 1407ms
✓ addCidToAccountComment error is logged when it rejects 305ms
✓ hooks/utils/use-interval.test.ts (7 tests) 16ms
✓ stores/feeds/utils.test.ts (39 tests) 8ms
✓ stores/feeds/feed-sorter.test.ts (28 tests) 6ms
✓ stores/feeds/feeds-store.test.ts (18 tests) 4245ms
✓ add feed, increment page, block address 1831ms
✓ addCommunitiesPagesOnLowBufferedFeeds skips cache-expired community 302ms
✓ resetFeed resets page to 1 and clears loaded/updated 464ms
✓ addNextCommunityPageToStore catch logs error when fetch throws 408ms
✓ lib/localforage-lru/localforage-lru.test.ts (5 tests) 3ms
✓ stores/authors-comments/utils.test.ts (15 tests) 8ms
✓ stores/replies/utils.test.ts (30 tests) 5ms
✓ stores/replies/replies-store.test.ts (10 tests) 4499ms
✓ add feed, increment page 766ms
✓ addFeedToStoreOrUpdateComment with flat does not add nested feeds 2036ms
✓ resetFeed resets page to 1 and clears loaded/updated 361ms
✓ addNextRepliesPageToStore catch when addNextRepliesPageToStore rejects 664ms
✓ updateFeedsAgain when updateFeeds called twice quickly 656ms
✓ stores/accounts/account-generator.test.ts (7 tests) 4ms
✓ lib/community-address.test.ts (7 tests) 2ms
✓ stores/replies-pages/utils.test.ts (4 tests) 3ms
✓ hooks/accounts/accounts.test.ts (105 tests) 5988ms
✓ cid gets added to account comment after fetched in useComment 2144ms
✓ create owner community and edit it 1023ms
✓ hooks/authors/authors.test.ts (52 tests | 4 skipped) 8859ms
✓ useAuthorAddress extends shortAddress when shorter than crypto name 2036ms
✓ get multiple pages until no more previous comment 2538ms
✓ find more recent lastCommentCid while scrolling 611ms
✓ some author comments have wrong author 1466ms
✓ cannot spam load more 1162ms
✓ stores/accounts/accounts-actions.test.ts (51 tests) 9460ms
✓ publishComment retries on challenge failure 401ms
✓ deleteComment abandons pending publish session, no-op mutation when session removed 2039ms
✓ abandonAndStopPublishSession when comment has no stop: skips stop (branch 58) 2092ms
✓ error handler no-op when session abandoned 2095ms
✓ stores/communities-pages/communities-pages-store.test.ts (28 tests) 10702ms
✓ addNextCommunityPageToStore scopes cached page clients per account 406ms
✓ invalidateCommunityPages removes loaded page chain from store and database 405ms
✓ addCidToAccountComment error is logged when it rejects 304ms
✓ add next pages from community.posts.pageCids 1413ms
✓ add next pages from community.posts.pages 1409ms
✓ page comments without updatedAt are still indexed on first insert 2044ms
✓ existing fresher indexed comment is not overwritten by older/empty-freshness page data 4082ms
✓ hooks/feeds/feeds.test.ts (47 tests) 13472ms
✓ change community addresses and sort type 767ms
✓ get feed with 1 community and scroll to multiple pages 1730ms
✓ get feed with 1 community sorted by new and scroll to multiple pages 916ms
✓ get multiple communities sorted by new and scroll to multiple pages 563ms
✓ get multiple communities with filter and scroll to multiple pages 412ms
✓ get feed page 1 and 2 with multiple communities sorted by topAll 308ms
✓ 1 community, scroll to end of feed, hasMore becomes false 511ms
✓ multiple communities, scroll to end of feed, hasMore becomes false 1175ms
✓ community updates while we are scrolling 411ms
✓ store page pages in database 410ms
✓ feed doesn't contain blocked addresses 377ms
✓ feed doesn't contain blocked cids 411ms
✓ communityAddressesWithNewerPosts and reset 371ms
✓ updated feeds is updated, loaded feeds is not 308ms
✓ prepend changes to append and publish 512ms
✓ scroll pages and publish 307ms
✓ modQueue reset refreshes the latest community snapshot before rebuilding 321ms
✓ hooks/replies.test.ts (57 tests) 21168ms
✓ sort type new, switch to sort type old, switch to different comment (comment argument) 409ms
✓ scroll pages 825ms (retry x4)
✓ hasMore false 305ms
✓ sort type best, changing flat: true to false, false to true 305ms
✓ sort type new, changing flat: true to false, false to true 466ms
✓ new nested replies are not automatically added to feed, loadMore must be called 615ms
✓ new nested replies (with no nested replies initially) are not automatically added to feed, loadMore must be called 663ms
✓ flat 416ms
✓ scroll pages 2198ms
✓ scroll pages and publish 2196ms
✓ scroll pages append and publish 2310ms
✓ scroll pages flat 2197ms
✓ scroll pages flat and publish 2303ms
✓ scroll pages flat, append and publish 2308ms
✓ stores/authors-comments/authors-comments-store.test.ts (13 tests) 27473ms
✓ get multiple pages 2432ms
✓ discover new lastCommentCid while scrolling 4858ms
✓ multiple filters and authors at the same time 3352ms
✓ store error paths 561ms
✓ updateCommentsOnCommentsChange addCommentToStore rejection is caught 553ms
✓ setLastCommentCidOnCommentsChange returns when comment older than buffered 15194ms

Test Files 35 passed (35)
Tests 894 passed | 6 skipped (900)
Start at 21:48:57
Duration 30.59s (transform 20.46s, setup 852ms, import 38.45s, tests 120.30s, environment 15.31s)

JSON report written to /Users/Tommaso/Desktop/bitsocial/bitsocial-react-hooks/src/.vitest-reports/tests.json
Done in 31.00s., focused , , and suites. yarn run v1.22.22
$ yarn test:coverage && node scripts/verify-hooks-stores-coverage.mjs
$ vitest run --config config/vitest.config.js --coverage.enabled --coverage.provider=istanbul --coverage.reporter=text --coverage.reporter=json --coverage.reporter=json-summary --coverage.reportsDirectory=./coverage

RUN v4.0.18 /Users/Tommaso/Desktop/bitsocial/bitsocial-react-hooks/src
Coverage enabled with istanbul

✓ stores/accounts/accounts-store.test.ts (6 tests) 550ms
✓ initializeAccountsStore catch when startUpdatingAccountCommentOnCommentUpdateEvents rejects 306ms
✓ stores/comments/comments-store.test.ts (10 tests) 775ms
✓ comment without timestamp registers once(update) for addCidToAccountComment 302ms
✓ addCidToAccountComment error is logged when it rejects 301ms
✓ stores/accounts/accounts-actions-internal.test.ts (37 tests) 1592ms
✓ hooks/comments.test.ts (31 tests) 516ms
✓ hooks/states.test.ts (16 tests) 1925ms
✓ fetch comment 414ms
✓ fetch community 613ms
✓ fetch feed 710ms
✓ hooks/plebbit-rpc.test.ts (16 tests) 496ms
✓ hooks/communities.test.ts (27 tests | 1 skipped) 409ms
✓ hooks/accounts/utils.test.ts (14 tests) 375ms
✓ lib/plebbit-js/plebbit-js-mock.test.ts (5 tests) 112ms
✓ stores/communities/communities-store.test.ts (14 tests) 174ms
✓ lib/chain/chain.test.ts (9 tests | 1 skipped) 130ms
✓ lib/utils/utils.test.ts (13 tests) 59ms
✓ hooks/actions/actions.test.ts (44 tests) 3171ms
✓ publishVote with no onChallenge/onChallengeVerification completes successfully 2086ms
✓ stores/replies-pages/replies-pages-store.test.ts (19 tests) 4010ms
✓ addNextRepliesPageToStore skips when existing fresher (branch 116) 407ms
✓ add next pages from comment.replies.pageCids 1412ms
✓ add next pages from comment.replies.pages 1407ms
✓ addCidToAccountComment error is logged when it rejects 306ms
✓ stores/accounts/accounts-database.test.ts (53 tests) 61ms
✓ stores/feeds/feed-sorter.test.ts (28 tests) 7ms
✓ stores/accounts/utils.test.ts (28 tests) 18ms
✓ hooks/authors/author-avatars.test.ts (35 tests) 58ms
✓ hooks/utils/use-interval.test.ts (7 tests) 15ms
✓ stores/authors-comments/utils.test.ts (15 tests) 12ms
✓ stores/feeds/utils.test.ts (39 tests) 9ms
✓ stores/feeds/feeds-store.test.ts (18 tests) 4381ms
✓ add feed, increment page, block address 1873ms
✓ addCommunitiesPagesOnLowBufferedFeeds skips cache-expired community 303ms
✓ resetFeed resets page to 1 and clears loaded/updated 412ms
✓ resetFeed logs and continues when refreshCommunity rejects 357ms
✓ addNextCommunityPageToStore catch logs error when fetch throws 461ms
✓ stores/replies/replies-store.test.ts (10 tests) 4448ms
✓ add feed, increment page 814ms
✓ addFeedToStoreOrUpdateComment with flat does not add nested feeds 2037ms
✓ addNextRepliesPageToStore catch when addNextRepliesPageToStore rejects 660ms
✓ updateFeedsAgain when updateFeeds called twice quickly 657ms
✓ lib/localforage-lru/localforage-lru.test.ts (5 tests) 4ms
✓ lib/community-address.test.ts (7 tests) 2ms
✓ stores/replies/utils.test.ts (30 tests) 6ms
✓ stores/accounts/account-generator.test.ts (7 tests) 4ms
✓ stores/replies-pages/utils.test.ts (4 tests) 2ms
✓ hooks/accounts/accounts.test.ts (105 tests) 5996ms
✓ cid gets added to account comment after fetched in useComment 2143ms
✓ create owner community and edit it 1021ms
✓ stores/accounts/accounts-actions.test.ts (51 tests) 9453ms
✓ publishComment retries on challenge failure 402ms
✓ deleteComment abandons pending publish session, no-op mutation when session removed 2029ms
✓ abandonAndStopPublishSession when comment has no stop: skips stop (branch 58) 2089ms
✓ error handler no-op when session abandoned 2089ms
✓ hooks/authors/authors.test.ts (52 tests | 4 skipped) 8874ms
✓ useAuthorAddress extends shortAddress when shorter than crypto name 2042ms
✓ get multiple pages until no more previous comment 2535ms
✓ find more recent lastCommentCid while scrolling 609ms
✓ some author comments have wrong author 1465ms
✓ cannot spam load more 1166ms
✓ stores/communities-pages/communities-pages-store.test.ts (28 tests) 10698ms
✓ addNextCommunityPageToStore scopes cached page clients per account 405ms
✓ invalidateCommunityPages removes loaded page chain from store and database 404ms
✓ addCidToAccountComment error is logged when it rejects 305ms
✓ add next pages from community.posts.pageCids 1414ms
✓ add next pages from community.posts.pages 1407ms
✓ page comments without updatedAt are still indexed on first insert 2036ms
✓ existing fresher indexed comment is not overwritten by older/empty-freshness page data 4087ms
✓ hooks/feeds/feeds.test.ts (47 tests) 13328ms
✓ change community addresses and sort type 566ms
✓ get feed with 1 community and scroll to multiple pages 1731ms
✓ get feed with 1 community sorted by new and scroll to multiple pages 874ms
✓ get multiple communities sorted by new and scroll to multiple pages 716ms
✓ get multiple communities with filter and scroll to multiple pages 361ms
✓ get feed and change active account 311ms
✓ 1 community, scroll to end of feed, hasMore becomes false 462ms
✓ multiple communities, scroll to end of feed, hasMore becomes false 1327ms
✓ feed doesn't contain blocked addresses 334ms
✓ feed doesn't contain blocked cids 313ms
✓ communityAddressesWithNewerPosts and reset 679ms
✓ updated feeds is updated, loaded feeds is not 309ms
✓ prepend changes to append and publish 475ms
✓ scroll pages and publish 314ms
✓ deleted local account post/reindex disappears from feed accountComments injection immediately 310ms
✓ modQueue reset refreshes the latest community snapshot before rebuilding 322ms
✓ hooks/replies.test.ts (57 tests) 20469ms
✓ scroll pages 365ms (retry x1)
✓ sort type new, changing flat: true to false, false to true 360ms
✓ new nested replies are not automatically added to feed, loadMore must be called 563ms
✓ new nested replies (with no nested replies initially) are not automatically added to feed, loadMore must be called 616ms
✓ change accountComments options, append, prepend, newerThan 308ms
✓ scroll pages 2194ms
✓ scroll pages and publish 2251ms
✓ scroll pages append and publish 2222ms
✓ scroll pages flat 2209ms
✓ scroll pages flat and publish 2305ms
✓ scroll pages flat, append and publish 2304ms
✓ stores/authors-comments/authors-comments-store.test.ts (13 tests) 27709ms
✓ get multiple pages 2442ms
✓ discover new lastCommentCid while scrolling 4940ms
✓ multiple filters and authors at the same time 3409ms
✓ store error paths 626ms
✓ updateCommentsOnCommentsChange addCommentToStore rejection is caught 559ms
✓ setLastCommentCidOnCommentsChange returns when comment older than buffered 15199ms

Test Files 35 passed (35)
Tests 894 passed | 6 skipped (900)
Start at 21:49:30
Duration 33.66s (transform 47.51s, setup 546ms, import 70.78s, tests 119.85s, environment 15.27s)

JSON report written to /Users/Tommaso/Desktop/bitsocial/bitsocial-react-hooks/src/.vitest-reports/tests.json
% Coverage report from istanbul
-------------------|---------|----------|---------|---------|-------------------
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
-------------------|---------|----------|---------|---------|-------------------
All files | 90.6 | 87.03 | 91.76 | 90.44 |
src | 71.42 | 50 | 100 | 71.42 |
index.ts | 71.42 | 50 | 100 | 71.42 | 7,10
src/hooks | 99.4 | 96.12 | 100 | 99.35 |
comments.ts | 100 | 100 | 100 | 100 |
communities.ts | 98.74 | 92.06 | 100 | 98.64 | 111,118
plebbit-rpc.ts | 98 | 96 | 100 | 97.72 | 84
replies.ts | 100 | 93.22 | 100 | 100 | 87-95
states.ts | 100 | 100 | 100 | 100 |
...hooks/accounts | 100 | 96.6 | 100 | 100 |
accounts.ts | 100 | 95.4 | 100 | 100 | ...68-380,574,627
utils.ts | 100 | 100 | 100 | 100 |
src/hooks/actions | 100 | 99.17 | 100 | 100 |
actions.ts | 100 | 99.17 | 100 | 100 | 226
src/hooks/authors | 99.68 | 94.25 | 100 | 100 |
...or-avatars.ts | 100 | 100 | 100 | 100 |
authors.ts | 99.53 | 93.29 | 100 | 100 | ...04,478,488,509
utils.ts | 100 | 100 | 100 | 100 |
src/hooks/feeds | 100 | 92.1 | 100 | 100 |
feeds.ts | 100 | 92.1 | 100 | 100 | ...43,258,294,371
src/hooks/utils | 100 | 100 | 100 | 100 |
use-interval.ts | 100 | 100 | 100 | 100 |
src/lib | 94.21 | 89.04 | 93.93 | 94.16 |
...ty-address.ts | 100 | 100 | 100 | 100 |
debug-utils.ts | 60 | 100 | 0 | 60 | 5,14
...bit-compat.ts | 93.33 | 81.57 | 100 | 93.33 | 17,42,56,72
polyfill.ts | 40 | 50 | 100 | 40 | 6-8,11
test-utils.ts | 95.69 | 83.33 | 100 | 95.6 | 56,115,124,128
validator.ts | 95.48 | 91.72 | 91.3 | 95.48 | ...23-527,533,561
src/lib/chain | 63.44 | 35.13 | 66.66 | 62.85 |
chain.ts | 63.44 | 35.13 | 66.66 | 62.85 | ...40,272,277,357
...ocalforage-lru | 82.41 | 83.78 | 60.86 | 82.22 |
index.ts | 28.57 | 50 | 0 | 28.57 | 7-18
...forage-lru.ts | 86.9 | 85.71 | 87.5 | 86.74 | ...25-136,161,167
...lib/plebbit-js | 38.42 | 26.79 | 43.85 | 38.46 |
index.ts | 90 | 50 | 100 | 90 | 37
...ck-content.ts | 7.78 | 0.89 | 0 | 7.84 | ...1440,1444-1445
...it-js-mock.ts | 96.56 | 86.45 | 94.11 | 96.53 | ...04,563,640-641
...it-js/fixtures | 100 | 100 | 100 | 100 |
...wn-example.ts | 100 | 100 | 100 | 100 |
src/lib/utils | 87.65 | 82.05 | 86.11 | 88.28 |
...moderation.ts | 96.55 | 95.45 | 100 | 96.55 | 39
utils.ts | 86.44 | 78.94 | 84.84 | 87.14 | ...86-390,421-425
...tores/accounts | 99.84 | 98.23 | 100 | 100 |
...-generator.ts | 100 | 100 | 100 | 100 |
...s-internal.ts | 100 | 100 | 100 | 100 |
...ts-actions.ts | 99.65 | 96.22 | 100 | 100 | ...65,793,816,872
...s-database.ts | 100 | 100 | 100 | 100 |
...unts-store.ts | 100 | 100 | 100 | 100 |
utils.ts | 100 | 100 | 100 | 100 |
...thors-comments | 100 | 99.13 | 100 | 100 |
...ents-store.ts | 100 | 98.95 | 100 | 100 | 479
utils.ts | 100 | 100 | 100 | 100 |
...tores/comments | 100 | 100 | 100 | 100 |
...ents-store.ts | 100 | 100 | 100 | 100 |
...es/communities | 100 | 97.61 | 100 | 100 |
...ties-store.ts | 100 | 97.61 | 100 | 100 | 300
...munities-pages | 100 | 100 | 100 | 100 |
...ages-store.ts | 100 | 100 | 100 | 100 |
src/stores/feeds | 98.29 | 92.28 | 100 | 98.24 |
feed-sorter.ts | 100 | 100 | 100 | 100 |
feeds-store.ts | 100 | 100 | 100 | 100 |
utils.ts | 97 | 89.41 | 100 | 96.91 | ...97,267,394-396
...stores/replies | 99.25 | 95.8 | 100 | 99.23 |
...ents-store.ts | 100 | 100 | 100 | 100 |
replies-store.ts | 100 | 100 | 100 | 100 |
utils.ts | 98.67 | 94.37 | 100 | 98.63 | 276-278,421
.../replies-pages | 100 | 96.34 | 100 | 100 |
...ages-store.ts | 100 | 95.83 | 100 | 100 | 116,175
utils.ts | 100 | 100 | 100 | 100 |
-------------------|---------|----------|---------|---------|-------------------
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command. still reports the repo’s existing 100% baseline gaps outside this review fix. The remaining bot note about reusing a shared legacy-only test fixture is a non-blocking maintainability nit, not a correctness issue.

Copy link

@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: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/lib/plebbit-compat.ts`:
- Around line 75-90: The helper backfillPublicationCommunityAddress incorrectly
returns early when publication.subplebbitAddress exists, skipping normalization;
fix by changing the early-return condition in
backfillPublicationCommunityAddress to only return if publication is falsy or
publication.communityAddress is already present (remove the
publication.subplebbitAddress check), then continue to compute communityAddress
from options?.communityAddress ?? options?.subplebbitAddress and assign
publication.communityAddress = communityAddress when it’s missing so legacy
subplebbitAddress entries get normalized.

In `@src/stores/accounts/accounts-actions.test.ts`:
- Around line 199-238: The partial-rename mock created by
createLegacyPublicationSchemaPlebbitMock is missing an override for
publishCommunityEdit (and/or createCommunityEdit/createSubplebbitEdit if those
are the actual method names used) so tests don't assert that
communityAddress/communityEdit are stripped; update the
LegacyPublicationSchemaPlebbit class to add an async publishCommunityEdit(opts:
any) method that throws if "communityAddress" or "communityEdit" (or
"communityEdit" and "communityAddress" as appropriate) exist in opts and
otherwise calls super.publishCommunityEdit(opts), and ensure the factory
createLegacyPublicationSchemaPlebbit still returns the instance and preserves
getShortAddress/getShortCid from PlebbitJsMock.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 9672a89e-2bdf-4be5-95c6-fae9a2a2d114

📥 Commits

Reviewing files that changed from the base of the PR and between d5ecef3 and f1fe98d.

📒 Files selected for processing (5)
  • src/lib/plebbit-compat.ts
  • src/stores/accounts/accounts-actions-internal.test.ts
  • src/stores/accounts/accounts-actions-internal.ts
  • src/stores/accounts/accounts-actions.test.ts
  • src/stores/accounts/accounts-actions.ts

Comment on lines +199 to +238
function createLegacyPublicationSchemaPlebbitMock() {
class LegacyPublicationSchemaPlebbit extends BasePlebbit {
async createComment(opts: any) {
if ("communityAddress" in opts) {
throw new Error("createComment received communityAddress");
}
return super.createComment(opts);
}

async createVote(opts: any) {
if ("communityAddress" in opts) {
throw new Error("createVote received communityAddress");
}
return super.createVote(opts);
}

async createCommentEdit(opts: any) {
if ("communityAddress" in opts) {
throw new Error("createCommentEdit received communityAddress");
}
if ("communityEdit" in opts) {
throw new Error("createCommentEdit received communityEdit");
}
return super.createCommentEdit(opts);
}

async createCommentModeration(opts: any) {
if ("communityAddress" in opts) {
throw new Error("createCommentModeration received communityAddress");
}
return super.createCommentModeration(opts);
}
}

const createLegacyPublicationSchemaPlebbit: any = async (...args: any[]) =>
new LegacyPublicationSchemaPlebbit(...args);
createLegacyPublicationSchemaPlebbit.getShortAddress = PlebbitJsMock.getShortAddress;
createLegacyPublicationSchemaPlebbit.getShortCid = PlebbitJsMock.getShortCid;
return createLegacyPublicationSchemaPlebbit;
}
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Cover publishCommunityEdit() in the partial-rename mock too.

This mock still inherits the default createCommunityEdit/createSubplebbitEdit behavior, so the suite below never proves that remote community edits were normalized away from communityAddress/communityEdit. A regression in normalizeCommunityEditOptionsForPlebbit() would still let Lines 971-977 pass.

Suggested test hardening
 class LegacyPublicationSchemaPlebbit extends BasePlebbit {
   async createComment(opts: any) {
     if ("communityAddress" in opts) {
       throw new Error("createComment received communityAddress");
     }
     return super.createComment(opts);
   }
@@
   async createCommentModeration(opts: any) {
     if ("communityAddress" in opts) {
       throw new Error("createCommentModeration received communityAddress");
     }
     return super.createCommentModeration(opts);
   }
+
+  async createCommunityEdit(opts: any) {
+    if ("communityAddress" in opts) {
+      throw new Error("createCommunityEdit received communityAddress");
+    }
+    if ("communityEdit" in opts) {
+      throw new Error("createCommunityEdit received communityEdit");
+    }
+    return super.createCommunityEdit(opts);
+  }
+
+  async createSubplebbitEdit(opts: any) {
+    if ("communityAddress" in opts) {
+      throw new Error("createSubplebbitEdit received communityAddress");
+    }
+    if ("communityEdit" in opts) {
+      throw new Error("createSubplebbitEdit received communityEdit");
+    }
+    return super.createSubplebbitEdit(opts);
+  }
 }
As per coding guidelines, `src/stores/**/*.{ts,tsx}` must "Maintain mandatory 100% test coverage for hooks and stores; every feature or bug fix must include/adjust tests to keep coverage at 100%, verified via `node scripts/verify-hooks-stores-coverage.mjs`."
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
function createLegacyPublicationSchemaPlebbitMock() {
class LegacyPublicationSchemaPlebbit extends BasePlebbit {
async createComment(opts: any) {
if ("communityAddress" in opts) {
throw new Error("createComment received communityAddress");
}
return super.createComment(opts);
}
async createVote(opts: any) {
if ("communityAddress" in opts) {
throw new Error("createVote received communityAddress");
}
return super.createVote(opts);
}
async createCommentEdit(opts: any) {
if ("communityAddress" in opts) {
throw new Error("createCommentEdit received communityAddress");
}
if ("communityEdit" in opts) {
throw new Error("createCommentEdit received communityEdit");
}
return super.createCommentEdit(opts);
}
async createCommentModeration(opts: any) {
if ("communityAddress" in opts) {
throw new Error("createCommentModeration received communityAddress");
}
return super.createCommentModeration(opts);
}
}
const createLegacyPublicationSchemaPlebbit: any = async (...args: any[]) =>
new LegacyPublicationSchemaPlebbit(...args);
createLegacyPublicationSchemaPlebbit.getShortAddress = PlebbitJsMock.getShortAddress;
createLegacyPublicationSchemaPlebbit.getShortCid = PlebbitJsMock.getShortCid;
return createLegacyPublicationSchemaPlebbit;
}
function createLegacyPublicationSchemaPlebbitMock() {
class LegacyPublicationSchemaPlebbit extends BasePlebbit {
async createComment(opts: any) {
if ("communityAddress" in opts) {
throw new Error("createComment received communityAddress");
}
return super.createComment(opts);
}
async createVote(opts: any) {
if ("communityAddress" in opts) {
throw new Error("createVote received communityAddress");
}
return super.createVote(opts);
}
async createCommentEdit(opts: any) {
if ("communityAddress" in opts) {
throw new Error("createCommentEdit received communityAddress");
}
if ("communityEdit" in opts) {
throw new Error("createCommentEdit received communityEdit");
}
return super.createCommentEdit(opts);
}
async createCommentModeration(opts: any) {
if ("communityAddress" in opts) {
throw new Error("createCommentModeration received communityAddress");
}
return super.createCommentModeration(opts);
}
async createCommunityEdit(opts: any) {
if ("communityAddress" in opts) {
throw new Error("createCommunityEdit received communityAddress");
}
if ("communityEdit" in opts) {
throw new Error("createCommunityEdit received communityEdit");
}
return super.createCommunityEdit(opts);
}
async createSubplebbitEdit(opts: any) {
if ("communityAddress" in opts) {
throw new Error("createSubplebbitEdit received communityAddress");
}
if ("communityEdit" in opts) {
throw new Error("createSubplebbitEdit received communityEdit");
}
return super.createSubplebbitEdit(opts);
}
}
const createLegacyPublicationSchemaPlebbit: any = async (...args: any[]) =>
new LegacyPublicationSchemaPlebbit(...args);
createLegacyPublicationSchemaPlebbit.getShortAddress = PlebbitJsMock.getShortAddress;
createLegacyPublicationSchemaPlebbit.getShortCid = PlebbitJsMock.getShortCid;
return createLegacyPublicationSchemaPlebbit;
}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/stores/accounts/accounts-actions.test.ts` around lines 199 - 238, The
partial-rename mock created by createLegacyPublicationSchemaPlebbitMock is
missing an override for publishCommunityEdit (and/or
createCommunityEdit/createSubplebbitEdit if those are the actual method names
used) so tests don't assert that communityAddress/communityEdit are stripped;
update the LegacyPublicationSchemaPlebbit class to add an async
publishCommunityEdit(opts: any) method that throws if "communityAddress" or
"communityEdit" (or "communityEdit" and "communityAddress" as appropriate) exist
in opts and otherwise calls super.publishCommunityEdit(opts), and ensure the
factory createLegacyPublicationSchemaPlebbit still returns the instance and
preserves getShortAddress/getShortCid from PlebbitJsMock.

Copy link

@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

♻️ Duplicate comments (1)
src/lib/plebbit-compat.ts (1)

75-90: ⚠️ Potential issue | 🟠 Major

Prefer the returned publication’s legacy address when backfilling.

This still misses legacy responses where the only address lives on publication.subplebbitAddress. That matters for flows like publishCommunityEdit(address, opts), where the address can be passed separately and options may not carry communityAddress/subplebbitAddress at all. In that case communityAddress stays unset even though the returned publication already has the legacy field.

Suggested fix
 export const backfillPublicationCommunityAddress = <
   T extends Record<string, any> | undefined,
   O extends Record<string, any> | undefined,
 >(
   publication: T,
   options: O,
 ): T => {
-  const communityAddress = options?.communityAddress ?? options?.subplebbitAddress;
   if (!publication || publication.communityAddress) {
     return publication;
   }
+  const communityAddress =
+    publication.subplebbitAddress ?? options?.communityAddress ?? options?.subplebbitAddress;
   if (!communityAddress) {
     return publication;
   }
   publication.communityAddress = communityAddress;
   return publication;
 };
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/lib/plebbit-compat.ts` around lines 75 - 90,
backfillPublicationCommunityAddress currently only uses options
(communityAddress or subplebbitAddress) to backfill publication.communityAddress
and misses cases where the returned publication already carries a legacy address
in publication.subplebbitAddress; update the function so that if
publication.communityAddress is unset you first derive communityAddress from
options as now, but if that is falsy, fall back to publication.subplebbitAddress
and assign that to publication.communityAddress; reference the function name
backfillPublicationCommunityAddress and the symbol publication.subplebbitAddress
when making the change.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/stores/accounts/accounts-actions.test.ts`:
- Around line 182-190: The community-edit test mocks (notably the
createSubplebbitEdit method which currently only throws on incoming
communityAddress/communityEdit and then calls
BasePlebbit.prototype.createCommunityEdit) must be updated to also return the
legacy shape that includes subplebbitAddress so the backfill path
backfillPublicationCommunityAddress used by publishCommunityEdit is exercised;
modify the mock(s) used around createSubplebbitEdit (and the analogous mocks
referenced at the 234-241 region) to sometimes return a legacy object with
subplebbitAddress (in addition to asserting rejection of inbound community*
fields), ensuring publishCommunityEdit triggers the
backfillPublicationCommunityAddress branch in tests.

---

Duplicate comments:
In `@src/lib/plebbit-compat.ts`:
- Around line 75-90: backfillPublicationCommunityAddress currently only uses
options (communityAddress or subplebbitAddress) to backfill
publication.communityAddress and misses cases where the returned publication
already carries a legacy address in publication.subplebbitAddress; update the
function so that if publication.communityAddress is unset you first derive
communityAddress from options as now, but if that is falsy, fall back to
publication.subplebbitAddress and assign that to publication.communityAddress;
reference the function name backfillPublicationCommunityAddress and the symbol
publication.subplebbitAddress when making the change.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: f09e2b65-4fa1-408a-8cde-4056b608e60a

📥 Commits

Reviewing files that changed from the base of the PR and between f1fe98d and 3feea56.

📒 Files selected for processing (2)
  • src/lib/plebbit-compat.ts
  • src/stores/accounts/accounts-actions.test.ts

Comment on lines +182 to +190
async createSubplebbitEdit(opts: any) {
if ("communityAddress" in opts) {
throw new Error("legacy createSubplebbitEdit received communityAddress");
}
if ("communityEdit" in opts) {
throw new Error("legacy createSubplebbitEdit received communityEdit");
}
return BasePlebbit.prototype.createCommunityEdit.call(this, opts);
}
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

The community-edit mocks still don’t exercise the legacy return-shape backfill.

Unlike createComment() on Lines 205-207, these community-edit mocks only reject inbound community* fields; they never return a legacy object with subplebbitAddress. That means the suites below prove outbound normalization, but they still don’t cover the new backfillPublicationCommunityAddress() path for publishCommunityEdit(). A regression there would keep passing.

As per coding guidelines, src/stores/**/*.{ts,tsx} must "Maintain mandatory 100% test coverage for hooks and stores; every feature or bug fix must include/adjust tests to keep coverage at 100%, verified via node scripts/verify-hooks-stores-coverage.mjs."

Also applies to: 234-241

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/stores/accounts/accounts-actions.test.ts` around lines 182 - 190, The
community-edit test mocks (notably the createSubplebbitEdit method which
currently only throws on incoming communityAddress/communityEdit and then calls
BasePlebbit.prototype.createCommunityEdit) must be updated to also return the
legacy shape that includes subplebbitAddress so the backfill path
backfillPublicationCommunityAddress used by publishCommunityEdit is exercised;
modify the mock(s) used around createSubplebbitEdit (and the analogous mocks
referenced at the 234-241 region) to sometimes return a legacy object with
subplebbitAddress (in addition to asserting rejection of inbound community*
fields), ensuring publishCommunityEdit triggers the
backfillPublicationCommunityAddress branch in tests.

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

const commentWithCid = comment;
const commentWithCid = addShortAddressesToAccountComment(
normalizeCommentCommunityAddress(comment) as any,
);
Copy link

Choose a reason for hiding this comment

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

Stored comments inconsistently retain subplebbitAddress after verification

Medium Severity

The challenge-verification and update-handler paths use normalizeCommentCommunityAddress to normalize stored comments, but that function only adds communityAddress without removing subplebbitAddress. In contrast, the initial store path at line 653 uses normalizePublicationOptionsForStore, which properly deletes subplebbitAddress. When a plebbit-js implementation sets subplebbitAddress on returned Comment objects (as LegacyPublicationSchemaPlebbit does), stored comments gain both fields after challenge verification or update events, contradicting the store's communityAddress-only convention.

Additional Locations (1)
Fix in Cursor Fix in Web

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