Skip to content

Conversation

@fairlighteth
Copy link
Contributor

@fairlighteth fairlighteth commented Dec 11, 2025

Summary

Major refactor of the Token Selector architecture to improve performance, maintainability, and user experience. This PR introduces a Jotai-based state management system, eliminates deep prop drilling, and implements a cleaner controller-view pattern.

🏗 Architecture & State Management

  • Jotai Atom Integration: Introduced tokenListViewAtom to manage view state (tokens, loading, search, context).
  • Controller-Level Hydration: Moved state hydration from SelectTokenModal to controllerAtomHydration hook.
    • Reduces SelectTokenModal props from ~35 to ~21 (UI/callbacks only, organized into logical interfaces).
    • Gates hydration with shouldRender to prevent unnecessary updates.
  • Controller Splitting: Decomposed monolithic controllerState.ts into cohesive hooks:
    • tokenDataHooks.ts (Data sources)
    • tokenSelectionHooks.ts (Selection logic)
    • widgetUIState.ts (UI handlers)
  • Flicker-Free Sync: Implemented useHydrateAtoms + useLayoutEffect pattern for seamless state synchronization.

⚡️ Performance & Cleanup

  • Prop Drilling Removal: TokensContent, TokensVirtualList, and TokenSearchResults now read directly from atoms instead of receiving drilled props.
  • Clean Teardown: Added useResetTokenListViewState to ensure state clears properly on widget close.
  • Render Optimization: Extracted SelectTokenModalShell and TokenColumnContent to reduce re-renders and file size.
  • Consistent Hydration: Ensures displayLpTokenLists and onClearRecentTokens are properly hydrated/passed to avoid state drift.

📱 UI/UX Improvements

  • Mobile Chain Selector: Added MobileChainSelector and MobileChainPanelPortal for better mobile navigation.
  • Chain Panel: Enhanced ChainPanel and ChainsSelector with improved styling and logic.
  • Favorites & Recents: Improved handling of favorite/recent tokens in the virtual list.

Test Plan

  • Manual Smoke Test:
    • Open/Close modal (state resets correctly)
    • Search tokens (input syncs to atom, list filters)
    • Favorites/Recent tokens display correctly
    • "Clear" recent tokens works
    • Chain selector panel works (desktop & mobile)
    • Bridge tokens filtering
    • LP Widget flow (gated by displayLpTokenLists)
  • Static Analysis:
    • TypeScript check passed
    • ESLint passed
  • Fixtures: Updated SelectTokenModal/index.cosmos.tsx to use CosmosAtomProvider.

- Move token list view state to `tokenListViewAtom` using Jotai
- Remove prop drilling through `SelectTokenModal` -> `TokensContent` -> `TokensVirtualList`
- Extract `SelectTokenModalShell` to reduce LOC in `SelectTokenModal/index.tsx`
- Implement `useHydrateAtoms` + `useLayoutEffect` for flicker-free state sync
- Add `useResetTokenListViewState` for clean unmounts
- Remove TODO from `types.ts`
@vercel
Copy link

vercel bot commented Dec 11, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
cowfi Ready Ready Preview Dec 15, 2025 10:36am
explorer-dev Ready Ready Preview Dec 15, 2025 10:36am
swap-dev Ready Ready Preview Dec 15, 2025 10:36am
widget-configurator Ready Ready Preview Dec 15, 2025 10:36am
2 Skipped Deployments
Project Deployment Review Updated (UTC)
cosmos Ignored Ignored Dec 15, 2025 10:36am
sdk-tools Ignored Ignored Preview Dec 15, 2025 10:36am

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 11, 2025

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/token-selector-14

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@fairlighteth fairlighteth changed the title refactor: props drilling refactor(tokenselector): 14 - remove props drilling Dec 11, 2025
@fairlighteth fairlighteth self-assigned this Dec 11, 2025
@fairlighteth fairlighteth requested a review from a team December 11, 2025 10:10
@fairlighteth fairlighteth marked this pull request as ready for review December 11, 2025 10:10
@fairlighteth fairlighteth marked this pull request as draft December 11, 2025 11:25
@fairlighteth fairlighteth removed the request for review from a team December 11, 2025 11:25
@fairlighteth fairlighteth changed the title refactor(tokenselector): 14 - remove props drilling refactor(tokensList): atom-based architecture & prop drilling removal Dec 11, 2025
…rops

- Move atom hydration from SelectTokenModal to controllerAtomHydration hook
- Split controllerState.ts into cohesive hooks (tokenData, tokenSelection, widgetUI)
- Reduce SelectTokenModal props from 27 to ~17 (remove data props, keep UI callbacks)
- Gate hydration by shouldRender to prevent unnecessary updates
- Update Cosmos fixtures to use atom provider
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants