Skip to content

Conversation

@JollyRogerz
Copy link
Collaborator

✨ Feature: Comprehensive Optimizations, Testing Foundation, & UI Refinements 🛠️🧪🎨

This Pull Request introduces a significant suite of improvements across the codebase, focusing on performance optimization, establishing a robust testing foundation, enhancing UI/UX, and improving overall code quality and stability.

Vercel ---> https://atoma-dashboard-agqkim7kr-jollyvs-projects.vercel.app/

🚀 Performance Optimizations & Bundle Analysis:

  1. Bundle Analysis Setup 📊:

    • Integrated @next/bundle-analyzer to allow for detailed inspection of JavaScript bundle sizes.
    • Added an analyze script to package.json for easy generation of bundle reports.
    • Configured next.config.mjs to activate the analyzer via the ANALYZE=true environment variable.
  2. Dependency Version Pinning 📌:

    • Updated package.json to pin all dependencies to specific versions, moving away from latest or broad caret ^ ranges. This ensures more stable and reproducible builds.
    • Resolved type definition conflicts by consolidating @types/react and @types/react-dom into devDependencies.
  3. Next.js Image Optimization 🖼️:

    • Enabled Next.js's powerful built-in image optimization by setting images.unoptimized: false in next.config.mjs. The project was already making good use of the <Image> component.
  4. Code Splitting & Dynamic Imports for Load Time Improvement ⚡:

    • ZKLogin Cryptographic Libraries: The ZkLogin class (lib/zklogin.ts) and its substantial cryptographic dependencies (including poseidon-lite) are now dynamically imported only when ZK login flows are initiated (e.g., in AuthForm, account-portal, and wallet disconnection utilities). This significantly reduces their impact on initial bundle sizes for users not engaging with ZK login.
    • Recharts (Charting Library):
      • Refactored AreaPanel and BarGaugePanel (used in app/page.tsx) into separate, self-contained component files (components/charts/AreaPanel.tsx, components/charts/BarGaugePanel.tsx).
      • These chart panels are now dynamically imported in app/page.tsx, ensuring the recharts library (approx. 72KB gzipped) is loaded on demand rather than being part of the main page's initial bundle.
    • Module Refactoring for Tree-Shaking:
      • Split lib/atoma.ts: Type interfaces and enums (e.g., ModelModality) were moved to lib/atoma-types.ts.
      • Created lib/sui-utils.ts: The Sui Transaction-dependent payUSDC function was moved here. This broke a critical static import chain that was unnecessarily pulling @mysten/sui/transactions (and its large dependencies like poseidon-lite) into the main bundle via lib/utils.ts.

🧪 Testing Foundation & Initial Test Suites:

  1. Testing Framework & Libraries Setup 🛠️:

    • Installed and configured Jest as the testing framework.
    • Integrated React Testing Library (@testing-library/react, @testing-library/jest-dom, @testing-library/user-event) for component and interaction testing.
    • Added jest-environment-jsdom for a browser-like testing environment.
    • Incorporated ESLint plugins (eslint-plugin-jest-dom, eslint-plugin-testing-library) to enforce testing best practices.
  2. Configuration:

    • jest.config.mjs: Set up for Next.js with TypeScript support, module name mappers for aliases, and JSDOM environment.
    • jest.setup.js: Imports @testing-library/jest-dom for extended matchers and includes a global mock for ResizeObserver to improve compatibility with Radix UI-based components.
    • .eslintrc.json: Enhanced with plugin:testing-library/react and plugin:jest-dom/recommended.
    • package.json: Added test and test:watch scripts.
  3. Initial Test Suites Implemented ✅:

    • Utility Functions:
      • lib/utils.ts: Comprehensive unit tests for simplifyModelName, formatNumber, modalityToFeatureName, and cn.
      • utils/utils.ts: Unit tests for readableModelName, processModelsForCategory, RenderRequestBodyBasedOnEndPoint, and parseOutputBasedOnEndpoint.
    • Core UI Components:
      • components/LoadingCircle.tsx: Tests for rendering and prop variations (size, spinning state).
      • components/NavItem.tsx: (Refactored out of Sidebar for testability). Tests cover rendering based on props, active state highlighting, external link behavior, and tooltip structure (using mocks).
      • components/AuthForm.tsx: Extensive tests covering login/register modes, form input validation, API call mocking (loginUser, registerUser), context interactions (useSettings), ZkLogin flow mocking (dynamic import and class methods), and error/success toast notifications.
      • components/sidebar.tsx: Tests for rendering navigation items (using a mocked NavItem), conditional rendering of "Settings" link based on login state, collapsed/expanded states on desktop, and mobile open/close functionality (mocking useMobile and useSettings).
    • Page-Level Components:
      • app/models/page.test.tsx: Tests for data fetching logic (mocking getTasks, getSubscriptions), rendering of model cards, interaction with the Select component for filtering models (regular and confidential), and triggering the ApiUsageDialog.
      • app/page.test.tsx (Network Status Dashboard): Initial tests covering rendering of MetricsCards, initial loading states, and handling of API failures for graph data. (More complex data flow and panel prop tests were temporarily skipped due to persistent mocking challenges but can be revisited).
    • Skipped Tests: The test suite for components/top-nav.tsx has been temporarily skipped (describe.skip) due to intractable "Element type is invalid" errors in the JSDOM environment, despite extensive mocking efforts. This suite can be re-enabled and debugged further in the future.

