Skip to content

fix(accounts): enrich local account comment authors#64

Merged
tomcasaburi merged 2 commits into
masterfrom
fix/enriched-account-comments
Jun 24, 2026
Merged

fix(accounts): enrich local account comment authors#64
tomcasaburi merged 2 commits into
masterfrom
fix/enriched-account-comments

Conversation

@tomcasaburi

@tomcasaburi tomcasaburi commented Jun 24, 2026

Copy link
Copy Markdown
Member

Summary

  • Restore missing author identity on local account comments returned by useAccountComment and useAccountComments when the comment belongs to the selected account.
  • Preserve existing account-comment author fields and avoid overwriting comments that already have an author address.
  • Reject negative and fractional useAccountComment indexes, matching the existing list-index behavior.
  • Bump the package to 0.1.20 so the publish-on-merge workflow can publish this fix for downstream apps.

Verification

  • yarn prettier
  • yarn build
  • yarn type-check
  • yarn test
  • yarn test:coverage
  • targeted vitest regression run for account-comment author restoration and invalid indexes
  • yarn llms:generate

Notes

  • node scripts/verify-hooks-stores-coverage.mjs currently fails against broad pre-existing hook/store coverage gaps outside this change; the full coverage test run passes.

Note

Low Risk
Scoped account-hook presentation fix with no store mutation; behavior is gated on account ownership and missing author address.

Overview
Local account comments from useAccountComment and useAccountComments now get author address and shortAddress from the active account when a cached entry belongs to that account but is missing author.address. Existing per-comment author fields (e.g. display name) are kept; comments that already have an author address are unchanged. Enrichment is read-time only—nothing is written back to the accounts store.

useAccountComment ignores invalid commentIndex values (negative or non-integer), consistent with list indexing elsewhere.

Package version is 0.1.20; README/LLM docs note the author backfill behavior. Tests cover restoration and invalid indexes.

Reviewed by Cursor Bugbot for commit 0c3f756. Bugbot is set up for automated code reviews on this repo. Configure here.

Summary by CodeRabbit

  • New Features

    • Account comments now display fuller author details when local identity data is available, including address and short address.
    • Returned comment lists are more consistently enriched with account-related profile information.
  • Bug Fixes

    • Improved handling of invalid comment indexes so negative and non-integer values are ignored safely.
    • Updated changelog references and release documentation to reflect the latest version.

@coderabbitai

coderabbitai Bot commented Jun 24, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Adds a getAccountCommentWithAccountAuthor helper to accounts.ts that enriches locally-stored account comments with the account owner's address and shortAddress (computed via PkcJs) when those fields are absent from cached entries. Wires the helper into both useAccountComments and useAccountComment, tightens commentIndex validation to non-negative integers, and adds corresponding tests. Bumps the package version to 0.1.20 and updates README.md / LLM doc files.

Changes

Author identity enrichment in account comment hooks

Layer / File(s) Summary
Author enrichment helper and hook wiring
src/hooks/accounts/accounts.ts
Adds PkcJs import and getAccountCommentWithAccountAuthor helper; reads account from the accounts store in useAccountComments and maps the helper over each returned comment; tightens resolvedCommentIndex to reject negative and fractional values; refactors useAccountComment's memo to apply the same helper.
Tests for author enrichment and commentIndex edge cases
src/hooks/accounts/accounts.test.ts
Adds a test verifying author address/shortAddress restoration for the owning account while preserving existing identity on other entries. Adds an edge-case test confirming negative and fractional commentIndex inputs leave the hook uninitialized.
Docs note, changelog, and version bump
README.md, llms-full.txt, llms.txt, package.json
Inserts a clarifying note about author identity restoration in the "Get your own comments and votes" section; adds the 0.1.19 CHANGELOG block; updates the LLM index changelog reference; bumps version to 0.1.20.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • bitsocialnet/bitsocial-react-hooks#42: Modifies useAccountComment's commentIndex resolution in the same file — the main PR's non-negative integer validation and enriched author memo directly extend the lookup logic introduced there.

Poem

🐇 Hop, hop — the address was lost in the cache,
A shortAddress missing, gone in a flash!
getAccountCommentWithAccountAuthor to the rescue today,
PkcJs whispers the address back our way.
Negative indices? Fractions? No, no, no!
Only whole, non-negative numbers may go.
The rabbit bumped the version and bounded away~ 🌟

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly matches the main change: enriching local account comment authors in accounts hooks.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
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 docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/enriched-account-comments

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
src/hooks/accounts/accounts.ts (1)

441-448: 🎯 Functional Correctness | 🔵 Trivial | 💤 Low value

Optional: address/shortAddress could diverge if a stored author has a stale shortAddress but no address.

Because ...accountComment.author is spread after the computed shortAddress but address is then force-set from the account, a cached author carrying a shortAddress (without address) would keep its stale shortAddress while address is overwritten with the account's. In the current enrichment scenario (missing identity) this is unlikely, but moving the forced shortAddress after the comment spread—alongside address—keeps the pair consistent.

♻️ Keep address/shortAddress consistent
     author: {
       ...accountAuthor,
-      ...(accountShortAddress ? { shortAddress: accountShortAddress } : {}),
       ...accountComment.author,
       address: accountAuthor.address,
+      ...(accountShortAddress ? { shortAddress: accountShortAddress } : {}),
     },
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/hooks/accounts/accounts.ts` around lines 441 - 448, The author merge in
accounts.ts can leave address and shortAddress inconsistent when
accountComment.author already contains a stale shortAddress. Update the author
composition in the enrichment logic so the account-derived address and
shortAddress are applied together after spreading accountComment.author, using
the same source object or fallback logic in the relevant merge block inside the
accounts hook. Keep the final author object construction in sync by ensuring the
forced address assignment and the shortAddress override are adjacent and derived
from the current accountAuthor values.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@src/hooks/accounts/accounts.ts`:
- Around line 441-448: The author merge in accounts.ts can leave address and
shortAddress inconsistent when accountComment.author already contains a stale
shortAddress. Update the author composition in the enrichment logic so the
account-derived address and shortAddress are applied together after spreading
accountComment.author, using the same source object or fallback logic in the
relevant merge block inside the accounts hook. Keep the final author object
construction in sync by ensuring the forced address assignment and the
shortAddress override are adjacent and derived from the current accountAuthor
values.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: a3c5b9c3-bc9d-4dfa-9b3b-b5543eb2a5a1

📥 Commits

Reviewing files that changed from the base of the PR and between 0b78a21 and 66d9d54.

📒 Files selected for processing (6)
  • README.md
  • llms-full.txt
  • llms.txt
  • package.json
  • src/hooks/accounts/accounts.test.ts
  • src/hooks/accounts/accounts.ts

@tomcasaburi tomcasaburi merged commit cac2376 into master Jun 24, 2026
8 checks passed
@tomcasaburi tomcasaburi deleted the fix/enriched-account-comments branch June 24, 2026 08:10
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