Skip to content

An open-source, faster Devin alternative

TypeScript

feat(web): migrate Layout/shell to AppShell (light, responsive)

Igor Zalutskia088d2ed0d9b
diff --git a/web/src/App.tsx b/web/src/App.tsx
index 5db25ff7..ddc7eb3b 100644
--- a/web/src/App.tsx
+++ b/web/src/App.tsx
@@ -1,7 +1,7 @@
import { Routes, Route, Navigate } from 'react-router-dom'
import { AuthProvider } from './hooks/useAuth'
import ProtectedRoute from './components/ProtectedRoute'
-import Layout from './components/Layout'
+import AppShell from './components/app-shell'
import Dashboard from './pages/Dashboard'
import Sessions from './pages/Sessions'
import APIKeys from './pages/APIKeys'
@@ -16,7 +16,7 @@ export default function App() {
<AuthProvider>
<Routes>
<Route element={<ProtectedRoute />}>
- <Route element={<Layout />}>
+ <Route element={<AppShell />}>
<Route index element={<Dashboard />} />
<Route path="sessions" element={<Sessions />} />
<Route path="sessions/:sandboxId" element={<SessionDetail />} />
diff --git a/web/src/components/Layout.tsx b/web/src/components/Layout.tsx
deleted file mode 100644
index 3855bdd3..00000000
--- a/web/src/components/Layout.tsx
+++ /dev/null
@@ -1,299 +0,0 @@
-import { useState } from 'react'
-import { NavLink, Outlet, useLocation, Link } from 'react-router-dom'
-import { useQuery } from '@tanstack/react-query'
-import { useAuth } from '../hooks/useAuth'
-import { logout, getAutumnBilling } from '../api/client'
-
-/* ── SVG Icons (inline, no extra deps) ────────────────────── */
-const icons = {
- grid: (
- <svg width="17" height="17" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.7" strokeLinecap="round" strokeLinejoin="round">
- <rect x="3" y="3" width="7" height="7" rx="1.5" />
- <rect x="14" y="3" width="7" height="7" rx="1.5" />
- <rect x="3" y="14" width="7" height="7" rx="1.5" />
- <rect x="14" y="14" width="7" height="7" rx="1.5" />
- </svg>
- ),
- clock: (
- <svg width="17" height="17" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.7" strokeLinecap="round" strokeLinejoin="round">
- <circle cx="12" cy="12" r="9" />
- <polyline points="12 7 12 12 15.5 14.5" />
- </svg>
- ),
- key: (
- <svg width="17" height="17" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.7" strokeLinecap="round" strokeLinejoin="round">
- <path d="M21 2l-2 2m-7.61 7.61a5.5 5.5 0 1 1-7.778 7.778 5.5 5.5 0 0 1 7.777-7.777zm0 0L15.5 7.5m0 0l3 3L22 7l-3-3m-3.5 3.5L19 4" />
- </svg>
- ),
- layers: (
- <svg width="17" height="17" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.7" strokeLinecap="round" strokeLinejoin="round">
- <polygon points="12 2 2 7 12 12 22 7 12 2" />
- <polyline points="2 17 12 22 22 17" />
- <polyline points="2 12 12 17 22 12" />
- </svg>
- ),
- box: (
- <svg width="17" height="17" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.7" strokeLinecap="round" strokeLinejoin="round">
- <path d="M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z" />
- <polyline points="3.27 6.96 12 12.01 20.73 6.96" />
- <line x1="12" y1="22.08" x2="12" y2="12" />
- </svg>
- ),
- creditCard: (
- <svg width="17" height="17" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.7" strokeLinecap="round" strokeLinejoin="round">
- <rect x="1" y="4" width="22" height="16" rx="2" ry="2" />
- <line x1="1" y1="10" x2="23" y2="10" />
- </svg>
- ),
- gear: (
- <svg width="17" height="17" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.7" strokeLinecap="round" strokeLinejoin="round">
- <circle cx="12" cy="12" r="3" />
- <path d="M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 1 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 1 1-2.83-2.83l.06-.06A1.65 1.65 0 0 0 4.68 15a1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 1 1 2.83-2.83l.06.06A1.65 1.65 0 0 0 9 4.68a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 1 1 2.83 2.83l-.06.06A1.65 1.65 0 0 0 19.4 9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1z" />
- </svg>
- ),
- logout: (
- <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.7" strokeLinecap="round" strokeLinejoin="round">
- <path d="M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4" />
- <polyline points="16 17 21 12 16 7" />
- <line x1="21" y1="12" x2="9" y2="12" />
- </svg>
- ),
-}
-
-const navItems = [
- { to: '/', label: 'Dashboard', end: true, icon: icons.grid },
- { to: '/sessions', label: 'Sessions', icon: icons.clock },
- { to: '/checkpoints', label: 'Checkpoints', icon: icons.layers },
- { to: '/templates', label: 'Templates', icon: icons.box },
- { to: '/api-keys', label: 'API Keys', icon: icons.key },
- { to: '/billing', label: 'Billing', icon: icons.creditCard },
- { to: '/settings', label: 'Settings', icon: icons.gear },
-]
-
-// Org-wide halt notice. Prepaid (autumn) orgs that exhaust their credits get
-// halted — sandboxes hibernate — so show a small banner on every page except
-// Billing (where the fix already lives) so they understand why things paused
-// and where to resolve it. Legacy orgs 404 on /billing/autumn → no data → no
-// banner, which is the desired behavior.
-function HaltBanner() {
- const location = useLocation()
- const { data } = useQuery({
- queryKey: ['autumn-billing'],
- queryFn: getAutumnBilling,
- retry: false,
- refetchInterval: (q) => (q.state.error ? false : 30_000),
- })
- const halted = data?.isHalted ?? false
- if (!halted || location.pathname.startsWith('/billing')) return null
- return (
- <div style={{
- margin: '-32px -36px 28px',
- padding: '9px 36px',
- background: 'var(--accent-indigo)',
- color: '#fff',
- fontSize: 13,
- fontWeight: 500,
- display: 'flex', alignItems: 'center', justifyContent: 'center',
- textAlign: 'center',
- }}>
- <span>
- Your sandboxes are paused — you&apos;re out of prepaid credits.{' '}
- <Link to="/billing" style={{ color: '#fff', fontWeight: 700, textDecoration: 'underline' }}>
- Top up &amp; turn on auto-recharge
- </Link>{' '}
- to resume now and prevent future pauses.
- </span>
- </div>
- )
-}
-
-export default function Layout() {
- const { user, switchOrg } = useAuth()
- const [orgSwitcherOpen, setOrgSwitcherOpen] = useState(false)
- const hasMultipleOrgs = (user?.orgs?.length ?? 0) > 1
- const activeOrg = user?.orgs?.find(o => o.isActive)
-
- return (
- <div style={{ display: 'flex', minHeight: '100vh' }}>
- {/* ── Sidebar ── */}
- <nav style={{
- width: 232,
- background: 'var(--bg-deep)',
- borderRight: '1px solid var(--border-subtle)',
- display: 'flex',
- flexDirection: 'column',
- position: 'fixed',
- top: 0,
- left: 0,
- bottom: 0,
- zIndex: 50,
- }}>
- {/* Brand */}
- <div style={{ padding: '22px 20px 18px', borderBottom: '1px solid var(--border-subtle)' }}>
- <div style={{ display: 'flex', alignItems: 'center', gap: 10 }}>
- <div style={{
- width: 30, height: 30, borderRadius: 8,
- background: 'var(--gradient-primary)',
- display: 'flex', alignItems: 'center', justifyContent: 'center',
- fontSize: 12, fontWeight: 800, color: '#fff',
- fontFamily: 'var(--font-display)',
- boxShadow: '0 0 16px rgba(99,102,241,0.25)',
- }}>OS</div>
- <div>
- <div style={{
- fontSize: 14, fontWeight: 700,
- fontFamily: 'var(--font-display)',
- color: 'var(--text-primary)',
- letterSpacing: '-0.02em',
- }}>OpenComputer</div>
- <div style={{
- fontSize: 9, color: 'var(--text-tertiary)',
- fontFamily: 'var(--font-mono)',
- letterSpacing: '0.06em',
- textTransform: 'uppercase',
- }}>Console</div>
- </div>
- </div>
- </div>
-
- {/* Org Switcher (only visible with multiple orgs) */}
- {hasMultipleOrgs && (
- <div style={{ padding: '10px 12px', borderBottom: '1px solid var(--border-subtle)', position: 'relative' }}>
- <button
- onClick={() => setOrgSwitcherOpen(!orgSwitcherOpen)}
- style={{
- width: '100%', display: 'flex', alignItems: 'center', justifyContent: 'space-between',
- padding: '8px 10px', background: 'rgba(255,255,255,0.03)',
- border: '1px solid var(--border-subtle)', borderRadius: 6,
- cursor: 'pointer', color: 'var(--text-primary)', fontSize: 12,
- fontFamily: 'var(--font-body)',
- }}
- >
- <span style={{ overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}>
- {activeOrg?.name || 'Select org'}
- </span>
- <svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2">
- <polyline points="6 9 12 15 18 9" />
- </svg>
- </button>
- {orgSwitcherOpen && (
- <div style={{
- position: 'absolute', top: '100%', left: 12, right: 12,
- background: 'var(--bg-deep)', border: '1px solid var(--border-subtle)',
- borderRadius: 6, marginTop: 4, zIndex: 100,
- boxShadow: '0 4px 16px rgba(0,0,0,0.3)',
- }}>
- {user?.orgs?.map(org => (
- <button
- key={org.id}
- onClick={() => {
- switchOrg(org.id)
- setOrgSwitcherOpen(false)
- }}
- style={{
- display: 'block', width: '100%', textAlign: 'left',
- padding: '8px 12px', background: org.isActive ? 'rgba(99,102,241,0.1)' : 'none',
- border: 'none', cursor: 'pointer',
- color: org.isActive ? 'var(--text-primary)' : 'var(--text-secondary)',
- fontSize: 12, fontFamily: 'var(--font-body)',
- borderBottom: '1px solid var(--border-subtle)',
- }}
- onMouseOver={e => { if (!org.isActive) e.currentTarget.style.background = 'rgba(255,255,255,0.03)' }}
- onMouseOut={e => { if (!org.isActive) e.currentTarget.style.background = 'none' }}
- >
- {org.name}
- {org.isPersonal && <span style={{ fontSize: 10, color: 'var(--text-tertiary)', marginLeft: 6 }}>(personal)</span>}
- </button>
- ))}
- </div>
- )}
- </div>
- )}
-
- {/* Nav Links */}
- <div style={{ flex: 1, padding: '10px 8px' }}>
- {navItems.map(item => (
- <NavLink
- key={item.to}
- to={item.to}
- end={item.end}
- style={({ isActive }) => ({
- display: 'flex',
- alignItems: 'center',
- gap: 10,
- padding: '9px 14px',
- color: isActive ? 'var(--text-primary)' : 'var(--text-secondary)',
- background: isActive ? 'rgba(99, 102, 241, 0.07)' : 'transparent',
- textDecoration: 'none',
- fontSize: 13,
- fontWeight: isActive ? 600 : 400,
- fontFamily: 'var(--font-body)',
- borderRadius: 8,
- marginBottom: 2,
- transition: 'all 0.15s ease',
- borderLeft: isActive
- ? '2px solid var(--accent-indigo)'
- : '2px solid transparent',
- })}
- >
- <span style={{ display: 'flex', alignItems: 'center', opacity: 0.6 }}>{item.icon}</span>
- {item.label}
- </NavLink>
- ))}
- </div>
-
- {/* User */}
- <div style={{
- padding: '14px 16px',
- borderTop: '1px solid var(--border-subtle)',
- }}>
- <div style={{ display: 'flex', alignItems: 'center', gap: 10, marginBottom: 10 }}>
- <div style={{
- width: 28, height: 28, borderRadius: '50%',
- background: 'var(--gradient-primary)',
- display: 'flex', alignItems: 'center', justifyContent: 'center',
- fontSize: 11, fontWeight: 700, color: '#fff',
- flexShrink: 0,
- }}>
- {user?.email?.charAt(0).toUpperCase() || '?'}
- </div>
- <div style={{
- fontSize: 12, color: 'var(--text-secondary)',
- overflow: 'hidden', textOverflow: 'ellipsis',
- whiteSpace: 'nowrap', flex: 1,
- }}>{user?.email}</div>
- </div>
- <button
- onClick={() => logout()}
- style={{
- display: 'flex', alignItems: 'center', gap: 6,
- background: 'none', border: 'none',
- color: 'var(--text-tertiary)',
- cursor: 'pointer', fontSize: 12,
- fontFamily: 'var(--font-body)',
- padding: 0,
- transition: 'color 0.15s ease',
- }}
- onMouseOver={e => (e.currentTarget.style.color = 'var(--accent-rose)')}
- onMouseOut={e => (e.currentTarget.style.color = 'var(--text-tertiary)')}
- >
- {icons.logout}
- Sign out
- </button>
- </div>
- </nav>
-
- {/* ── Main Content ── */}
- <main style={{
- flex: 1,
- marginLeft: 232,
- padding: '32px 36px',
- minHeight: '100vh',
- background: 'radial-gradient(ellipse 80% 50% at 50% -10%, rgba(99,102,241,0.04) 0%, transparent 70%)',
- }}>
- <HaltBanner />
- <Outlet />
- </main>
- </div>
- )
-}
diff --git a/web/src/components/app-shell.tsx b/web/src/components/app-shell.tsx
new file mode 100644
index 00000000..cfd5cb1d
--- /dev/null
+++ b/web/src/components/app-shell.tsx
@@ -0,0 +1,238 @@
+import { useState } from 'react'
+import { Link, NavLink, Outlet, useLocation } from 'react-router-dom'
+import { useQuery } from '@tanstack/react-query'
+import {
+ LayoutGrid,
+ Boxes,
+ Layers,
+ Package,
+ KeyRound,
+ CreditCard,
+ Settings,
+ LogOut,
+ ChevronsUpDown,
+ Check,
+ Menu,
+ type LucideIcon,
+} from 'lucide-react'
+import { useAuth } from '@/hooks/useAuth'
+import { logout, getAutumnBilling } from '@/api/client'
+import { Button } from '@/components/ui/button'
+import {
+ Sheet,
+ SheetContent,
+ SheetTitle,
+ SheetTrigger,
+} from '@/components/ui/sheet'
+import {
+ DropdownMenu,
+ DropdownMenuContent,
+ DropdownMenuItem,
+ DropdownMenuLabel,
+ DropdownMenuSeparator,
+ DropdownMenuTrigger,
+} from '@/components/ui/dropdown-menu'
+import { cn } from '@/lib/utils'
+
+type NavItem = { to: string; label: string; icon: LucideIcon; end?: boolean }
+
+const NAV: NavItem[] = [
+ { to: '/', label: 'Dashboard', icon: LayoutGrid, end: true },
+ { to: '/sessions', label: 'Sessions', icon: Boxes },
+ { to: '/checkpoints', label: 'Checkpoints', icon: Layers },
+ { to: '/templates', label: 'Templates', icon: Package },
+ { to: '/api-keys', label: 'API Keys', icon: KeyRound },
+ { to: '/billing', label: 'Billing', icon: CreditCard },
+ { to: '/settings', label: 'Settings', icon: Settings },
+]
+
+function Brand() {
+ return (
+ <Link to="/" className="flex items-center gap-2.5">
+ <span className="bg-foreground text-background flex size-8 items-center justify-center rounded-md font-mono text-xs font-bold">
+ oc
+ </span>
+ <span className="flex flex-col leading-none">
+ <span className="text-sm font-semibold tracking-tight">
+ OpenComputer
+ </span>
+ <span className="text-muted-foreground mt-0.5 font-mono text-[10px] tracking-wide">
+ Console
+ </span>
+ </span>
+ </Link>
+ )
+}
+
+function OrgSwitcher() {
+ const { user, switchOrg } = useAuth()
+ const orgs = user?.orgs ?? []
+ if (orgs.length <= 1) return null
+ const active = orgs.find((o) => o.isActive)
+
+ return (
+ <DropdownMenu>
+ <DropdownMenuTrigger asChild>
+ <Button
+ variant="outline"
+ className="w-full justify-between font-normal"
+ size="sm"
+ >
+ <span className="truncate">{active?.name || 'Select org'}</span>
+ <ChevronsUpDown className="size-3.5 shrink-0 opacity-60" />
+ </Button>
+ </DropdownMenuTrigger>
+ <DropdownMenuContent
+ align="start"
+ className="w-(--radix-dropdown-menu-trigger-width) min-w-56"
+ >
+ <DropdownMenuLabel>Organizations</DropdownMenuLabel>
+ <DropdownMenuSeparator />
+ {orgs.map((org) => (
+ <DropdownMenuItem
+ key={org.id}
+ onClick={() => !org.isActive && switchOrg(org.id)}
+ className="gap-2"
+ >
+ <Check
+ className={cn(
+ 'size-4 shrink-0',
+ org.isActive ? 'opacity-100' : 'opacity-0',
+ )}
+ />
+ <span className="truncate">{org.name}</span>
+ {org.isPersonal ? (
+ <span className="text-muted-foreground ml-auto text-xs">
+ personal
+ </span>
+ ) : null}
+ </DropdownMenuItem>
+ ))}
+ </DropdownMenuContent>
+ </DropdownMenu>
+ )
+}
+
+function SidebarBody({ onNavigate }: { onNavigate?: () => void }) {
+ const { user } = useAuth()
+ return (
+ <div className="flex h-full flex-col">
+ <div className="border-b px-4 py-4">
+ <Brand />
+ </div>
+
+ {(user?.orgs?.length ?? 0) > 1 ? (
+ <div className="border-b px-3 py-3">
+ <OrgSwitcher />
+ </div>
+ ) : null}
+
+ <nav className="flex-1 space-y-0.5 overflow-y-auto p-3">
+ {NAV.map((item) => (
+ <NavLink
+ key={item.to}
+ to={item.to}
+ end={item.end}
+ onClick={onNavigate}
+ className={({ isActive }) =>
+ cn(
+ 'flex min-h-9 items-center gap-2.5 rounded-md px-3 text-sm transition-colors',
+ isActive
+ ? 'bg-sidebar-accent text-foreground font-medium'
+ : 'text-muted-foreground hover:bg-sidebar-accent/60 hover:text-foreground',
+ )
+ }
+ >
+ <item.icon className="size-[18px] shrink-0" aria-hidden />
+ {item.label}
+ </NavLink>
+ ))}
+ </nav>
+
+ <div className="border-t p-3">
+ <div className="mb-2 flex items-center gap-2.5 px-1">
+ <span className="bg-secondary flex size-7 shrink-0 items-center justify-center rounded-full text-xs font-semibold">
+ {user?.email?.charAt(0).toUpperCase() || '?'}
+ </span>
+ <span className="text-muted-foreground truncate text-xs">
+ {user?.email}
+ </span>
+ </div>
+ <Button
+ variant="ghost"
+ size="sm"
+ className="text-muted-foreground w-full justify-start"
+ onClick={() => logout()}
+ >
+ <LogOut className="size-4" aria-hidden />
+ Sign out
+ </Button>
+ </div>
+ </div>
+ )
+}
+
+// Org-wide halt notice. Prepaid (autumn) orgs that exhaust credits get halted
+// (sandboxes hibernate); show a banner everywhere except Billing so users know
+// why things paused and where to resolve it. Legacy orgs 404 on /billing/autumn
+// → no data → no banner.
+function HaltBanner() {
+ const location = useLocation()
+ const { data } = useQuery({
+ queryKey: ['autumn-billing'],
+ queryFn: getAutumnBilling,
+ retry: false,
+ refetchInterval: (q) => (q.state.error ? false : 30_000),
+ })
+ const halted = data?.isHalted ?? false
+ if (!halted || location.pathname.startsWith('/billing')) return null
+ return (
+ <div className="border-status-pending/20 bg-status-pending-bg text-status-pending border-b px-4 py-2.5 text-center text-sm sm:px-8">
+ Your sandboxes are paused — you&apos;re out of prepaid credits.{' '}
+ <Link
+ to="/billing"
+ className="font-semibold underline underline-offset-2"
+ >
+ Top up &amp; turn on auto-recharge
+ </Link>{' '}
+ to resume now and prevent future pauses.
+ </div>
+ )
+}
+
+export default function AppShell() {
+ const [drawerOpen, setDrawerOpen] = useState(false)
+
+ return (
+ <div className="bg-background text-foreground min-h-screen font-sans">
+ {/* Desktop sidebar */}
+ <aside className="bg-sidebar fixed inset-y-0 left-0 z-30 hidden w-60 border-r md:block">
+ <SidebarBody />
+ </aside>
+
+ {/* Mobile top bar */}
+ <header className="bg-sidebar sticky top-0 z-20 flex h-14 items-center gap-3 border-b px-4 md:hidden">
+ <Sheet open={drawerOpen} onOpenChange={setDrawerOpen}>
+ <SheetTrigger asChild>
+ <Button variant="ghost" size="icon" aria-label="Open navigation">
+ <Menu className="size-5" />
+ </Button>
+ </SheetTrigger>
+ <SheetContent side="left" className="bg-sidebar w-64 p-0">
+ <SheetTitle className="sr-only">Navigation</SheetTitle>
+ <SidebarBody onNavigate={() => setDrawerOpen(false)} />
+ </SheetContent>
+ </Sheet>
+ <Brand />
+ </header>
+
+ {/* Main content */}
+ <div className="md:pl-60">
+ <HaltBanner />
+ <main className="mx-auto max-w-7xl px-4 py-6 sm:px-8 sm:py-8">
+ <Outlet />
+ </main>
+ </div>
+ </div>
+ )
+}