Route unregistered token spaces to Token tab by default#1660
Route unregistered token spaces to Token tab by default#1660j-paterson merged 10 commits intocanaryfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Caution Review failedThe pull request is closed. 📝 WalkthroughWalkthroughRuntime default-tab loading added and hardcoded redirects removed. Page loaders now fetch a space's stored default tab and, when no tab param is provided, redirect to that tab. Several space-data creators became async to await the loaded default; TabBar delete/rename gating was simplified. Changes
Sequence Diagram(s)sequenceDiagram
participant Browser
participant NextPage as Next Page Loader
participant TabUtils as loadSpaceDefaultTab (Server)
participant Storage as Supabase (Storage)
Browser->>NextPage: Request /space/:id (no tab param)
NextPage->>TabUtils: loadSpaceDefaultTab(spaceId, fallback)
TabUtils->>Storage: fetch tabOrder for spaceId
Storage-->>TabUtils: tabOrder JSON (or error)
TabUtils-->>NextPage: resolved defaultTab (first tab or fallback)
NextPage-->>Browser: redirect to /space/:id/{encoded defaultTab}
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
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: 0
🧹 Nitpick comments (1)
src/app/(spaces)/t/[network]/[contractAddress]/page.tsx (1)
50-53: Dead code: fallback is unreachable after redirect.Since
redirect()throws when!decodedTabNameParam(lines 38-42), the fallback|| tokenSpacePageData.defaultTabon line 52 is never executed. Consider simplifying:Suggested simplification
<TokenSpace spacePageData={tokenSpacePageData} - tabName={decodedTabNameParam || tokenSpacePageData.defaultTab} + tabName={decodedTabNameParam} />Alternatively, if you want to keep the fallback for defensive coding (e.g., if the redirect logic changes later), a non-null assertion or comment would clarify intent.
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
next.config.mjssrc/app/(spaces)/t/[network]/[contractAddress]/page.tsxsrc/app/(spaces)/t/[network]/[contractAddress]/utils.tssrc/common/types/spaceData.ts
💤 Files with no reviewable changes (1)
- next.config.mjs
🧰 Additional context used
🧬 Code graph analysis (1)
src/app/(spaces)/t/[network]/[contractAddress]/utils.ts (1)
src/common/data/database/supabase/clients/server.ts (1)
createSupabaseServerClient(7-7)
🔇 Additional comments (5)
src/common/types/spaceData.ts (1)
46-54: LGTM - Type change supports dynamic default tab resolution.The broadening from literal
'Token'tostringenables the runtime-determined default tab. This is consistent with the baseSpacePageData.defaultTabtype on line 25.src/app/(spaces)/t/[network]/[contractAddress]/page.tsx (1)
37-42: LGTM - Redirect to computed default tab.The redirect correctly routes bare token-space URLs to the resolved default tab. Since
redirect()throws internally in Next.js, execution won't continue past this point when!decodedTabNameParam.src/app/(spaces)/t/[network]/[contractAddress]/utils.ts (3)
94-117: LGTM - Well-structured helper with appropriate error handling.The function correctly:
- Returns early when no
spaceIdis provided- Uses try-catch to handle JSON parsing and storage errors gracefully
- Falls back to
undefinedon any failure, allowing the caller to use a defaultOne consideration: the returned tab name is not validated against a known set of tabs. If storage contains an invalid tab name, it will be used as-is. This may be intentional to support custom tabs.
242-243: LGTM - Correct fallback chain for default tab resolution.The logic correctly resolves the default tab from the space's
tabOrderconfiguration, falling back to"Token"for unregistered spaces. This aligns with the PR objective.
274-287: Verify the returneddefaultTabis propagated correctly.The
defaultTabproperty is now dynamic. Confirm downstream consumers (particularly the page component's redirect logic) handle all possible values correctly.#!/bin/bash # Verify how defaultTab is used across the codebase rg -n --type=ts -C3 'defaultTab' src/app/
Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
cfd6ef7 to
4bc0bff
Compare
- Add shared loadSpaceDefaultTab utility function for consistent tab loading - Update all space types (Profile, Channel, Proposal, Token, NavPage) to use dynamic default tabs from tabOrder storage - Change defaultTab type from literal strings to string for all space types - Add redirect logic to Profile, Channel, and Proposal pages when no tab specified - Update TabBar to only show delete button when more than one tab exists - Allow renaming/deleting default tab as long as at least one tab remains - Ensure at least one tab always remains (enforced in UI and deletion logic)
Revert changes to: - src/config/index.ts (remove Clanker-specific config system) - src/config/clanker/initialSpaces/initialHomebase.ts (remove new file) - package.json (revert dependency updates) - yarn.lock (revert lock file changes)
Replace @neynar/nodejs-sdk imports with local string constants to avoid pulling in axios (which uses Node.js APIs) when config is imported in Edge Runtime contexts (e.g., /api/metadata/community). The enum values match the SDK: - FeedType.Filter = 'filter' - FilterType.ChannelId = 'channel_id'
Motivation
tabNamein the URL currently falls back to the profile handling and can cause a stray "Profile" tab to be created.Tokentab to avoid creating mismatched tab entries.Description
This should avoid breaking any token spaces that were registered with "profile" as the primary tab
Testing
Codex Task
Summary by CodeRabbit
New Features
Bug Fixes
Behavior
✏️ Tip: You can customize this high-level summary in your review settings.