🎨 UI/UX Enhancements & Bug Fixes:

  1. Chart Date Formatting (app/page.tsx) 📅:

    • Resolved "Invalid Date" issues on chart X-axes by ensuring consistent use of numeric timestamps and proper formatting.
  2. Sidebar Navigation Order (components/sidebar.tsx) 🧭:

    • External links ("Docs", "Help") are now grouped at the bottom of the sidebar for better organization.
  3. Account Portal UI (components/api-documentation.tsx) 🔒➡️☑️:

    • Replaced the Lock/Unlock icon for "Confidential" mode in the Quick Reference section with a standard Checkbox and Label, improving clarity and user experience.
  4. Models Page UI (app/models/page.tsx) 💅:

    • Removed the redundant Lock/Unlock toggle near the "Models" page title (confidentiality is now solely managed by the Select dropdown).
    • Increased text size within ModelCards and the minimum height of the cards for improved readability and visual appeal.
  5. Client-Side Exception Resolution (Hydration) 📱✅:

    • Refactored hooks/use-mobile.tsx (and removed a duplicate) to correctly initialize state in useEffect, preventing hydration mismatches related to viewport-dependent rendering.
    • Significantly refactored components/background-grid.tsx to calculate dimensions in useEffect and use a performant pattern, resolving potential hydration errors and improving its rendering logic while preserving its interactive effect.
  6. Build Stability (ESLint & TypeScript) 💪:

    • Enabled strict ESLint and TypeScript error checking during builds in next.config.mjs.
    • Systematically addressed numerous type errors and linter warnings that surfaced, leading to a cleaner and more robust codebase. This included correcting import paths after module refactoring and improving type safety.
    • Added eslint-disable-next-line comments where necessary for specific, pragmatic DOM access patterns in test mocks (e.g., for closest() and React.Children manipulations).

This comprehensive effort significantly advances the project's quality, performance, and testability. Future work can build upon this strong foundation.

Ruben-ledgerlink and others added 30 commits May 23, 2025 20:57
* add stream and update playground chat

* stop stream

* remove edit and add email to api key

* wip

* reduce circle
* Update UI components and layout, add SUI wallet integration, and update dependencies

* fix: add react-markdown dependency for playground page

* Fix dropdown positioning issues with CSS modifications

* Fix dropdown menu positioning by reverting to original implementation with align='end' and forceMount

* fix: remove fill from TTFT and ITL charts while maintaining fill for other charts

* UI overhaul with grid highlighting fixes, button styling specificity, component updates, and added libraries

* Fix conflicts with main branch by importing login-register components

* Resolve top-nav.tsx conflict by merging dash/v2 wallet disconnect functionality

* feat: Update sidebar logos and top nav button styles - Add new Atoma logos and adjust size - Enhance top nav button styles with hover effects for light/dark modes

* fix: improved sidebar logo alignment and dark mode transition performance

* fix: consistent card hover effects in light and dark mode, improve sidebar transitions

* fix: adjust spacing between label and input in dialog

---------

Co-authored-by: Ruben Macedo <[email protected]>
* Update UI components and layout, add SUI wallet integration, and update dependencies

* fix: add react-markdown dependency for playground page

* Fix dropdown positioning issues with CSS modifications

* Fix dropdown menu positioning by reverting to original implementation with align='end' and forceMount

* fix: remove fill from TTFT and ITL charts while maintaining fill for other charts

* UI overhaul with grid highlighting fixes, button styling specificity, component updates, and added libraries

* Fix conflicts with main branch by importing login-register components

* Resolve top-nav.tsx conflict by merging dash/v2 wallet disconnect functionality

* feat: Update sidebar logos and top nav button styles - Add new Atoma logos and adjust size - Enhance top nav button styles with hover effects for light/dark modes

* fix: improved sidebar logo alignment and dark mode transition performance

* fix: consistent card hover effects in light and dark mode, improve sidebar transitions

* fix: adjust spacing between label and input in dialog

* Fix modal styling and chart theme reactivity

---------

Co-authored-by: Ruben Macedo <[email protected]>
…mpute toggle in Quick Reference - Add confidential compute variants in Models page - Update API examples for confidential compute - Add lock icon and confidential tags - Update ApiUsageDialog to support confidential mode
…etwork#162)

* feat: add confidential compute endpoints and UI - Add confidential compute toggle in Quick Reference - Add confidential compute variants in Models page - Update API examples for confidential compute - Add lock icon and confidential tags - Update ApiUsageDialog to support confidential mode

* chore: clean up .env backup example conflict markers

* Deleted not needed env files

* removed patch file
…oma-network#164)

* feat: add confidential compute endpoints and UI - Add confidential compute toggle in Quick Reference - Add confidential compute variants in Models page - Update API examples for confidential compute - Add lock icon and confidential tags - Update ApiUsageDialog to support confidential mode

* chore: clean up .env backup example conflict markers

* Deleted not needed env files

* removed patch file

* fix: loosen payUSDC client type to avoid dapp-kit mismatched SuiClient types

* fix: loosen SuiClient type in utils.payUSDC

* fix: remove invalid suppressHydrationWarning prop on next-themes ThemeProvider

* fix: remove duplicate Layout definition causing duplicate React identifier error

* fix: make error and onSubmit props optional for LoginRegisterModal

* fix: add custom props interface for Separator orientation and decorative

* fix: remove outdated WalletContextState import, fallback to any

* chore: exclude playground backup file from TypeScript checks

* chore: fix type errors and tsconfig exclusions

* fix: provide required props to LoginRegisterModal

* fix: cast suiClient to any to resolve type mismatch during build

* feat: conditionally render Settings link based on login state
…ipsis, tooltips, reduced whitespace, and usage-based sorting
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants