Skip to content

⭐️⭐️⭐️ Open-source, self-hosted alternative to Linear and Plane. Project management and issue tracking where teams and AI agents work side by side to plan and ship products.

perf(web): load the shell overlays and the chat panel on first open (#689)

Croff47fdf2654614
diff --git a/apps/web/src/components/layout/ShellOverlays.tsx b/apps/web/src/components/layout/ShellOverlays.tsx
index 604a26bf..ade944b5 100644
--- a/apps/web/src/components/layout/ShellOverlays.tsx
+++ b/apps/web/src/components/layout/ShellOverlays.tsx
@@ -1,13 +1,17 @@
'use client';
+import dynamic from 'next/dynamic';
import { useRouter } from 'next/navigation';
import type { ProjectDetail } from '@/lib/api/endpoints/projects';
import { issuePath, projectPath } from '@/utils/paths';
import type { useOverlays } from '@/hooks/useOverlays';
-import NewProjectModal from '@/components/layout/NewProjectModal';
-import InitiativeDialog from '@/components/common/overlay/InitiativeDialog';
-import NewIssueModal from '@/features/issue/components/create/NewIssueModal';
-import IssueDetail from '@/features/issue/components/detail/IssueDetail';
+
+// Every project page mounts the Shell, so these load on first open: a page that opens
+// none of them does not download the editor and the pickers they carry.
+const NewProjectModal = dynamic(() => import('@/components/layout/NewProjectModal'));
+const InitiativeDialog = dynamic(() => import('@/components/common/overlay/InitiativeDialog'));
+const NewIssueModal = dynamic(() => import('@/features/issue/components/create/NewIssueModal'));
+const IssueDetail = dynamic(() => import('@/features/issue/components/detail/IssueDetail'));
// The project-level overlays the Shell mounts above its content. Each renders only
// while its overlay state says it is open.
diff --git a/apps/web/src/features/ai-chat/components/panel/ChatPanel.tsx b/apps/web/src/features/ai-chat/components/panel/ChatPanel.tsx
index b43f2ea1..ccec61bf 100644
--- a/apps/web/src/features/ai-chat/components/panel/ChatPanel.tsx
+++ b/apps/web/src/features/ai-chat/components/panel/ChatPanel.tsx
@@ -1,6 +1,7 @@
'use client';
import { useRef } from 'react';
+import dynamic from 'next/dynamic';
import { Maximize2, Minimize2, Pin, PinOff, X } from 'lucide-react';
import { useTranslations } from 'next-intl';
import { Direction } from 'radix-ui';
@@ -9,9 +10,11 @@ import { usePersistedWidth } from '@/hooks/usePersistedWidth';
import { cn } from '@/lib/utils';
import { Button } from '@/components/ui/button';
import ResizeGrip from '@/components/common/ResizeGrip';
-import { ChatPanelBody } from './ChatPanelBody';
import { chatPanelWidthKey, type ChatPanelMode } from '../../hooks/useChatPanel';
+// Its code, like its data, waits for the first open.
+const ChatPanelBody = dynamic(() => import('./ChatPanelBody').then((mod) => mod.ChatPanelBody));
+
const DEFAULT_WIDTH = 400;
const MIN_WIDTH = 320;
const MAX_WIDTH = 720;