Skip to content

Conversation

tenfourty
Copy link


name: pull request
about: submit changes to the project
title: "[pr] Replace Easy Peasy with Zustand for improved performance and SSR"
labels: ''
assignees: ''


description

Replace Easy Peasy state management with Zustand across the entire application to improve performance, resolve SSR hydration issues, and enhance type safety. This migration was triggered by critical issues: the settings dialogue not working properly, onboarding always showing, and analytics remaining active despite being disabled.

Key Changes:

State Management Migration

  • Replace Easy Peasy stores with Zustand stores using modern patterns
  • Implement proper SSR hydration with zustand/middleware
  • Add comprehensive TypeScript interfaces for better type safety
  • Migrate settings and profiles to dedicated Zustand stores

Cross-Platform Improvements

  • Implement cross-platform getDataDir() using Tauri's appDataDir()
  • Replace hardcoded path handling with proper cross-platform APIs
  • Fix macOS-specific path resolution issues

Authentication & User Management

  • Add force reload functionality for user authentication
  • Implement 30-second caching with localforage for API calls
  • Add proper error handling and retry logic for authentication flows
  • Resolve user data synchronisation issues between stores

Performance & Reliability

  • Fix memory leaks in analytics timeout cleanup
  • Resolve React hook dependency warnings and circular references
  • Optimise React re-rendering with selective Zustand subscriptions
  • Add proper cleanup handlers for useEffect hooks

UI/UX Enhancements

  • Maintain persistent pipe filter toggle state
  • Improve settings dialogue behaviour and persistence
  • Add better loading states and error handling
  • Ensure consistent state across component re-renders

Technical Debt Resolution

  • Remove unused Easy Peasy dependencies and related code
  • Clean up circular dependency issues in React hooks
  • Add comprehensive error boundaries and defensive programming
  • Improve code organisation with dedicated type definitions

SSR & Hydration Fixes

  • Resolve Next.js hydration mismatches in onboarding flow
  • Add proper hydration guards for client-only operations
  • Implement store hydration awaiting patterns
  • Fix platform-specific initialisation issues

Implementation Notes: Vibe coded with Claude Code while trying to maintain a clean, organised code structure. Extensive manual testing was performed to ensure reliability.

related issue: #

how to test

  1. Settings Dialogue - Open settings, change preferences (especially analytics toggle), close and reopen - verify changes persist and analytics actually turn off
  2. Onboarding Flow - Clear app data/fresh install and verify onboarding only shows once, then doesn't reappear on subsequent launches
  3. Authentication - Login/logout multiple times, verify user data persists correctly, and no authentication loops occur
  4. Cross-Platform - Test on macOS/Windows/Linux to verify that path handling and data directory access work properly
  5. SSR Hydration - Check browser console during page loads for hydration errors, especially during onboarding
  6. Analytics Behaviour - Turn analytics off in settings and verify no analytics events are sent (check network tab)
  7. Pipe Filter State - Toggle pipe filters and navigate between pages to confirm state persistence

Files Changed: 48 files, 1,342 insertions, 1,023 deletions
Breaking Changes: None - maintains full backwards compatibility

Screenshots showing working settings persistence, single onboarding display, and clean console logs (no hydration errors) would help verify that the core issues are resolved.

if you are not the author of this PR and you see it and you think it can take more than 30 mins for maintainers to review, we will tip you between $20 and $200 for you to review and test it for us.

Replace Easy Peasy state management with Zustand across the entire application
to improve performance, resolve SSR hydration issues, and enhance type safety.

**Key Changes:**

## State Management Migration
- Replace Easy Peasy stores with Zustand stores using modern patterns
- Implement proper SSR hydration with zustand/middleware
- Add comprehensive TypeScript interfaces for better type safety
- Migrate settings and profiles to dedicated Zustand stores

## Cross-Platform Improvements
- Implement cross-platform `getDataDir()` using Tauri's `appDataDir()`
- Replace hardcoded path handling with proper cross-platform APIs
- Fix macOS-specific path resolution issues

## Authentication & User Management
- Add force reload functionality for user authentication
- Implement 30-second caching with localforage for API calls
- Add proper error handling and retry logic for authentication flows
- Resolve user data synchronization issues between stores

## Performance & Reliability
- Fix memory leaks in analytics timeout cleanup
- Resolve React hook dependency warnings and circular references
- Optimize React re-rendering with selective Zustand subscriptions
- Add proper cleanup handlers for useEffect hooks

## UI/UX Enhancements
- Maintain persistent pipe filter toggle state
- Improve settings dialog behavior and persistence
- Add better loading states and error handling
- Ensure consistent state across component re-renders

## Technical Debt Resolution
- Remove unused Easy Peasy dependencies and related code
- Clean up circular dependency issues in React hooks
- Add comprehensive error boundaries and defensive programming
- Improve code organization with dedicated type definitions

## SSR & Hydration Fixes
- Resolve Next.js hydration mismatches in onboarding flow
- Add proper hydration guards for client-only operations
- Implement store hydration awaiting patterns
- Fix platform-specific initialization issues

**Files Changed:** 48 files, 1,342 insertions, 1,023 deletions

**Breaking Changes:** None - maintains full backward compatibility

**Testing:** All existing functionality verified working with improved reliability
Copy link
Contributor

🧪 testing bounty created!

a testing bounty has been created for this PR: view testing issue

testers will be awarded $20 each for providing quality test reports. please check the issue for testing requirements.

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.

1 participant