chore: drop old plebbit list, rename to use-default-subscriptions#813
chore: drop old plebbit list, rename to use-default-subscriptions#813tomcasaburi merged 2 commits intomasterfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
📝 WalkthroughWalkthroughThe PR systematically refactors the default subscriptions hook infrastructure, renaming "multisub"/"subplebbit" terminology to "default subscriptions" across the codebase. The core hook switches its network source from Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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
🧹 Nitpick comments (5)
src/hooks/use-auto-subscribe.ts (1)
3-62: LGTM — hook rename only; the leftoverdefaultSubplebbitslocal could be renamed for clarity.The variable now holds
DefaultSubscription[]and is only used for a.lengthgate and as a dep, so behavior is unchanged. Consider renaming todefaultSubscriptionsin a follow-up to match the rest of the migration.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/hooks/use-auto-subscribe.ts` around lines 3 - 62, Rename the local variable defaultSubplebbits to defaultSubscriptions to match the hook useDefaultSubscriptions and improve clarity: update the const declaration that assigns useDefaultSubscriptions(), replace its usage in the length check (defaultSubplebbits?.length) and in the effect dependency array, and ensure the new name is used wherever defaultSubplebbits appears (including the dependency list of useEffect) so behavior remains identical.src/hooks/use-default-subscriptions.ts (2)
120-122: StaleSubplebbitcast — should beDefaultSubscription.
defaultSubscriptionsisDefaultSubscription[](the renamed local type), notSubplebbit. TheSubplebbitimport on line 2 only exists for this cast and can be dropped after the fix.♻️ Proposed fix
-import { Subplebbit } from '@bitsocialnet/bitsocial-react-hooks'; import useContentOptionsStore from '../stores/use-content-options-store';const filteredSubscriptions = useMemo(() => { - return defaultSubscriptions.filter((subscription: Subplebbit) => { + return defaultSubscriptions.filter((subscription) => { const tags = subscription.tags || [];🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/hooks/use-default-subscriptions.ts` around lines 120 - 122, The filter callback is casting items to the wrong type: replace the Subplebbit cast with DefaultSubscription so the code uses the local DefaultSubscription type; update the filter in the useMemo block that defines filteredSubscriptions to treat each item as DefaultSubscription (and remove the now-unused Subplebbit import at top of the file).
167-179: Stalemultisubnaming — rename for consistency with the new terminology.The rest of the module dropped the "multisub" terminology; this helper still carries it in both the parameter name and inner variable. The hook signature also accepts
any, which masks the actualDefaultSubscription[]shape.♻️ Proposed rename + tighter typing
-const getUniqueTags = (multisub: any) => { +const getUniqueTags = (subscriptions: DefaultSubscription[] | Record<string, DefaultSubscription>) => { const allTags = new Set<string>(); - Object.values(multisub).forEach((sub: any) => { + Object.values(subscriptions).forEach((sub) => { if (sub?.tags?.length) { sub.tags.forEach((tag: string) => allTags.add(tag)); } }); return Array.from(allTags).sort(); }; -export const useDefaultSubscriptionTags = (subscriptions: any) => { +export const useDefaultSubscriptionTags = (subscriptions: DefaultSubscription[]) => { return useMemo(() => getUniqueTags(subscriptions), [subscriptions]); };🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/hooks/use-default-subscriptions.ts` around lines 167 - 179, Rename the stale "multisub" identifiers and tighten types: change the getUniqueTags parameter name from multisub to something like subscriptionsMap (or subscriptions) and update internal variable names accordingly; update getUniqueTags signature to accept the concrete shape (e.g., Record<string, DefaultSubscription> or the appropriate map type) and change useDefaultSubscriptionTags to accept subscriptions: DefaultSubscription[] (or the actual DefaultSubscription[] type) instead of any so useMemo calls getUniqueTags with properly typed input; update references to sub and tags handling within getUniqueTags to match the DefaultSubscription structure (use getUniqueTags and useDefaultSubscriptionTags to locate the functions).src/views/subplebbits/subplebbits.tsx (1)
316-316: Optional: renamedefaultSubplebbitslocals to match the new hook.These locals are now populated by
useDefaultSubscriptions()but still carry the olddefaultSubplebbitsname. Thefind((defaultSub) => defaultSub.address === ...)usage stays valid sinceDefaultSubscriptionstill hasaddress/tags, so this is purely a naming consistency cleanup with the rest of the rename in this PR. Feel free to defer if it's intentionally being kept for the broader subplebbit→community follow-up.Also applies to: 358-358, 462-462
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/views/subplebbits/subplebbits.tsx` at line 316, Rename the local variables named defaultSubplebbits to reflect the new hook name (e.g., defaultSubscriptions) where you call useDefaultSubscriptions() and in the other occurrences (the locals used at lines around the other uses), keeping the existing find((defaultSub) => defaultSub.address === ...) logic intact; update any references to DefaultSubscription-typed items and their usages so they refer to the new local name (defaultSubscriptions) to keep naming consistent with useDefaultSubscriptions().src/components/topbar/topbar.tsx (1)
59-59: Optional: rename local variable for consistency.The local is still called
defaultSubplebbitseven though it now holdsDefaultSubscription[]fromuseDefaultSubscriptions(). SincehandleNSFWSubscriptionPromptconsumes it via adefaultSubplebbitsprop, you can leave the call site as-is, but a local alias likedefaultSubscriptionswould better match the new terminology.♻️ Proposed rename
- const defaultSubplebbits = useDefaultSubscriptions(); + const defaultSubscriptions = useDefaultSubscriptions(); @@ - await handleNSFWSubscriptionPrompt({ - account, - defaultSubplebbits, - tagsToShow: ['adult', 'gore', 'anti', 'vulgar'], - isShowingAll: true, - }); + await handleNSFWSubscriptionPrompt({ + account, + defaultSubplebbits: defaultSubscriptions, + tagsToShow: ['adult', 'gore', 'anti', 'vulgar'], + isShowingAll: true, + }); @@ - await handleNSFWSubscriptionPrompt({ - account, - defaultSubplebbits, - tagsToShow: [tagName], - }); + await handleNSFWSubscriptionPrompt({ + account, + defaultSubplebbits: defaultSubscriptions, + tagsToShow: [tagName], + });🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/components/topbar/topbar.tsx` at line 59, Rename the local variable returned from useDefaultSubscriptions() from defaultSubplebbits to defaultSubscriptions and update all local references accordingly; when calling handleNSFWSubscriptionPrompt (and any JSX props expecting defaultSubplebbits), pass defaultSubscriptions as the value for the defaultSubplebbits prop so you keep the handler prop name unchanged while making the local variable name consistent.
🤖 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/hooks/use-default-subscriptions.ts`:
- Around line 54-58: The fetch parsing currently assumes data.subplebbits exists
and lets a TypeError be swallowed, causing cacheSubscriptions to stay null and
repeated refetches; update the parsing in use-default-subscriptions.ts to
defensively read either data.subplebbits or data.subscriptions (e.g., const list
= Array.isArray(data.subscriptions) ? data.subscriptions :
Array.isArray(data.subplebbits) ? data.subplebbits : []), validate list is an
array of DefaultSubscription before filtering (use Array.isArray and type
guards), assign cacheSubscriptions = filteredList, and on parse errors or
unexpected shape set cacheSubscriptions to a safe default (empty array) and log
the error instead of silently swallowing it so pending/state handling stops
triggering tight retry loops (adjust error handling around
filteredSubscriptions/cacheSubscriptions and the pending flag accordingly).
---
Nitpick comments:
In `@src/components/topbar/topbar.tsx`:
- Line 59: Rename the local variable returned from useDefaultSubscriptions()
from defaultSubplebbits to defaultSubscriptions and update all local references
accordingly; when calling handleNSFWSubscriptionPrompt (and any JSX props
expecting defaultSubplebbits), pass defaultSubscriptions as the value for the
defaultSubplebbits prop so you keep the handler prop name unchanged while making
the local variable name consistent.
In `@src/hooks/use-auto-subscribe.ts`:
- Around line 3-62: Rename the local variable defaultSubplebbits to
defaultSubscriptions to match the hook useDefaultSubscriptions and improve
clarity: update the const declaration that assigns useDefaultSubscriptions(),
replace its usage in the length check (defaultSubplebbits?.length) and in the
effect dependency array, and ensure the new name is used wherever
defaultSubplebbits appears (including the dependency list of useEffect) so
behavior remains identical.
In `@src/hooks/use-default-subscriptions.ts`:
- Around line 120-122: The filter callback is casting items to the wrong type:
replace the Subplebbit cast with DefaultSubscription so the code uses the local
DefaultSubscription type; update the filter in the useMemo block that defines
filteredSubscriptions to treat each item as DefaultSubscription (and remove the
now-unused Subplebbit import at top of the file).
- Around line 167-179: Rename the stale "multisub" identifiers and tighten
types: change the getUniqueTags parameter name from multisub to something like
subscriptionsMap (or subscriptions) and update internal variable names
accordingly; update getUniqueTags signature to accept the concrete shape (e.g.,
Record<string, DefaultSubscription> or the appropriate map type) and change
useDefaultSubscriptionTags to accept subscriptions: DefaultSubscription[] (or
the actual DefaultSubscription[] type) instead of any so useMemo calls
getUniqueTags with properly typed input; update references to sub and tags
handling within getUniqueTags to match the DefaultSubscription structure (use
getUniqueTags and useDefaultSubscriptionTags to locate the functions).
In `@src/views/subplebbits/subplebbits.tsx`:
- Line 316: Rename the local variables named defaultSubplebbits to reflect the
new hook name (e.g., defaultSubscriptions) where you call
useDefaultSubscriptions() and in the other occurrences (the locals used at lines
around the other uses), keeping the existing find((defaultSub) =>
defaultSub.address === ...) logic intact; update any references to
DefaultSubscription-typed items and their usages so they refer to the new local
name (defaultSubscriptions) to keep naming consistent with
useDefaultSubscriptions().
🪄 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
Run ID: d93aef7c-05ca-406d-9605-e3356c46f50c
📒 Files selected for processing (12)
src/components/author-sidebar/author-sidebar.tsxsrc/components/search-bar/search-bar.tsxsrc/components/topbar/topbar.tsxsrc/hooks/use-auto-subscribe.tssrc/hooks/use-default-subscriptions.tssrc/hooks/use-is-broadly-nsfw-subplebbit.tssrc/hooks/use-is-nsfw-subplebbit.tssrc/views/all/all.tsxsrc/views/domain/domain.tsxsrc/views/settings/content-options/content-options.tsxsrc/views/submit-page/submit-page.tsxsrc/views/subplebbits/subplebbits.tsx
| const data = await res.json(); | ||
|
|
||
| const filteredSubplebbits = multisub.subplebbits.filter((sub: MultisubSubplebbit) => !sub.lowUptime); | ||
| const filteredSubscriptions = data.subplebbits.filter((sub: DefaultSubscription) => !sub.lowUptime); | ||
|
|
||
| cacheSubplebbits = filteredSubplebbits; | ||
| cacheSubscriptions = filteredSubscriptions; |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
# First, examine the full use-default-subscriptions.ts file to understand context
fd -t f "use-default-subscriptions.ts" --exec cat -n {} \;Repository: bitsocialnet/seedit
Length of output: 6755
🏁 Script executed:
# Search for seedit-default-subscriptions.json or related files
fd -t f "default-subscriptions"Repository: bitsocialnet/seedit
Length of output: 102
🏁 Script executed:
# Search for any schema definitions or type definitions related to subscriptions
rg "DefaultSubscription" -t ts -t tsx -B 2 -A 5Repository: bitsocialnet/seedit
Length of output: 91
🏁 Script executed:
# Check for any references to the JSON structure or field names
rg "subplebbits|subscriptions" -t ts -t tsx -C 3 | head -100Repository: bitsocialnet/seedit
Length of output: 91
🏁 Script executed:
# Search for any JSON examples or schema related to default subscriptions
rg "subscriptions|subplebbits" -i --max-count 50Repository: bitsocialnet/seedit
Length of output: 50375
🏁 Script executed:
# Check if there are any docs, examples, or schema files
fd -t f -e json -e md -e ts | grep -i "default\|subscri\|schema" | head -20Repository: bitsocialnet/seedit
Length of output: 784
🏁 Script executed:
# Look for any GitHub Actions workflow or build files that might reference the JSON
fd -t f -e yml -e yaml | xargs cat -n 2>/dev/null | head -50Repository: bitsocialnet/seedit
Length of output: 45
🏁 Script executed:
# Search for any comments or references to the bitsocialnet/lists repo
rg "bitsocialnet/lists" -i -B 5 -A 5Repository: bitsocialnet/seedit
Length of output: 878
Defensive parse required: verify JSON schema field name before merging.
Two confirmed issues in the parsing logic (lines 54-58):
-
Field name mismatch: Code reads
data.subplebbitsbut returns shape usessubscriptionskey. If the incoming JSON standardizes onsubscriptions(matching the new naming convention),data.subplebbitswill beundefinedand.filter()throws. -
Inadequate error handling: A
TypeErrorfrom line 56 is caught silently,cacheSubscriptionsremainsnull, andpendingresets tofalse. Every subsequent hook mount retriggers the fetch—creating a tight retry loop until the JSON parses correctly.
🛡️ Proposed defensive parse
const data = await res.json();
- const filteredSubscriptions = data.subplebbits.filter((sub: DefaultSubscription) => !sub.lowUptime);
+ const list: DefaultSubscription[] = Array.isArray(data?.subscriptions)
+ ? data.subscriptions
+ : Array.isArray(data?.subplebbits)
+ ? data.subplebbits
+ : [];
+ const filteredSubscriptions = list.filter((sub) => !sub.lowUptime);Confirm the intended JSON shape of seedit-default-subscriptions.json (field subscriptions vs subplebbits) in the bitsocialnet/lists repository or PR before merging.
📝 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.
| const data = await res.json(); | |
| const filteredSubplebbits = multisub.subplebbits.filter((sub: MultisubSubplebbit) => !sub.lowUptime); | |
| const filteredSubscriptions = data.subplebbits.filter((sub: DefaultSubscription) => !sub.lowUptime); | |
| cacheSubplebbits = filteredSubplebbits; | |
| cacheSubscriptions = filteredSubscriptions; | |
| const data = await res.json(); | |
| const list: DefaultSubscription[] = Array.isArray(data?.subscriptions) | |
| ? data.subscriptions | |
| : Array.isArray(data?.subplebbits) | |
| ? data.subplebbits | |
| : []; | |
| const filteredSubscriptions = list.filter((sub) => !sub.lowUptime); | |
| cacheSubscriptions = filteredSubscriptions; |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@src/hooks/use-default-subscriptions.ts` around lines 54 - 58, The fetch
parsing currently assumes data.subplebbits exists and lets a TypeError be
swallowed, causing cacheSubscriptions to stay null and repeated refetches;
update the parsing in use-default-subscriptions.ts to defensively read either
data.subplebbits or data.subscriptions (e.g., const list =
Array.isArray(data.subscriptions) ? data.subscriptions :
Array.isArray(data.subplebbits) ? data.subplebbits : []), validate list is an
array of DefaultSubscription before filtering (use Array.isArray and type
guards), assign cacheSubscriptions = filteredList, and on parse errors or
unexpected shape set cacheSubscriptions to a safe default (empty array) and log
the error instead of silently swallowing it so pending/state handling stops
triggering tight retry loops (adjust error handling around
filteredSubscriptions/cacheSubscriptions and the pending flag accordingly).
Rename the hook file and exports from use-default-subplebbits to use-default-subscriptions. Switch the fetch URL from plebbit/lists default-multisub.json to bitsocialnet/lists seedit-default-subscriptions.json. A 404 from the new (not-yet-populated) list gracefully resolves to empty defaults so new users see an empty subscription feed (like a fresh Reddit account). The list will be populated later.
When use-default-subscriptions resolves to [] (the expected case while seedit-default-subscriptions.json is empty or 404s), the auto-subscribe effect was early-returning before removing the account from the checking set. That kept isCheckingSubscriptions true forever and prevented the "no subscriptions" empty state from ever rendering on home. Fix by ensuring removeCheckingAccount is always called once the auto-subscribe pass completes, even when there is nothing to auto-subscribe to.
afc9c85 to
0da6e32
Compare
There was a problem hiding this comment.
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.
Reviewed by Cursor Bugbot for commit 0da6e32. Configure here.
| if (!account || !defaultCommunities?.length) { | ||
| removeCheckingAccount(accountAddress); | ||
| return; | ||
| } |
There was a problem hiding this comment.
Premature empty state during initial defaults fetch
Medium Severity
The new branch calls removeCheckingAccount whenever defaultCommunities is empty, but useDefaultSubscriptions returns [] both while the fetch is in flight and after a 404. As a result, isCheckingSubscriptions flips to false during the initial fetch, not only on a real 404. New users on slower networks will see the home page's "no subscriptions" empty state flash after the safeToShowNoSubscriptions debounce, then return to loading once the fetch resolves and auto-subscribe runs.
Reviewed by Cursor Bugbot for commit 0da6e32. Configure here.


Summary
src/hooks/use-default-subplebbits.ts→src/hooks/use-default-subscriptions.ts, with renamed exports (useDefaultSubscriptions,useDefaultSubscriptionAddresses,useDefaultSubscriptionTags,useDefaultSubscriptionsMetadata) and types (DefaultSubscription,DefaultSubscriptionsMetadata).plebbit/lists/master/default-multisub.jsontobitsocialnet/lists/master/seedit-default-subscriptions.json.src/.The new list file
seedit-default-subscriptions.jsondoes not exist yet onbitsocialnet/lists. Until you create it, the homepage's auto-subscribe will be empty by design — that is the goal for now.This is part of a multi-PR migration to bring seedit on par with 5chan. The broader
subplebbit→communityrename is intentionally deferred to a separate PR (PR D) so review stays manageable.Test plan
Note
Medium Risk
Medium risk because it changes the remote source and error-handling for default subscription data, which affects homepage/all/domain feeds, suggestions, and auto-subscribe behavior for new users.
Overview
Switches the app’s “default communities” source from the old
plebbit/listsmultisub to a newbitsocialnet/listsdefault-subscriptions JSON, and renames the hook API accordingly (e.g.,useDefaultSubscriptions,useDefaultSubscriptionAddresses, metadata/tags helpers).Updates all call sites to use the new hook names, and changes the fetch path to explicitly treat non-OK responses as “no defaults” (clearing caches and notifying subscribers), which in turn makes auto-subscribe and default-driven feeds/suggestions start empty when the list is missing.
Reviewed by Cursor Bugbot for commit 0da6e32. Bugbot is set up for automated code reviews on this repo. Configure here.
Summary by CodeRabbit
Release Notes
Refactor