feat(communities): expose sync lifecycle state - #73
Conversation
📝 WalkthroughWalkthrough
ChangesCommunity synchronization state
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant Community
participant addCommunityToStore
participant communitiesStore
participant useCommunity
Community->>addCommunityToStore: Emit update lifecycle events
addCommunityToStore->>communitiesStore: Normalize and record sync status
communitiesStore->>useCommunity: Provide sync status metadata
useCommunity->>useCommunity: Return syncState, cache, and timestamps
Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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.
Inline comments:
In `@src/stores/communities/communities-store.ts`:
- Around line 591-598: Update deleteCommunity’s setState cleanup to also remove
the deleted community’s entry from state.errors, alongside syncStatuses, and
return the cleaned errors map in the new state. Preserve the existing
communities and syncStatuses cleanup behavior.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 74ec032d-b23e-479e-8671-1041ce079cb2
📒 Files selected for processing (7)
README.mdllms-full.txtsrc/hooks/communities.test.tssrc/hooks/communities.tssrc/stores/communities/communities-store.test.tssrc/stores/communities/communities-store.tssrc/types.ts
|
Addressed the CodeRabbit finding in 02b0353: deleting a community now removes its stored errors together with its sync status, with a regression assertion. Reverified build, type-check, lint, the full 1,123-test suite, and full coverage (97.25% statements / 92.47% branches). |
Summary
statesemanticsVerification
yarn buildyarn type-checkyarn lint(0 errors; existing warnings only)yarn test(1,123 passed, 6 skipped)Closes #72
Note
Low Risk
Additive API and store fields with preserved
statesemantics; risk is mainly consumers misreadingstatevssyncStateif they skip the docs.Overview
useCommunitynow returnssyncState,hasCachedData,lastFetchAttemptAt, andlastSuccessfulFetchAtalongside the existing community fields. Cached-datastatestill stayssucceededwhenupdatedAtis present, even during background refresh;syncStatetracks the live fetch lifecycle (initializing→loading/retrying→succeeded/failed/stopped).The communities store maintains per-community
syncStatuses, updated from PKCupdatingstatechangeevents (withwaiting-retrymapped toretrying) and set tofailedwhenaddCommunityToStorethrows.deleteCommunityclears sync status and errors for that key. Types addCommunitySyncStateand extendUseCommunityResult.README /
llms-full.txtdocument the new fields and example usage; changelog entries for 0.1.29 / 0.1.30; tests cover the lifecycle,onlyIfCached, failures, and delete cleanup.Reviewed by Cursor Bugbot for commit 02b0353. Bugbot is set up for automated code reviews on this repo. Configure here.
Summary by CodeRabbit
New Features
Bug Fixes
Documentation
useCommunity.