diff --git a/apps/web/app/globals.css b/apps/web/app/globals.css
index bf9d3d5..d763014 100644
--- a/apps/web/app/globals.css
+++ b/apps/web/app/globals.css
@@ -144,7 +144,26 @@
* {
@apply border-border outline-ring/50;
}
+ html {
+ -webkit-text-size-adjust: 100%;
+ text-size-adjust: 100%;
+ /* A tap shows the control's own pressed state, not the browser's grey box. */
+ -webkit-tap-highlight-color: transparent;
+ }
body {
@apply bg-background text-foreground font-sans;
+ /* The page stays put: no rubber-band of the whole app, no pull to refresh. */
+ overscroll-behavior: none;
+ }
+ /* No double-tap zoom, so taps answer at once. */
+ a,
+ button,
+ input,
+ label,
+ select,
+ textarea,
+ [role='button'],
+ [role='tab'] {
+ touch-action: manipulation;
}
}
diff --git a/apps/web/app/layout.tsx b/apps/web/app/layout.tsx
index 6b52389..6d078fa 100644
--- a/apps/web/app/layout.tsx
+++ b/apps/web/app/layout.tsx
@@ -1,4 +1,4 @@
-import type { Metadata } from 'next'
+import type { Metadata, Viewport } from 'next'
import { SITE_NAME } from '@/lib/site'
import { GeistSans } from 'geist/font/sans'
import { GeistMono } from 'geist/font/mono'
@@ -16,6 +16,22 @@ export const dynamic = 'force-dynamic'
export const metadata: Metadata = {
title: SITE_NAME,
description: 'A v0.app clone built with AI Elements and Geist.',
+ // Added to a phone's home screen, it opens full screen, like an app.
+ appleWebApp: { capable: true, title: SITE_NAME, statusBarStyle: 'default' },
+}
+
+// A phone: the page runs edge to edge (the shell pads for the notch and the
+// home bar), the keyboard shrinks the page rather than covering the composer,
+// and the browser's bars take the page's colour.
+export const viewport: Viewport = {
+ width: 'device-width',
+ initialScale: 1,
+ viewportFit: 'cover',
+ interactiveWidget: 'resizes-content',
+ themeColor: [
+ { media: '(prefers-color-scheme: light)', color: '#ffffff' },
+ { media: '(prefers-color-scheme: dark)', color: '#0f0f11' },
+ ],
}
export default async function RootLayout({
diff --git a/apps/web/app/manifest.ts b/apps/web/app/manifest.ts
new file mode 100644
index 0000000..9e9b029
--- /dev/null
+++ b/apps/web/app/manifest.ts
@@ -0,0 +1,16 @@
+import type { MetadataRoute } from 'next'
+import { SITE_NAME } from '@/lib/site'
+
+// Installed on a phone, the app opens on its own, without the browser's bars.
+export default function manifest(): MetadataRoute.Manifest {
+ return {
+ name: SITE_NAME,
+ short_name: SITE_NAME,
+ description: 'A v0.app clone built with AI Elements and Geist.',
+ start_url: '/',
+ display: 'standalone',
+ background_color: '#ffffff',
+ theme_color: '#ffffff',
+ icons: [{ src: '/icon.svg', sizes: 'any', type: 'image/svg+xml' }],
+ }
+}
diff --git a/apps/web/components/ai-elements/prompt-input.tsx b/apps/web/components/ai-elements/prompt-input.tsx
index d4416a6..6dc9c75 100644
--- a/apps/web/components/ai-elements/prompt-input.tsx
+++ b/apps/web/components/ai-elements/prompt-input.tsx
@@ -775,6 +775,10 @@ export const PromptInputTextarea = ({
if (e.shiftKey) {
return
}
+ // A touch keyboard's return key starts a new line; the send button sends.
+ if (window.matchMedia('(pointer: coarse)').matches) {
+ return
+ }
e.preventDefault()
// Check if the submit button is disabled before submitting
diff --git a/apps/web/components/chat/chat-conversation.tsx b/apps/web/components/chat/chat-conversation.tsx
index 0d185fd..80fb2cd 100644
--- a/apps/web/components/chat/chat-conversation.tsx
+++ b/apps/web/components/chat/chat-conversation.tsx
@@ -249,7 +249,7 @@ export function ChatConversation({
taskDisabled={isSubmitting || restoringMessageId !== null}
vercelProjectId={vercelProjectId}
/>
-
+
= [
+ { pane: 'chat', label: 'Chat' },
+ { pane: 'preview', label: 'Preview' },
+ { pane: 'code', label: 'Code' },
+]
+
export function ChatHeader({
chatId,
title,
view,
onViewChange,
+ mobilePane,
+ onMobilePaneChange,
}: {
chatId: string
title: string
view: ChatView
onViewChange: (view: ChatView) => void
+ mobilePane: MobilePane
+ onMobilePaneChange: (pane: MobilePane) => void
}) {
const router = useRouter()
const deployChat = useDeployChat(`/api/chats/${encodeURIComponent(chatId)}/deploy`)
@@ -99,135 +113,249 @@ export function ChatHeader({
}
return (
-
-
-
- {title}
-
-
-
-
-
onViewChange('preview')}
- size="icon-xs"
- variant="ghost"
- >
-
-
-
onViewChange('code')}
- size="icon-xs"
- variant="ghost"
- >
-
-
+ <>
+ {/* A phone: menu, the chat's title, its actions and a new chat; then the
+ Chat | Preview | Code switch. */}
+
-
-
-
-
-
-
-
-
/
-
-
-
-
-
-
+
+
+
+
+ {title}
+
-
-
-
-
-
-
-
-
- {
- event.preventDefault()
- void duplicate()
- }}
- title={duplicateError ?? undefined}
- >
- {isDuplicating ? (
-
- ) : (
-
- )}
- {isDuplicating ? 'Duplicating' : 'Duplicate'}
-
- {
- event.preventDefault()
- void download()
- }}
- title={duplicateError ?? undefined}
- >
- {isDownloading ? (
-
- ) : (
-
- )}
- {isDownloading ? 'Downloading' : 'Download'}
-
-
-
- {deploymentUrl ? (
-
-
-
- View
-
+
+
+ onViewChange('preview')}
+ size="icon-xs"
+ variant="ghost"
+ >
+
- ) : (
onViewChange('code')}
+ size="icon-xs"
+ variant="ghost"
>
- {isPublishing ? (
-
- ) : (
-
- )}
- {isPublishing ? 'Publishing' : 'Publish'}
+
+
+
+
+
+
+
+
+
+
- )}
+ /
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {
+ event.preventDefault()
+ void duplicate()
+ }}
+ title={duplicateError ?? undefined}
+ >
+ {isDuplicating ? (
+
+ ) : (
+
+ )}
+ {isDuplicating ? 'Duplicating' : 'Duplicate'}
+
+ {
+ event.preventDefault()
+ void download()
+ }}
+ title={duplicateError ?? undefined}
+ >
+ {isDownloading ? (
+
+ ) : (
+
+ )}
+ {isDownloading ? 'Downloading' : 'Download'}
+
+
+
+ {deploymentUrl ? (
+
+
+
+ View
+
+
+ ) : (
+
+ {isPublishing ? (
+
+ ) : (
+
+ )}
+ {isPublishing ? 'Publishing' : 'Publish'}
+
+ )}
+
-
-
+
+ >
)
}
diff --git a/apps/web/components/chat/chat-workspace.tsx b/apps/web/components/chat/chat-workspace.tsx
index 866a881..2ff9631 100644
--- a/apps/web/components/chat/chat-workspace.tsx
+++ b/apps/web/components/chat/chat-workspace.tsx
@@ -8,9 +8,10 @@ import {
CodeEditorPane,
type ChatFilesResult,
} from '@/components/chat/code-editor'
-import { ChatHeader, type ChatView } from '@/components/chat/chat-header'
+import { ChatHeader, type ChatView, type MobilePane } from '@/components/chat/chat-header'
import { ChatConversation } from '@/components/chat/chat-conversation'
import { PreviewPane } from '@/components/preview/preview-pane'
+import { cn } from '@/lib/utils'
import { designModeMessageText, type DesignModeTurn } from '@/lib/design-mode-message'
import type { DesignModeMessage } from 'v0/browser'
@@ -25,6 +26,9 @@ export function ChatWorkspace({
}) {
const router = useRouter()
const [view, setView] = useState
('preview')
+ // A phone shows one pane at a time, the chat first; a wide screen shows the
+ // chat beside the preview or the code.
+ const [mobilePane, setMobilePane] = useState('chat')
const [contentRevision, setContentRevision] = useState(0)
const [previewRevision, setPreviewRevision] = useState(0)
const [isPreviewReady, setIsPreviewReady] = useState(false)
@@ -69,16 +73,28 @@ export function ChatWorkspace({
router.refresh()
}, [router])
+ const handleMobilePaneChange = useCallback((pane: MobilePane) => {
+ setMobilePane(pane)
+ if (pane !== 'chat') setView(pane)
+ }, [])
+
return (
-
+
-
+
-
+ // A phone: the files are a row of chips above the editor; a wide screen:
+ // a list beside it.
+
+
{files.map((file) => (
updateSelectedFile(event.target.value)}
spellCheck={false}
diff --git a/apps/web/components/chat/conversation-view.tsx b/apps/web/components/chat/conversation-view.tsx
index 4137abe..314d476 100644
--- a/apps/web/components/chat/conversation-view.tsx
+++ b/apps/web/components/chat/conversation-view.tsx
@@ -61,7 +61,7 @@ export function ConversationView({
return (
-
+
{visibleMessages.length === 0 ? (
No messages yet.
) : (
@@ -116,8 +116,8 @@ function ConversationMessage({
diff --git a/apps/web/components/home/home-client.tsx b/apps/web/components/home/home-client.tsx
index 145e4a5..4aac71e 100644
--- a/apps/web/components/home/home-client.tsx
+++ b/apps/web/components/home/home-client.tsx
@@ -12,7 +12,7 @@ import { useMemo, useRef, useState, type ChangeEvent, type FormEvent } from 'rea
import { PromptBox } from '@/components/prompt-box'
import { PromptInputButton } from '@/components/ai-elements/prompt-input'
import { ConversationView } from '@/components/chat/conversation-view'
-import { SidebarToggleButton } from '@/components/layout/app-shell'
+import { MobileTopBar, SidebarToggleButton } from '@/components/layout/app-shell'
import { Button } from '@/components/ui/button'
import {
Dialog,
@@ -32,6 +32,7 @@ import { Input } from '@/components/ui/input'
import { Label } from '@/components/ui/label'
import { useSettings } from '@/lib/hooks/useSettings'
import { FileIcon, PlusIcon } from '@/lib/icons'
+import { SITE_NAME } from '@/lib/site'
export function HomeClient() {
const router = useRouter()
@@ -195,8 +196,9 @@ export function HomeClient() {
return (
<>
-
-
+
+
+
0 ? (
<>
-
{prompt}
+
+ {prompt}
+
>
) : (
-
-
-
- What do you want to create?
-
- {prompt}
+ // A phone: the question in the middle, the box at the bottom under
+ // the thumb. A wide screen: both together, centred.
+
+
+
+
+ What do you want to create?
+
+
+
+ {prompt}
+
)}
diff --git a/apps/web/components/layout/app-shell.tsx b/apps/web/components/layout/app-shell.tsx
index 0336297..ae6da8b 100644
--- a/apps/web/components/layout/app-shell.tsx
+++ b/apps/web/components/layout/app-shell.tsx
@@ -1,35 +1,106 @@
'use client'
-import { createContext, useContext, useState } from 'react'
+import { createContext, useCallback, useContext, useEffect, useRef, useState } from 'react'
+import { usePathname } from 'next/navigation'
import { Sidebar } from '@/components/layout/sidebar'
import { Button } from '@/components/ui/button'
import type { getSidebarChats } from '@/lib/sidebar-chats'
-import { SidebarToggleIcon } from '@/lib/icons'
+import { MenuIcon, NewChatIcon, SidebarToggleIcon } from '@/lib/icons'
import { cn } from '@/lib/utils'
+// The shell: the sidebar beside the page on a wide screen; on a phone, a
+// drawer over it, the way a native chat app does it (closed at first, opened
+// from the menu button or a swipe from the left edge, closed by the scrim, a
+// swipe back, or going to another chat).
+
const SidebarContext = createContext<{
open: boolean
setOpen: (open: boolean) => void
+ mobileOpen: boolean
+ setMobileOpen: (open: boolean) => void
} | null>(null)
-export function SidebarToggleButton({ className }: { className?: string }) {
+/** How far from the left edge a swipe must start to open the drawer, and how
+ * far it must travel. */
+const EDGE_PX = 24
+const SWIPE_PX = 56
+
+export function SidebarToggleButton({
+ className,
+ wideOnly = false,
+}: {
+ className?: string
+ /** Leave the phone's menu button to the page's own top bar. */
+ wideOnly?: boolean
+}) {
const sidebar = useContext(SidebarContext)
+ if (!sidebar) return null
- if (!sidebar || sidebar.open) return null
+ return (
+ <>
+ {/* A phone: the menu button, always there. */}
+ {wideOnly ? null : (
+
sidebar.setMobileOpen(true)}
+ size="icon"
+ variant="ghost"
+ >
+
+
+ )}
+ {/* A wide screen: only while the sidebar is collapsed. */}
+ {sidebar.open ? null : (
+
sidebar.setOpen(true)}
+ size="icon"
+ variant="ghost"
+ >
+
+
+ )}
+ >
+ )
+}
+/** A phone's new-chat button, top right. */
+export function NewChatButton({ className }: { className?: string }) {
return (
sidebar.setOpen(true)}
+ aria-label="New chat"
+ className={cn('size-10 shrink-0 text-foreground md:hidden', className)}
+ onClick={() => window.location.assign('/')}
size="icon"
variant="ghost"
>
-
+
)
}
+/** A phone's top bar: menu, title, then what the page adds (new chat by
+ * default). Hidden on a wide screen. */
+export function MobileTopBar({
+ title,
+ actions,
+}: {
+ title?: React.ReactNode
+ actions?: React.ReactNode
+}) {
+ return (
+
+
+
+ {title}
+
+ {actions ?? }
+
+ )
+}
+
export function AppShell({
children,
apiKeyStatus,
@@ -43,16 +114,79 @@ export function AppShell({
sidebarChats: ReturnType
}) {
const [sidebarOpen, setSidebarOpen] = useState(true)
+ const [mobileOpen, setMobileOpen] = useState(false)
+ const pathname = usePathname()
+ const touchStart = useRef<{ x: number; y: number } | null>(null)
+
+ // Going to another chat closes the drawer.
+ const [drawerPath, setDrawerPath] = useState(pathname)
+ if (drawerPath !== pathname) {
+ setDrawerPath(pathname)
+ setMobileOpen(false)
+ }
+
+ // Escape closes it too.
+ useEffect(() => {
+ if (!mobileOpen) return
+ const onKey = (event: KeyboardEvent) => {
+ if (event.key === 'Escape') setMobileOpen(false)
+ }
+ window.addEventListener('keydown', onKey)
+ return () => window.removeEventListener('keydown', onKey)
+ }, [mobileOpen])
+
+ const onTouchStart = useCallback((event: React.TouchEvent) => {
+ const touch = event.touches[0]
+ touchStart.current = touch ? { x: touch.clientX, y: touch.clientY } : null
+ }, [])
+
+ // A swipe from the left edge opens the drawer; a swipe left closes it.
+ const onTouchEnd = useCallback(
+ (event: React.TouchEvent) => {
+ const start = touchStart.current
+ const touch = event.changedTouches[0]
+ touchStart.current = null
+ if (!start || !touch) return
+ const dx = touch.clientX - start.x
+ const dy = Math.abs(touch.clientY - start.y)
+ if (dy > Math.abs(dx)) return
+ if (!mobileOpen && start.x <= EDGE_PX && dx >= SWIPE_PX) setMobileOpen(true)
+ else if (mobileOpen && dx <= -SWIPE_PX) setMobileOpen(false)
+ },
+ [mobileOpen],
+ )
return (
-
-
+
+
setMobileOpen(false)}
onToggle={() => setSidebarOpen((open) => !open)}
open={sidebarOpen}
sidebarChats={sidebarChats}
/>
+ {/* The scrim behind the phone drawer. */}
+ setMobileOpen(false)}
+ />
{children}
diff --git a/apps/web/components/layout/chat-item.tsx b/apps/web/components/layout/chat-item.tsx
index 3894292..c4bb567 100644
--- a/apps/web/components/layout/chat-item.tsx
+++ b/apps/web/components/layout/chat-item.tsx
@@ -90,12 +90,15 @@ export function ChatItem({
<>
{chat.title || 'Untitled'}
@@ -106,7 +109,8 @@ export function ChatItem({
-
+
void handleToggleFavorite()}>
{isFavorite ? 'Remove from Favorites' : 'Add to Favorites'}
diff --git a/apps/web/components/layout/sidebar.tsx b/apps/web/components/layout/sidebar.tsx
index 725d729..919dbe6 100644
--- a/apps/web/components/layout/sidebar.tsx
+++ b/apps/web/components/layout/sidebar.tsx
@@ -10,10 +10,13 @@ import { ChatItem } from '@/components/layout/chat-item'
import { ApiKeyDialog } from '@/components/layout/api-key-dialog'
import type { getSidebarChats } from '@/lib/sidebar-chats'
import { cn } from '@/lib/utils'
-import { ChevronDownIcon, ChevronRightIcon, SidebarToggleIcon } from '@/lib/icons'
+import { ChevronDownIcon, ChevronRightIcon, CrossIcon, SidebarToggleIcon } from '@/lib/icons'
type SidebarProps = {
open: boolean
+ /** A phone: the drawer is out. */
+ mobileOpen: boolean
+ onMobileClose: () => void
apiKeyStatus: {
hasBrowserApiKey: boolean
hasEnvironmentApiKey: boolean
@@ -28,6 +31,7 @@ export function Sidebar(props: SidebarProps) {
fallback={
@@ -38,22 +42,30 @@ export function Sidebar(props: SidebarProps) {
)
}
+/** The aside: beside the page on a wide screen; on a phone, a drawer over it
+ * that slides in from the left. */
+function asideClass(open: boolean, mobileOpen: boolean) {
+ return cn(
+ 'flex shrink-0 flex-col gap-1 overflow-hidden bg-sidebar',
+ 'fixed inset-y-0 left-0 z-50 w-[85vw] max-w-80 pt-[env(safe-area-inset-top)] pb-[env(safe-area-inset-bottom)] transition-[translate,visibility] duration-300 ease-out',
+ // Shut, it slides out, then leaves the tab order and the screen reader;
+ // its shadow shows only while it is out.
+ mobileOpen ? 'translate-x-0 shadow-2xl' : '-translate-x-full max-md:invisible',
+ 'md:static md:z-auto md:max-w-none md:translate-x-0 md:pt-0 md:pb-0 md:shadow-none md:transition-[width] md:duration-200',
+ open ? 'md:w-64 md:border-r md:border-sidebar-border' : 'md:w-0',
+ )
+}
+
function SidebarSkeleton({
open,
+ mobileOpen,
apiKeyStatus,
onToggle,
-}: Pick) {
+}: Pick) {
return (
-
- {open ? (
-
+
+ {open || mobileOpen ? (
+
@@ -63,7 +75,7 @@ function SidebarSkeleton({
window.location.assign('/')}
type="button"
>
@@ -113,7 +125,14 @@ function ChatNamesSkeleton() {
)
}
-function SidebarContent({ open, apiKeyStatus, onToggle, sidebarChats }: SidebarProps) {
+function SidebarContent({
+ open,
+ mobileOpen,
+ onMobileClose,
+ apiKeyStatus,
+ onToggle,
+ sidebarChats,
+}: SidebarProps) {
const initialChats = use(sidebarChats)
const pathname = usePathname()
const router = useRouter()
@@ -178,14 +197,9 @@ function SidebarContent({ open, apiKeyStatus, onToggle, sidebarChats }: SidebarP
}
return (
-
- {open ? (
-
+
+ {open || mobileOpen ? (
+
@@ -195,17 +209,26 @@ function SidebarContent({ open, apiKeyStatus, onToggle, sidebarChats }: SidebarP
+
+
+
window.location.assign('/')}
type="button"
>
@@ -214,7 +237,7 @@ function SidebarContent({ open, apiKeyStatus, onToggle, sidebarChats }: SidebarP
{/* Favorites */}
-
+
Favorites
@@ -229,7 +252,7 @@ function SidebarContent({ open, apiKeyStatus, onToggle, sidebarChats }: SidebarP
{/* Recent Chats */}
-
+
Recent Chats
diff --git a/apps/web/components/prompt-box.tsx b/apps/web/components/prompt-box.tsx
index 1b69420..9b21458 100644
--- a/apps/web/components/prompt-box.tsx
+++ b/apps/web/components/prompt-box.tsx
@@ -58,7 +58,8 @@ export function PromptBox({
return (
onStop?.() : undefined}
type={isStreaming ? 'button' : 'submit'}
diff --git a/apps/web/components/ui/dialog.tsx b/apps/web/components/ui/dialog.tsx
index a65a330..3e3ba9b 100644
--- a/apps/web/components/ui/dialog.tsx
+++ b/apps/web/components/ui/dialog.tsx
@@ -54,6 +54,9 @@ function DialogContent({
data-slot="dialog-content"
className={cn(
'fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border bg-background p-6 shadow-lg duration-200 outline-none data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95 sm:max-w-lg',
+ // A phone: a sheet that rises from the bottom, with a grab handle.
+ 'max-md:top-auto max-md:bottom-0 max-md:left-0 max-md:max-w-full max-md:translate-x-0 max-md:translate-y-0 max-md:rounded-t-3xl max-md:rounded-b-none max-md:border-x-0 max-md:border-b-0 max-md:pt-8 max-md:pb-[max(1.5rem,env(safe-area-inset-bottom))] max-md:duration-300 max-md:data-[state=closed]:slide-out-to-bottom max-md:data-[state=closed]:zoom-out-100 max-md:data-[state=open]:slide-in-from-bottom max-md:data-[state=open]:zoom-in-100',
+ 'max-md:before:absolute max-md:before:top-2.5 max-md:before:left-1/2 max-md:before:h-1 max-md:before:w-10 max-md:before:-translate-x-1/2 max-md:before:rounded-full max-md:before:bg-muted-foreground/30',
className,
)}
{...props}
diff --git a/apps/web/components/ui/dropdown-menu.tsx b/apps/web/components/ui/dropdown-menu.tsx
index 8451264..a44007d 100644
--- a/apps/web/components/ui/dropdown-menu.tsx
+++ b/apps/web/components/ui/dropdown-menu.tsx
@@ -61,7 +61,7 @@ function DropdownMenuItem({
data-inset={inset}
data-variant={variant}
className={cn(
- "relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 data-[inset]:pl-8 data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 data-[variant=destructive]:focus:text-destructive dark:data-[variant=destructive]:focus:bg-destructive/20 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground data-[variant=destructive]:*:[svg]:text-destructive!",
+ "relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none max-md:gap-3 max-md:rounded-md max-md:px-3 max-md:py-2.5 max-md:text-[15px] focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 data-[inset]:pl-8 data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 data-[variant=destructive]:focus:text-destructive dark:data-[variant=destructive]:focus:bg-destructive/20 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground data-[variant=destructive]:*:[svg]:text-destructive!",
className,
)}
{...props}
diff --git a/apps/web/lib/icons.ts b/apps/web/lib/icons.ts
index 604d82d..2620080 100644
--- a/apps/web/lib/icons.ts
+++ b/apps/web/lib/icons.ts
@@ -27,6 +27,8 @@ export {
FullscreenClose as FullscreenCloseIcon,
RefreshClockwise as RefreshIcon,
SidebarLeft as SidebarToggleIcon,
+ Menu as MenuIcon,
+ PencilEdit as NewChatIcon,
Coins as CreditsIcon,
Check as CheckIcon,
CheckCircle as CheckCircleIcon,
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 1735d20..a6f635c 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -220,6 +220,9 @@ importers:
'@types/react':
specifier: ^19
version: 19.3.0
+ '@types/react-dom':
+ specifier: ^19
+ version: 19.3.0(@types/react@19.3.0)
'@types/react-test-renderer':
specifier: ^19.0.0
version: 19.3.0
diff --git a/tests/web/docs/architecture.md b/tests/web/docs/architecture.md
index 2239108..7578a3b 100644
--- a/tests/web/docs/architecture.md
+++ b/tests/web/docs/architecture.md
@@ -2,11 +2,12 @@
A test package at `tests/web`. Its lane runs the suite before it builds.
-## Suites (7)
+## Suites (8)
- `design-mode-message.test.tsx`
- `design-mode-route.test.ts`
- `health.test.ts`
+- `mobile-shell.test.tsx`
- `origins.test.ts`
- `preview-design-mode.test.tsx`
- `same-origin.test.ts`
diff --git a/tests/web/package.json b/tests/web/package.json
index 63f4834..42009af 100644
--- a/tests/web/package.json
+++ b/tests/web/package.json
@@ -15,6 +15,7 @@
"@cloudflare/workers-types": "^4.20260701.1",
"@types/node": "^22.9.0",
"@types/react": "^19",
+ "@types/react-dom": "^19",
"@types/react-test-renderer": "^19.0.0",
"@v0-sdk/react": "3.0.12",
"next": "16.3.8",
diff --git a/tests/web/src/mobile-shell.test.tsx b/tests/web/src/mobile-shell.test.tsx
new file mode 100644
index 0000000..bda5cba
--- /dev/null
+++ b/tests/web/src/mobile-shell.test.tsx
@@ -0,0 +1,139 @@
+import { renderToStaticMarkup } from 'react-dom/server'
+import { describe, expect, test, vi } from 'vitest'
+
+// The phone layout, the way a native chat app does it: a drawer for the chats,
+// a top bar with the menu, the title and a new chat, one pane at a time on a
+// chat (Chat | Preview | Code), and a composer that never makes iOS zoom.
+
+vi.mock('next/navigation', () => ({
+ usePathname: () => '/',
+ useRouter: () => ({ push: () => {}, refresh: () => {} }),
+}))
+
+const { AppShell, MobileTopBar } = await import('@/components/layout/app-shell')
+const { PreviewProxyProvider } = await import('@/components/preview/preview-proxy-provider')
+const { TooltipProvider } = await import('@/components/ui/tooltip')
+const { ChatHeader } = await import('@/components/chat/chat-header')
+const { PromptBox } = await import('@/components/prompt-box')
+const { default: manifest } = await import('@/app/manifest')
+
+const apiKeyStatus = { hasBrowserApiKey: false, hasEnvironmentApiKey: true }
+// Already settled, the way React reads a promise it has seen resolve.
+const sidebarChats = Object.assign(
+ Promise.resolve({ favoriteChats: [], recentChats: { chats: [], cursor: null } }),
+ { status: 'fulfilled', value: { favoriteChats: [], recentChats: { chats: [], cursor: null } } },
+)
+
+const classOf = (html: string, pattern: RegExp) => pattern.exec(html)?.[1] ?? ''
+const decode = (html: string) => html.replace(/&/g, '&').replace(/"/g, '"')
+
+describe('the shell on a phone', () => {
+ const html = decode(
+ renderToStaticMarkup(
+
+
+
+
+
+
+ ,
+ ),
+ )
+
+ test('the chats are a drawer, closed at first, beside the page on a wide screen', () => {
+ const aside = classOf(html, /]*class="([^"]*)"/)
+ expect(aside).toContain('fixed')
+ expect(aside).toContain('-translate-x-full')
+ // Out of the tab order and the screen reader while shut, on a phone only.
+ expect(aside).toContain('max-md:invisible')
+ expect(aside).toContain('md:static')
+ expect(aside).toContain('md:translate-x-0')
+ expect(aside).toContain('md:w-64')
+ })
+
+ test('its scrim lets taps through while the drawer is shut', () => {
+ const scrim = classOf(html, / {
+ expect(html).toContain('h-dvh')
+ expect(html).toContain('pt-[env(safe-area-inset-top)]')
+ })
+
+ test('the top bar has the menu, the title and a new chat, on a phone only', () => {
+ const bar = /
([\s\S]*?)<\/header>/.exec(html)!
+ expect(bar[1]).toContain('md:hidden')
+ expect(bar[2]).toContain('aria-label="Open menu"')
+ expect(bar[2]).toContain('My App Builder')
+ expect(bar[2]).toContain('aria-label="New chat"')
+ })
+})
+
+describe('a chat on a phone', () => {
+ const header = (mobilePane: 'chat' | 'preview' | 'code') =>
+ decode(
+ renderToStaticMarkup(
+ {}}
+ onViewChange={() => {}}
+ title="Yoga studio"
+ view="preview"
+ />,
+ ),
+ )
+
+ test('switches between Chat, Preview and Code, the chat first', () => {
+ const html = header('chat')
+ expect([...html.matchAll(/role="tab"[^>]*>([^<]+) m[1])).toEqual([
+ 'Chat',
+ 'Preview',
+ 'Code',
+ ])
+ expect(/aria-selected="true"[^>]*>([^<]+)]*>([^<]+) {
+ const html = header('chat')
+ expect(html).toContain('Yoga studio')
+ expect(html).toContain('aria-label="Chat actions"')
+ })
+})
+
+describe('the composer', () => {
+ const render = (compact: boolean) =>
+ decode(
+ renderToStaticMarkup(
+ {}}
+ onSubmit={() => {}}
+ />,
+ ),
+ )
+
+ test('writes at 16px on a phone, so iOS does not zoom when it takes focus', () => {
+ for (const compact of [false, true]) {
+ const textarea = classOf(render(compact), /