Add hidden trash board#1183
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
📝 WalkthroughWalkthroughThis PR introduces a special-boards module defining a hidden "trash" board with metadata (address, code, title, nsfw flag, aliases). It integrates this special board into route resolution, directory list filtering/normalization, theme/favicon NSFW detection, board title display, and post-transfer modal target options, with accompanying tests. ChangesSpecial Board Introduction and Integration
Estimated code review effort: 3 (Moderate) | ~25 minutes Sequence Diagram(s)sequenceDiagram
participant User
participant BoardView as Board/BoardHeader
participant RouteUtils as route-utils
participant SpecialBoards as special-boards module
User->>BoardView: Navigate to /trash
BoardView->>RouteUtils: getCommunityAddress(boardIdentifier)
RouteUtils->>SpecialBoards: getSpecialBoardByCode(code)
SpecialBoards-->>RouteUtils: TRASH_BOARD_ADDRESS
RouteUtils-->>BoardView: resolved address
BoardView->>SpecialBoards: getSpecialBoardByAddress(address)
SpecialBoards-->>BoardView: specialBoard (title, nsfw)
BoardView-->>User: Render TRASH_BOARD_TITLE, apply NSFW theme
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 |
|
Caution Failed to replace (edit) comment. This is likely due to insufficient permissions or the comment being deleted. Error details |
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/hooks/use-theme.ts (1)
68-115: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick winAdd a focused test for the special-board theme branch in
src/hooks/use-theme.tsThe newcurrentThemeandsetCommunityThemepaths for special boards still need direct coverage.🤖 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/use-theme.ts` around lines 68 - 115, Add a focused test covering the special-board branch in useTheme so both currentTheme resolution and setCommunityTheme are exercised when getSpecialBoardByAddress returns an nsfw board. Verify the hook picks themes.nsfw for special boards and that setCommunityTheme calls setThemeStore with the nsfw bucket in that path, using the existing useTheme, getSpecialBoardByAddress, and setThemeStore symbols to target the new logic directly.Source: Coding guidelines
🧹 Nitpick comments (2)
src/lib/utils/directory-list-lookup-utils.ts (1)
25-25: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winMissing test coverage for the top-level
directoryCodefilter branch.The new
isSpecialBoardCode(directoryCode)check on this line filters out an entire vendored directory when the directory's own code is a special code. This branch isn't covered bydirectory-list-lookup-utils.test.ts, which only mocks a nested trash board under directory code'b'(exercising the address-based guards at lines 43/55, not this line).As per coding guidelines, "Add or update tests for bug fixes and non-trivial logic changes when the code is reasonably testable."
✅ Suggested additional test case
it('excludes an entire vendored directory whose own code is a special board code', async () => { const { getVendoredDirectoryLists } = await importLookupUtilsWithDirectoryLists([ { directoryCode: 'trash', boards: [{ address: TRASH_BOARD_ADDRESS, publicKey: TRASH_BOARD_PUBLIC_KEY }] }, { directoryCode: 'b', boards: [{ address: 'business.eth', publicKey: 'biz-key' }] }, ]); expect(getVendoredDirectoryLists().map((d) => d.directoryCode)).toEqual(['b']); });🤖 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/lib/utils/directory-list-lookup-utils.ts` at line 25, Add test coverage for the top-level directoryCode filter in getVendoredDirectoryLists: the new isSpecialBoardCode(directoryCode) branch should be exercised by a case where an entire vendored directory is excluded because its own directoryCode is special, not just by nested board address checks. Update directory-list-lookup-utils.test.ts (or the existing lookup test helper) to import getVendoredDirectoryLists via the current test setup and assert that a directory with a special code is filtered out while a normal directory remains.Source: Coding guidelines
src/hooks/use-theme.ts (1)
68-80: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winExtract the duplicated NSFW-resolution logic into a shared helper.
The
community?.nsfw || specialBoard?.nsfwcheck is duplicated verbatim betweencurrentTheme's memo (Lines 71-76) andsetCommunityTheme(Lines 106-111). It also uses different combining semantics thanisSfwBoardinsrc/lib/update-favicon.ts, which instead treatsspecialBoardas fully overriding the directory entry (if (specialBoard) return !specialBoard.nsfw;) rather than OR-ing the two flags. Today these are behaviorally equivalent because special boards are filtered out ofdirectories, but the duplicated/divergent logic is fragile to future changes in that invariant.Consider extracting a single
resolveIsNsfwForAddress(address, directories)helper (e.g. alongsidegetSpecialBoardByAddressinsrc/lib/special-boards.ts) and reusing it in both files.♻️ Suggested consolidation
+// src/lib/special-boards.ts +export const resolveIsNsfwForAddress = ( + address: string | undefined, + directories: { address: string; nsfw?: boolean }[], +): boolean => { + const specialBoard = getSpecialBoardByAddress(address); + if (specialBoard) return !!specialBoard.nsfw; + const entry = directories.find((d) => d.address === address); + return !!entry?.nsfw; +};} else if (communityAddress) { - const community = directories.find((entry) => entry.address === communityAddress); - const specialBoard = getSpecialBoardByAddress(communityAddress); - if (community?.nsfw || specialBoard?.nsfw) { + if (resolveIsNsfwForAddress(communityAddress, directories)) { storedTheme = themes.nsfw; } else { storedTheme = themes.sfw; } }Also applies to: 100-115
🤖 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/use-theme.ts` around lines 68 - 80, Extract the duplicated NSFW-resolution logic into a shared helper so both theme selection paths use the same rules. Add a helper such as resolveIsNsfwForAddress(address, directories) near getSpecialBoardByAddress in special-boards logic, and have currentTheme and setCommunityTheme call it instead of repeating community?.nsfw || specialBoard?.nsfw. Also update isSfwBoard in update-favicon to use the same helper/semantics so special-board override behavior stays consistent.Source: Coding guidelines
🤖 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/components/post-transfer-modal/post-transfer-modal.tsx`:
- Around line 186-201: The board exclusion logic in boardOptions only checks
canonical addresses, so special-board aliases can still slip through as
selectable transfer targets. Update the filter in post-transfer-modal.tsx to
resolve the source board using the same alias-aware logic as sourceBoard,
including getSpecialBoardByAddress and any SPECIAL_BOARDS aliases, and then
exclude any matching board entry from boardOptions. Keep the change localized
around boardOptions, sourceCommunityAddress, and sourceBoard so the transfer
target list cannot include the current board under an alias.
---
Outside diff comments:
In `@src/hooks/use-theme.ts`:
- Around line 68-115: Add a focused test covering the special-board branch in
useTheme so both currentTheme resolution and setCommunityTheme are exercised
when getSpecialBoardByAddress returns an nsfw board. Verify the hook picks
themes.nsfw for special boards and that setCommunityTheme calls setThemeStore
with the nsfw bucket in that path, using the existing useTheme,
getSpecialBoardByAddress, and setThemeStore symbols to target the new logic
directly.
---
Nitpick comments:
In `@src/hooks/use-theme.ts`:
- Around line 68-80: Extract the duplicated NSFW-resolution logic into a shared
helper so both theme selection paths use the same rules. Add a helper such as
resolveIsNsfwForAddress(address, directories) near getSpecialBoardByAddress in
special-boards logic, and have currentTheme and setCommunityTheme call it
instead of repeating community?.nsfw || specialBoard?.nsfw. Also update
isSfwBoard in update-favicon to use the same helper/semantics so special-board
override behavior stays consistent.
In `@src/lib/utils/directory-list-lookup-utils.ts`:
- Line 25: Add test coverage for the top-level directoryCode filter in
getVendoredDirectoryLists: the new isSpecialBoardCode(directoryCode) branch
should be exercised by a case where an entire vendored directory is excluded
because its own directoryCode is special, not just by nested board address
checks. Update directory-list-lookup-utils.test.ts (or the existing lookup test
helper) to import getVendoredDirectoryLists via the current test setup and
assert that a directory with a special code is filtered out while a normal
directory remains.
🪄 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: 11f7489b-5112-4be2-b3d9-d8ca46765923
📒 Files selected for processing (17)
src/components/board-header/__tests__/board-header.test.tsxsrc/components/board-header/board-header.tsxsrc/components/post-transfer-modal/__tests__/post-transfer-modal.test.tsxsrc/components/post-transfer-modal/post-transfer-modal.tsxsrc/hooks/__tests__/use-directories.test.tsxsrc/hooks/use-directories.tssrc/hooks/use-theme.tssrc/lib/__tests__/update-favicon.test.tssrc/lib/special-boards.tssrc/lib/update-favicon.tssrc/lib/utils/__tests__/directory-list-lookup-utils.test.tssrc/lib/utils/__tests__/route-utils.test.tssrc/lib/utils/directory-list-lookup-utils.tssrc/lib/utils/route-utils.tssrc/views/board/__tests__/board.test.tsxsrc/views/board/board.tsxsrc/views/mod-queue/__tests__/mod-queue.test.tsx
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort 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 1a8db87. Configure here.

