fix: remove unnecessary use client directives#1166
Merged
MODSetter merged 3 commits intoMODSetter:devfrom Apr 8, 2026
Merged
Conversation
…gation - Replace window.location.href with router.push() + router.refresh() in UserDropdown logout - Replace window.location.href with router.push() in CreateSearchSpaceDialog - Replace window.location.reload() with router.refresh() in login page retry action - Prevents full page reloads and preserves React state during in-app navigation
- Remove 'use client' from connector-document-mapping.ts (only exports constants and pure functions) - Remove 'use client' from sidebar-separator.tsx (purely presentational component) - Remove 'use client' and Framer Motion from logs/loading.tsx, replace with Tailwind animations - Reduces client bundle size by moving server-compatible code to server components
|
@SohamBhattacharjee2003 is attempting to deploy a commit to the Rohan Verma's projects Team on Vercel. A member of the Team first needs to authorize it. |
There was a problem hiding this comment.
Review by RecurseML
🔍 Review performed on 65c0500..4066cbc
✨ No bugs found, your code is sparkling clean
✅ Files analyzed, no issues (6)
• surfsense_web/app/(home)/login/page.tsx
• surfsense_web/app/dashboard/[search_space_id]/logs/loading.tsx
• surfsense_web/app/docs/sidebar-separator.tsx
• surfsense_web/components/UserDropdown.tsx
• surfsense_web/components/assistant-ui/connector-popup/utils/connector-document-mapping.ts
• surfsense_web/components/layout/ui/dialogs/CreateSearchSpaceDialog.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Removed unnecessary
"use client"directives from modules that only export constants, types, or pure functions with no hooks, event handlers, or browser APIs. This reduces the client bundle size by allowing these components to be server-rendered.Changes:
connector-document-mapping.ts: Removed"use client"(only exports Record constant and pure utility functions)sidebar-separator.tsx: Removed"use client"(purely presentational component with no state/hooks/event handlers)logs/loading.tsx: Removed"use client"and Framer Motion, replaced with Tailwindanimate-in fade-inclassesMotivation and Context
Several modules were unnecessarily marked with
"use client"despite having no client-side requirements (hooks, event handlers, browser APIs). This forces them into the client bundle, increasing bundle size and reducing performance. By removing these directives, Next.js can render them on the server, improving initial page load times and reducing JavaScript sent to the client.The
logs/loading.tsxfile used Framer Motion only for entrance animations, which can be achieved with Tailwind's built-in animation utilities without requiring client-side JavaScript.FIX #1153
Screenshots
N/A - Bundle optimization (no visual changes, loading animations preserved)
API Changes
Change Type
Testing Performed
Verified:
next buildsucceeds without errors or warningsChecklist
High-level PR Summary
This PR removes unnecessary
"use client"directives from three modules that don't require client-side JavaScript (a constants/utils file, a presentational component, and a loading skeleton), allowing them to be server-rendered for better performance. Additionally, the PR replaceswindow.locationnavigation calls with Next.js'suseRouterthroughout the codebase for more consistent client-side routing, and removes Framer Motion from the loading skeleton in favor of Tailwind's built-in animation utilities.⏱️ Estimated Review Time: 5-15 minutes
💡 Review Order Suggestion
surfsense_web/components/assistant-ui/connector-popup/utils/connector-document-mapping.tssurfsense_web/app/docs/sidebar-separator.tsxsurfsense_web/app/dashboard/[search_space_id]/logs/loading.tsxsurfsense_web/app/(home)/login/page.tsxsurfsense_web/components/UserDropdown.tsxsurfsense_web/components/layout/ui/dialogs/CreateSearchSpaceDialog.tsxsurfsense_web/app/(home)/login/page.tsxsurfsense_web/components/UserDropdown.tsxsurfsense_web/components/layout/ui/dialogs/CreateSearchSpaceDialog.tsx