Conversation
📝 WalkthroughWalkthroughAdds an "archived" space flag across schema, types, server queries, utilities, and UI; filters and UI now respect archived state; removes the "Archive Space (Coming Soon)" settings action. Introduces omitArchived query option and isSpaceArchived utility. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant UI as Web UI
participant Server as Core Server
participant DB as Postgres
User->>UI: Toggle archive / enable "hide archived"
UI->>Server: GET spaces?omitArchived=true or POST create/update (flags include 'archived')
Server->>DB: SELECT ... WHERE NOT flags @> ARRAY['archived'] OR INSERT/UPDATE flags
DB-->>Server: Return filtered rows / confirm write
Server-->>UI: Return spaces (with memberCount) or updated space
UI-->>User: Render cards with isArchived -> "Archived" caption / colorVariant
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 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
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (3)
apps/web/src/app/[lang]/my-spaces/page.tsx (1)
36-39:⚠️ Potential issue | 🟡 MinorArchived spaces will appear in the "Spaces you might like" carousel
allSpacesis fetched withoutomitArchived: true. Since the new archive flow setsflags: ['archived'](notisArchivedboolean), the existingeq(spaces.isArchived, false)filter infindAllSpacesdoes not cover flag-archived spaces. The network/explore page correctly passesomitArchived: true, but this carousel does not — resulting in archived spaces appearing in recommendations (with the Archived badge, but still surfaced as suggestions).Unless surfacing archived spaces in recommendations is intentional, add
omitArchived: true:🔧 Proposed fix
const [allSpaces, mySpaces] = await Promise.all([ - getAllSpaces({ parentOnly: false, omitSandbox: true }), + getAllSpaces({ parentOnly: false, omitSandbox: true, omitArchived: true }), getAllSpaces({ search: query, parentOnly: false }), ]);🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@apps/web/src/app/`[lang]/my-spaces/page.tsx around lines 36 - 39, The "Spaces you might like" carousel fetches allSpaces via getAllSpaces without omitting archived entries, so archived spaces (flagged via flags:['archived']) are showing up; update the call that sets allSpaces (the first getAllSpaces invocation) to include omitArchived: true so it filters out archived spaces (aligning with the network/explore page behavior and the filtering logic in findAllSpaces).packages/core/src/space/server/queries.ts (1)
52-61:⚠️ Potential issue | 🟠 MajorDual archiving fields create a subtle footgun
findAllSpacesalways applieseq(spaces.isArchived, false)(line 54), but the new Archive Mode increate-space-form.tsxonly setsflags: ['archived']— it does not touch theisArchivedboolean column. This means the hard-coded boolean filter does not cover flag-archived spaces;omitArchived: truemust be explicitly passed to exclude them.This
omitArchived = falsedefault silently allows flag-archived spaces through. Callers that omit the flag (e.g., theallSpacesquery inmy-spaces/page.tsx) will receive archived spaces without any TypeScript warning. Additionally,findAllSpacesByMemberIdandfindAllSpacesByWeb3SpaceIdsboth use onlyeq(spaces.isArchived, false)with no flags-based filtering — spaces archived via flags will appear in those results, compensated only by client-side filtering inMyFilteredSpaces.Consider either:
- Keeping the two fields in sync in the space-update mutation (set
isArchived = truewhenflagsgains'archived'), which makes the always-oneq(spaces.isArchived, false)sufficient andomitArchivedredundant, or- Defaulting
omitArchivedtotrueso the safer behavior is the default.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/core/src/space/server/queries.ts` around lines 52 - 61, findAllSpaces currently hard-codes eq(spaces.isArchived, false) but defaults omitArchived = false, which lets flag-archived rows slip through; fix by making the safer default and/or keeping fields in sync: set omitArchived default to true in the findAllSpaces signature and ensure the WHERE clause includes the flags-based exclusion (not(sql`${spaces.flags} @> '["archived"]'::jsonb`)) when omitArchived is true; also update findAllSpacesByMemberId and findAllSpacesByWeb3SpaceIds to apply the same flags-based filter; additionally, in the space-update mutation (and create-space-form.tsx workflow) ensure that when flags gains or loses 'archived' you also set isArchived = true/false to keep the boolean column in sync.packages/epics/src/spaces/components/space-mode-label.tsx (1)
9-16:⚠️ Potential issue | 🔴 Critical
isArchivedis missing from theSpaceModeLabelcall in layout.tsxSince
isArchived: booleanis now required inSpaceModeLabelProps, the component call inapps/web/src/app/[lang]/dho/[id]/layout.tsx:164is incomplete. It passesisSandboxandisDemoderived fromspaceFromDb.flags, but omitsisArchived. Following the pattern fromspace-card-with-discoverability.tsx, pass:isArchived={spaceFromDb.flags?.includes('archived') ?? false}Also verify
space-card.tsx:157correctly passes all required props (it currently does).🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/epics/src/spaces/components/space-mode-label.tsx` around lines 9 - 16, SpaceModeLabel is now typed to require isArchived in SpaceModeLabelProps but the call in layout.tsx (where SpaceModeLabel is invoked with isSandbox and isDemo derived from spaceFromDb.flags) omits it; update that component call to pass isArchived using the same pattern as space-card-with-discoverability.tsx, e.g. set isArchived to spaceFromDb.flags?.includes('archived') ?? false so the SpaceModeLabelProps requirements are satisfied (also confirm space-card.tsx already passes all required props).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@packages/epics/src/spaces/components/create-space-form.tsx`:
- Around line 337-346: toggleArchived currently updates flags but forgets to
clear category validation errors when switching into 'archived' mode; update the
toggleArchived callback (mirror the behavior in toggleSandbox) to call
form.clearErrors('categories') whenever you set the next flags to include
'archived' (i.e., when activating archive mode) and then call
form.setValue('flags', next, { shouldDirty: true, shouldValidate: true }).
---
Outside diff comments:
In `@apps/web/src/app/`[lang]/my-spaces/page.tsx:
- Around line 36-39: The "Spaces you might like" carousel fetches allSpaces via
getAllSpaces without omitting archived entries, so archived spaces (flagged via
flags:['archived']) are showing up; update the call that sets allSpaces (the
first getAllSpaces invocation) to include omitArchived: true so it filters out
archived spaces (aligning with the network/explore page behavior and the
filtering logic in findAllSpaces).
In `@packages/core/src/space/server/queries.ts`:
- Around line 52-61: findAllSpaces currently hard-codes eq(spaces.isArchived,
false) but defaults omitArchived = false, which lets flag-archived rows slip
through; fix by making the safer default and/or keeping fields in sync: set
omitArchived default to true in the findAllSpaces signature and ensure the WHERE
clause includes the flags-based exclusion (not(sql`${spaces.flags} @>
'["archived"]'::jsonb`)) when omitArchived is true; also update
findAllSpacesByMemberId and findAllSpacesByWeb3SpaceIds to apply the same
flags-based filter; additionally, in the space-update mutation (and
create-space-form.tsx workflow) ensure that when flags gains or loses 'archived'
you also set isArchived = true/false to keep the boolean column in sync.
In `@packages/epics/src/spaces/components/space-mode-label.tsx`:
- Around line 9-16: SpaceModeLabel is now typed to require isArchived in
SpaceModeLabelProps but the call in layout.tsx (where SpaceModeLabel is invoked
with isSandbox and isDemo derived from spaceFromDb.flags) omits it; update that
component call to pass isArchived using the same pattern as
space-card-with-discoverability.tsx, e.g. set isArchived to
spaceFromDb.flags?.includes('archived') ?? false so the SpaceModeLabelProps
requirements are satisfied (also confirm space-card.tsx already passes all
required props).
ℹ️ Review info
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (11)
apps/web/src/app/[lang]/dho/[id]/_components/select-settings-action.tsxapps/web/src/app/[lang]/my-spaces/page.tsxapps/web/src/app/[lang]/network/page.tsxpackages/core/src/categories/types.tspackages/core/src/space/server/queries.tspackages/epics/src/spaces/components/create-space-form.tsxpackages/epics/src/spaces/components/my-filtered-spaces.tsxpackages/epics/src/spaces/components/space-card-with-discoverability.tsxpackages/epics/src/spaces/components/space-card.tsxpackages/epics/src/spaces/components/space-mode-label.tsxpackages/storage-postgres/src/schema/flags.ts
💤 Files with no reviewable changes (1)
- apps/web/src/app/[lang]/dho/[id]/_components/select-settings-action.tsx
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
apps/web/src/app/[lang]/dho/[id]/layout.tsx (1)
90-90:⚠️ Potential issue | 🟡 MinorArchived spaces appear unlabeled in "Spaces you might like".
Two gaps in this PR:
- Line 90 —
getAllSpacesomits sandboxes viaomitSandbox: truebut doesn't passomitArchived: true, so archived spaces leak into the discovery carousel. (Compare withapps/web/src/app/[lang]/network/page.tsxwhich correctly usesomitArchived: true.)- Lines 204–206 —
SpaceCardreceivesisSandboxandisDemobut notisArchived, so archived spaces render without the badge — unlike the current space's treatment at line 168.Resolve by either filtering them out or passing the prop (or both):
🔧 Proposed fix
- const spaces = await getAllSpaces({ parentOnly: false, omitSandbox: true }); + const spaces = await getAllSpaces({ parentOnly: false, omitSandbox: true, omitArchived: true });And if archived spaces should still appear with a badge instead of being hidden:
isSandbox={space.flags?.includes('sandbox') ?? false} isDemo={space.flags?.includes('demo') ?? false} + isArchived={space.flags?.includes('archived') ?? false}🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@apps/web/src/app/`[lang]/dho/[id]/layout.tsx at line 90, The discovery carousel is showing archived spaces because getAllSpaces is called with omitSandbox: true but not omitArchived; update the call to getAllSpaces({ parentOnly: false, omitSandbox: true, omitArchived: true }) so archived spaces are excluded, and/or propagate the archived state into the card UI by passing the space.isArchived value into SpaceCard (add isArchived={space.isArchived} where SpaceCard is rendered) and ensure SpaceCard's props/markup render the archived badge when isArchived is true so archived spaces are visibly labeled if you choose to keep them.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Outside diff comments:
In `@apps/web/src/app/`[lang]/dho/[id]/layout.tsx:
- Line 90: The discovery carousel is showing archived spaces because
getAllSpaces is called with omitSandbox: true but not omitArchived; update the
call to getAllSpaces({ parentOnly: false, omitSandbox: true, omitArchived: true
}) so archived spaces are excluded, and/or propagate the archived state into the
card UI by passing the space.isArchived value into SpaceCard (add
isArchived={space.isArchived} where SpaceCard is rendered) and ensure
SpaceCard's props/markup render the archived badge when isArchived is true so
archived spaces are visibly labeled if you choose to keep them.
There was a problem hiding this comment.
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 `@apps/web/src/app/`[lang]/dho/[id]/layout.tsx:
- Around line 169-171: The isArchived prop is incorrectly derived from
spaceMembers which is set to 0 on fetch/fallback errors; change the logic in the
layout where isArchived is computed to rely only on
spaceFromDb.flags.includes('archived') (remove the "|| spaceMembers === 0"
clause) and instead handle the members-failure case separately (e.g., keep
spaceMembers undefined/null on error or introduce an explicit membersFetchFailed
flag) so member-fetch failures do not mark spaces as archived; update any
related UI/error paths that depended on spaceMembers===0 to use the new failure
indicator.
In `@packages/core/src/space/server/web3/get-all-spaces.ts`:
- Around line 39-43: The mapping in enrichedSpaces sets memberCount: 0 when
web3SpaceId is null which causes isSpaceArchived to treat missing Web3 data as
archived; instead stop forcing memberCount to 0 (leave it undefined or null) and
update the filtering logic in isSpaceArchived (or the omitArchived branch) to
explicitly check web3SpaceId === null and treat those as "unknown/not archived"
rather than archived—apply the same change for the other case at the
corresponding block (lines referenced around the second instance).
ℹ️ Review info
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (8)
apps/web/src/app/[lang]/dho/[id]/layout.tsxapps/web/src/app/[lang]/my-spaces/page.tsxpackages/core/src/space/index.tspackages/core/src/space/server/web3/get-all-spaces.tspackages/core/src/space/utils.tspackages/epics/src/spaces/components/explore-spaces.tsxpackages/epics/src/spaces/components/my-filtered-spaces.tsxpackages/epics/src/spaces/components/space-card-with-discoverability.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
- packages/epics/src/spaces/components/my-filtered-spaces.tsx
Summary by CodeRabbit
New Features
Improvements