Summary
/trash/special board that routes tooff-topic.bsowithout appearing in directory navigation/trash/ - Off-topicin moderator transfer targets and board metadata, theme, and favicon handling/trash/safelyThe matching
bitsocialnet/listsseed-list file is already merged tomasterso existing bitsocial-seeder instances can discoveroff-topic.bsothrough the current GitHub contents source.Verification
corepack yarn lintcorepack yarn type-checkcorepack yarn testcorepack yarn buildcorepack yarn doctor(known baseline failure:ace-buildsSocket score and existing post-form effect diagnostics).189readback verifiedoff-topic.bsoresolves to the new public key and matchesrandom-nsfw.bsopublished features/challengesNote
Medium Risk
Touches routing, directory hydration, and moderator transfer flows across many call sites; mistakes could hide boards incorrectly or break transfers, but behavior is heavily covered by new tests.
Overview
Introduces a hidden
/trash/board (off-topic.bso) via a newspecial-boardsregistry: routable by code and aliases, but not shown in public directory lists.Routing & discovery:
getBoardPath/getCommunityAddressresolve trash without treating it as a normal directory route. Remote and vendored directory hydration filters special boards out of listings and lookup helpers so seed lists can still mention the board safely.UI & moderation: Headers, board page titles, NSFW theme bucket, and favicon logic use special-board metadata when there is no directory entry. The post transfer modal adds trash as a target, resolves it as a source (including alias matching), and omits re-transfer to trash when the source is identified by public key.
Transfer copy: Source moderation reasons use
/trash/and plain “the rules” instead of a rules-page link for special boards.Reviewed by Cursor Bugbot for commit dc806dc. Bugbot is set up for automated code reviews on this repo. Configure here.
Summary by CodeRabbit
New Features
Bug Fixes