Skip to content

perf: lazy-load DocumentTabContent to reduce initial dashboard bundle…#1273

Merged
MODSetter merged 1 commit intoMODSetter:devfrom
Tacite243:perf/lazy-load-document-content-1242
Apr 21, 2026
Merged

perf: lazy-load DocumentTabContent to reduce initial dashboard bundle…#1273
MODSetter merged 1 commit intoMODSetter:devfrom
Tacite243:perf/lazy-load-document-content-1242

Conversation

@Tacite243
Copy link
Copy Markdown
Contributor

@Tacite243 Tacite243 commented Apr 20, 2026

This PR implements dynamic importing (lazy-loading) for the DocumentTabContent component within the LayoutShell.

Description

  • Replaced the static import of DocumentTabContent with next/dynamic.
  • Added a loading state with a centered Spinner for better perceived performance.
  • Enabled ssr: false for this component to prevent potential hydration issues with the heavy editor dependencies (Plate/KaTeX).
  • Verified that document rendering and editing still work as expected.

Motivation and Context

The dashboard shell was previously pulling in heavy dependencies (Plate editor, MarkdownViewer, KaTeX, etc.) even for users who only used the chat. By lazy-loading the document content, we significantly reduce the initial bundle size of the dashboard.

FIX #1242

Screenshots

API Changes

  • This PR includes API changes

Change Type

  • Bug fix
  • New feature
  • Performance improvement
  • Refactoring
  • Documentation
  • Dependency/Build system
  • Breaking change

Testing Performed

  • Tested locally: Verified the spinner appears briefly when opening a document and that the editor is fully functional.
  • Manual/QA verification: Confirmed the chat-only pages no longer trigger the loading of document-related heavy scripts.

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

Note: Used --no-verify for commit due to existing lint errors in the main branch.
@MODSetter

High-level PR Summary

This PR implements lazy-loading for the DocumentTabContent component using next/dynamic to reduce the initial dashboard bundle size. By deferring the load of heavy editor dependencies (Plate editor, MarkdownViewer, KaTeX) until the document tab is actually accessed, users who only interact with chat features no longer need to download these unnecessary dependencies. The change includes a loading spinner for better user experience during component loading and disables SSR to prevent potential hydration issues with the editor dependencies.

⏱️ Estimated Review Time: 5-15 minutes

💡 Review Order Suggestion
Order File Path
1 surfsense_web/components/layout/ui/shell/LayoutShell.tsx

Need help? Join our Discord

Analyze latest changes

Summary by CodeRabbit

  • Performance
    • Document tabs now display a loading spinner while content is being prepared, improving the perceived performance of the application.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 20, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: b2abadc6-30d9-4d7b-b59f-34df8ad51f5d

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • ✅ Review completed - (🔄 Check again to review again)
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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 2b2453e..be2e011

✨ No bugs found, your code is sparkling clean

✅ Files analyzed, no issues (1)

surfsense_web/components/layout/ui/shell/LayoutShell.tsx

@MODSetter MODSetter merged commit df8a122 into MODSetter:dev Apr 21, 2026
2 of 3 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