An open-source, faster Devin alternative
TypeScript
perf(web): code-split route pages + lazy-load Terminal/Logs panels
Igor Zalutskic95ca4679bf7
diff --git a/web/src/App.tsx b/web/src/App.tsxindex 08d777e7..3d363b4e 100644--- a/web/src/App.tsx+++ b/web/src/App.tsx@@ -1,15 +1,19 @@+import { lazy } from 'react'import { Routes, Route, Navigate } from 'react-router-dom'import { AuthProvider } from './hooks/auth-provider'import ProtectedRoute from './components/ProtectedRoute'import AppShell from './components/app-shell'-import Dashboard from './pages/Dashboard'-import Sessions from './pages/Sessions'-import APIKeys from './pages/APIKeys'-import Checkpoints from './pages/Checkpoints'-import Templates from './pages/Templates'-import Settings from './pages/Settings'-import Billing from './pages/Billing'-import SessionDetail from './pages/SessionDetail'++// Route pages are code-split so the initial bundle stays small; the heaviest+// deps (xterm, in Terminal/LogsPanel) only load on SessionDetail when opened.+const Dashboard = lazy(() => import('./pages/Dashboard'))+const Sessions = lazy(() => import('./pages/Sessions'))+const APIKeys = lazy(() => import('./pages/APIKeys'))+const Checkpoints = lazy(() => import('./pages/Checkpoints'))+const Templates = lazy(() => import('./pages/Templates'))+const Settings = lazy(() => import('./pages/Settings'))+const Billing = lazy(() => import('./pages/Billing'))+const SessionDetail = lazy(() => import('./pages/SessionDetail'))export default function App() {return (diff --git a/web/src/components/app-shell.tsx b/web/src/components/app-shell.tsxindex 30882d02..b841f9bf 100644--- a/web/src/components/app-shell.tsx+++ b/web/src/components/app-shell.tsx@@ -1,4 +1,4 @@-import { useState } from 'react'+import { Suspense, useState } from 'react'import { Link, NavLink, Outlet, useLocation } from 'react-router-dom'import { useQuery } from '@tanstack/react-query'import {@@ -13,6 +13,7 @@ import {ChevronsUpDown,Check,Menu,+ Loader2,type LucideIcon,} from 'lucide-react'import { useAuth } from '@/hooks/useAuth'@@ -235,7 +236,15 @@ export default function AppShell() {<div className="md:pt-16 md:pl-60"><HaltBanner /><main className="mx-auto max-w-7xl px-4 py-6 sm:px-8">- <Outlet />+ <Suspense+ fallback={+ <div className="flex min-h-[60vh] items-center justify-center">+ <Loader2 className="text-muted-foreground size-5 animate-spin" />+ </div>+ }+ >+ <Outlet />+ </Suspense></main></div></div>diff --git a/web/src/pages/SessionDetail.tsx b/web/src/pages/SessionDetail.tsxindex cb932aae..bffeb81d 100644--- a/web/src/pages/SessionDetail.tsx+++ b/web/src/pages/SessionDetail.tsx@@ -1,4 +1,4 @@-import { useState } from 'react'+import { lazy, Suspense, useState } from 'react'import { Link, useNavigate, useParams } from 'react-router-dom'import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'import { notifyError } from '@/lib/errors'@@ -10,6 +10,7 @@ import {Power,Trash2,ChevronRight,+ Loader2,} from 'lucide-react'import {deleteSession,@@ -20,8 +21,9 @@ import {type Session,type SessionDetail as SessionDetailData,} from '@/api/client'-import Terminal from '@/components/Terminal'-import LogsPanel from '@/components/LogsPanel'+// Lazy — these pull in xterm / the SSE stream; keep them out of the main chunk.+const Terminal = lazy(() => import('@/components/Terminal'))+const LogsPanel = lazy(() => import('@/components/LogsPanel'))import { Panel } from '@/components/panel'import { Button } from '@/components/ui/button'import { Skeleton } from '@/components/ui/skeleton'@@ -239,19 +241,23 @@ export default function SessionDetail() {{showTerminal && isRunning ? (<div className="mb-4">- <Terminal- sandboxId={sandboxId!}- onClose={() => setShowTerminal(false)}- />+ <Suspense fallback={<PanelLoading />}>+ <Terminal+ sandboxId={sandboxId!}+ onClose={() => setShowTerminal(false)}+ />+ </Suspense></div>) : null}{showLogs ? (<div className="mb-4">- <LogsPanel- sandboxId={sandboxId!}- onClose={() => setShowLogs(false)}- />+ <Suspense fallback={<PanelLoading />}>+ <LogsPanel+ sandboxId={sandboxId!}+ onClose={() => setShowLogs(false)}+ />+ </Suspense></div>) : null}@@ -424,6 +430,15 @@ export default function SessionDetail() {)}+// Dark fallback while a lazy panel (Terminal / Logs) chunk loads.+function PanelLoading() {+ return (+ <div className="bg-terminal border-code-border flex h-40 items-center justify-center rounded-lg border">+ <Loader2 className="text-code-muted size-5 animate-spin" />+ </div>+ )+}+function PreviewUrlRow({port,host,