Skip to content

fix: remove unnecessary use client directives#1166

Merged
MODSetter merged 3 commits intoMODSetter:devfrom
SohamBhattacharjee2003:fix/remove-unnecessary-use-client-directives
Apr 8, 2026
Merged

fix: remove unnecessary use client directives#1166
MODSetter merged 3 commits intoMODSetter:devfrom
SohamBhattacharjee2003:fix/remove-unnecessary-use-client-directives

Conversation

@SohamBhattacharjee2003
Copy link
Copy Markdown
Contributor

@SohamBhattacharjee2003 SohamBhattacharjee2003 commented Apr 7, 2026

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 Tailwind animate-in fade-in classes

Motivation 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.tsx file 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

  • This PR includes API changes

Change Type

  • Bug fix
  • New feature
  • Performance improvement
  • Refactoring
  • Documentation
  • Dependency/Build system
  • Breaking change
  • Other (specify):

Testing Performed

  • Tested locally
  • Manual/QA verification

Verified:

  • next build succeeds without errors or warnings
  • Loading skeleton animations work correctly with Tailwind classes (fade-in effect preserved)
  • Sidebar separator renders properly in docs pages
  • Connector document mapping functions work as expected in connector popup
  • No runtime errors or console warnings
  • Client bundle size reduced (removed Framer Motion dependency from loading page)
  • All components function identically to before

Checklist

  • Follows project coding standards and conventions
  • Documentation updated as needed
  • Dependencies updated as needed
  • No lint/build errors or new warnings
  • All relevant tests are passing

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 replaces window.location navigation calls with Next.js's useRouter throughout 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
Order File Path
1 surfsense_web/components/assistant-ui/connector-popup/utils/connector-document-mapping.ts
2 surfsense_web/app/docs/sidebar-separator.tsx
3 surfsense_web/app/dashboard/[search_space_id]/logs/loading.tsx
4 surfsense_web/app/(home)/login/page.tsx
5 surfsense_web/components/UserDropdown.tsx
6 surfsense_web/components/layout/ui/dialogs/CreateSearchSpaceDialog.tsx
⚠️ Inconsistent Changes Detected
File Path Warning
surfsense_web/app/(home)/login/page.tsx Replaces window.location.reload() with router.refresh() in error retry logic, which is a navigation pattern change unrelated to removing 'use client' directives
surfsense_web/components/UserDropdown.tsx Replaces window.location.href with router.push/refresh in logout flow, which is a navigation pattern change unrelated to removing 'use client' directives
surfsense_web/components/layout/ui/dialogs/CreateSearchSpaceDialog.tsx Replaces window.location.href with router.push in search space creation, which is a navigation pattern change unrelated to removing 'use client' directives

Need help? Join our Discord

Analyzing latest changes...

…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
@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 7, 2026

@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.

Copy link
Copy Markdown

@recurseml recurseml Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@MODSetter MODSetter merged commit cf2115b into MODSetter:dev Apr 8, 2026
6 of 9 checks passed
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.

2 participants