From ac554974f6d134da3e6559b313dbe375354ab6a8 Mon Sep 17 00:00:00 2001 From: SohamBhattacharjee2003 <125297948+SohamBhattacharjee2003@users.noreply.github.com> Date: Wed, 8 Apr 2026 06:32:05 +0530 Subject: [PATCH] perf: lazy load video presentation in public chat Convert GenerateVideoPresentationToolUI from static import to dynamic import with ssr: false in public-thread.tsx. This prevents Remotion and @babel/standalone from being bundled in the public chat page. The main app's assistant-message.tsx already correctly lazy-loads this component, but the public thread was still using a static import, unnecessarily increasing the bundle size for public shared chats. Benefits: - Removes Remotion and @babel/standalone from public chat bundle - Reduces initial bundle size for public shared chats - Video presentations still render correctly when present - Faster page load for users viewing public chats Fixes #1145 --- surfsense_web/components/public-chat/public-thread.tsx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/surfsense_web/components/public-chat/public-thread.tsx b/surfsense_web/components/public-chat/public-thread.tsx index 8678cef52..807bb74f8 100644 --- a/surfsense_web/components/public-chat/public-thread.tsx +++ b/surfsense_web/components/public-chat/public-thread.tsx @@ -8,6 +8,7 @@ import { useAuiState, } from "@assistant-ui/react"; import { CheckIcon, CopyIcon } from "lucide-react"; +import dynamic from "next/dynamic"; import Image from "next/image"; import { type FC, type ReactNode, useState } from "react"; import { CitationMetadataProvider } from "@/components/assistant-ui/citation-metadata-context"; @@ -17,7 +18,11 @@ import { TooltipIconButton } from "@/components/assistant-ui/tooltip-icon-button import { GenerateImageToolUI } from "@/components/tool-ui/generate-image"; import { GeneratePodcastToolUI } from "@/components/tool-ui/generate-podcast"; import { GenerateReportToolUI } from "@/components/tool-ui/generate-report"; -import { GenerateVideoPresentationToolUI } from "@/components/tool-ui/video-presentation"; + +const GenerateVideoPresentationToolUI = dynamic( + () => import("@/components/tool-ui/video-presentation").then((m) => ({ default: m.GenerateVideoPresentationToolUI })), + { ssr: false } +); interface PublicThreadProps { footer?: ReactNode;