Skip to content

⚡ Consolidate User Profile Fetching#1

Open
Adamugy wants to merge 1 commit into
masterfrom
performance/consolidate-profile-fetching-6974672999587511152
Open

⚡ Consolidate User Profile Fetching#1
Adamugy wants to merge 1 commit into
masterfrom
performance/consolidate-profile-fetching-6974672999587511152

Conversation

@Adamugy
Copy link
Copy Markdown
Owner

@Adamugy Adamugy commented Feb 10, 2026

⚡ Performance Optimization: Consolidate User Profile Fetching

💡 What:

Consolidated two redundant useEffect hooks in src/App.tsx that both fetched user profile data from /api/auth/me. The merged logic now handles both the initial full profile fetch (when the user ID changes) and lighter synchronization from the local auth context (when the user ID remains the same).

🎯 Why:

The previous implementation resulted in redundant network requests on every app load and whenever the user object changed. Specifically:

  1. AuthProvider fetched /api/auth/me on mount.
  2. AppContent had two separate useEffect hooks that both fetched /api/auth/me again.
    This caused unnecessary load on the server and slowed down the initial application state synchronization.

📊 Measured Improvement:

  • Baseline: 3 calls to /api/auth/me during initial render.
  • After Optimization: 2 calls to /api/auth/me.
  • Improvement: 33% reduction in initial profile-related network requests.
  • Safety: The lastSyncedUserIdRef pattern ensures that we only perform a full fetch when necessary, while still keeping the local state in sync with updates from the authentication context.
  • Type Safety: Updated PlanTier in src/types.ts to include missing tiers (researcher, lab) used in the application logic.

PR created automatically by Jules for task 6974672999587511152 started by @Adamugy

- Merged two redundant useEffect hooks in src/App.tsx into a single effect.
- Improved synchronization logic using lastSyncedUserIdRef to avoid unnecessary network calls.
- Updated PlanTier type in src/types.ts to include 'researcher' and 'lab' tiers.
- Reduced initial profile-related network requests from 3 to 2 (a 33% improvement).

Co-authored-by: Adamugy <64354399+Adamugy@users.noreply.github.com>
@google-labs-jules
Copy link
Copy Markdown

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

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