-
Notifications
You must be signed in to change notification settings - Fork 141
fix(frontend): prefetch context switcher content only on org routes #3792
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(frontend): prefetch context switcher content only on org routes #3792
Conversation
|
🚅 Deployed to the rivet-pr-3792 environment in rivet-frontend
|
Merge activity
|
How to use the Graphite Merge QueueAdd the label merge-queue to this PR to add it to the merge queue. You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. This stack of pull requests is managed by Graphite. Learn more about stacking. |
…3792) ### TL;DR Refactored the ContextSwitcher component to improve code organization and fix a naming inconsistency. ### What changed? - Extracted the inner functionality of `ContextSwitcher` into a new `ContextSwitcherInner` component - Renamed `useContextSwitchMatch` to `useContextSwitcherMatch` for consistency - Simplified conditional logic by passing the organization as a prop to the inner component - Removed unnecessary type checking and conditional expressions ### How to test? 1. Navigate to pages that use the context switcher 2. Verify the context switcher appears correctly 3. Click on the context switcher to open the dropdown 4. Confirm that all functionality works as expected ### Why make this change? This refactoring improves code readability and maintainability by: - Creating a clearer separation of concerns between components - Fixing inconsistent naming conventions - Simplifying conditional logic that was unnecessarily complex - Making the code more predictable by using props instead of accessing context data in multiple places
Pull Request ReviewSummaryThis PR refactors the ContextSwitcher component to improve code organization and fix a naming inconsistency. The changes are well-executed with one key improvement: Key improvement: The prefetch query now only runs when on organization routes, preventing unnecessary data fetching on non-org pages. ✅ Strengths
🔍 Code Quality ObservationsTypeScript & React Patterns
Logic CorrectnessThe refactor maintains functional equivalence with a key improvement: Before: usePrefetchInfiniteQuery({
enabled: typeof match === "object" && "organization" in match,
...projectsQueryOptions({ organization: /* complex conditional */ })
});After: // Only rendered when match is truthy (frontend/src/app/context-switcher.tsx:36)
usePrefetchInfiniteQuery({
...projectsQueryOptions({ organization }) // Always has valid org
});This is actually an improvement because:
🎯 Testing RecommendationsBased on the PR description's test plan, I'd suggest verifying:
📊 Final AssessmentCode Quality: ⭐⭐⭐⭐⭐ Excellent ✨ RecommendationAPPROVE - This is a solid refactoring that improves code quality, maintainability, and performance. The changes are safe, well-structured, and the performance optimization (prefetching only on org routes) is a meaningful improvement. No blocking issues found. Ready to merge after testing verification. |
Graphite Automations"Test" took an action on this PR • (01/08/26)1 assignee was added to this PR based on Kacper Wojciechowski's automation. |

TL;DR
Refactored the ContextSwitcher component to improve code organization and fix a naming inconsistency.
What changed?
ContextSwitcherinto a newContextSwitcherInnercomponentuseContextSwitchMatchtouseContextSwitcherMatchfor consistencyHow to test?
Why make this change?
This refactoring improves code readability and maintainability by: