From 3b85e7fbc119f91365be99011e09c93a8855ca3b Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 4 Nov 2026 09:34:03 +0000 Subject: [PATCH] Native on a phone: the v0 clone feels like a chat app On a phone the app now works the way a native chat app does: - The chats are a drawer: the menu button or a swipe from the left edge opens it, the scrim, a swipe back, Escape, the close button or going to another chat shuts it. Shut, it leaves the tab order. A wide screen keeps the sidebar beside the page, as before. - A top bar: menu, the title in the middle, new chat. On a chat, its actions (Publish, Duplicate, Download) sit in one menu, and a Chat | Preview | Code switch shows one pane at a time, the chat first. - Home: the question in the middle, the composer docked at the bottom under the thumb, padded for the home bar. - The composer: 16px text so iOS does not zoom on focus, a rounder box, a round send button; a touch keyboard's return key starts a new line. - 15px chat text and rounder bubbles; bigger rows in the drawer and in menus; chat options visible without hover; dialogs rise from the bottom as sheets; the code pane's files become a row of chips. - The page runs edge to edge (viewport-fit cover, safe-area padding), the keyboard resizes it, no rubber-band or double-tap zoom, no grey tap flash, and a web app manifest so it opens full screen from the home screen. tests/web: mobile-shell.test.tsx covers the drawer, the top bar, the switch, the composer's size and the manifest (adds @types/react-dom). Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_019PcpNWBtvn3y8id6vTP3Yz --- apps/web/app/globals.css | 19 + apps/web/app/layout.tsx | 18 +- apps/web/app/manifest.ts | 16 + .../components/ai-elements/prompt-input.tsx | 4 + .../web/components/chat/chat-conversation.tsx | 2 +- apps/web/components/chat/chat-header.tsx | 370 ++++++++++++------ apps/web/components/chat/chat-workspace.tsx | 22 +- apps/web/components/chat/code-editor.tsx | 14 +- .../web/components/chat/conversation-view.tsx | 6 +- apps/web/components/home/home-client.tsx | 30 +- apps/web/components/layout/app-shell.tsx | 154 +++++++- apps/web/components/layout/chat-item.tsx | 12 +- apps/web/components/layout/sidebar.tsx | 77 ++-- apps/web/components/prompt-box.tsx | 7 +- apps/web/components/ui/dialog.tsx | 3 + apps/web/components/ui/dropdown-menu.tsx | 2 +- apps/web/lib/icons.ts | 2 + pnpm-lock.yaml | 3 + tests/web/docs/architecture.md | 3 +- tests/web/package.json | 1 + tests/web/src/mobile-shell.test.tsx | 139 +++++++ 21 files changed, 715 insertions(+), 189 deletions(-) create mode 100644 apps/web/app/manifest.ts create mode 100644 tests/web/src/mobile-shell.test.tsx 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} -
- -
-
- - + <> + {/* A phone: menu, the chat's title, its actions and a new chat; then the + Chat | Preview | Code switch. */} +
+ {/* Two equal sides, so the title sits in the middle. */} +
+
+ +
+ + {title} + +
+ + + + + + {deploymentUrl ? ( + + + + View deployment + + + ) : ( + { + event.preventDefault() + void publish() + }} + title={error ?? undefined} + > + {isPublishing ? ( + + ) : ( + + )} + {isPublishing ? 'Publishing' : 'Publish'} + + )} + { + event.preventDefault() + void duplicate() + }} + > + {isDuplicating ? ( + + ) : ( + + )} + {isDuplicating ? 'Duplicating' : 'Duplicate'} + + { + event.preventDefault() + void download() + }} + > + {isDownloading ? ( + + ) : ( + + )} + {isDownloading ? 'Downloading' : 'Download'} + + + + +
+ {error || duplicateError ? ( +

+ {error ?? duplicateError} +

+ ) : null} +
+
+ {MOBILE_PANES.map(({ pane, label }) => ( + + ))} +
+
+
-
- - - / - - - - - - +
+
+ + + {title} +
-
- - - - - - { - event.preventDefault() - void duplicate() - }} - title={duplicateError ?? undefined} - > - {isDuplicating ? ( - - ) : ( - - )} - {isDuplicating ? 'Duplicating' : 'Duplicate'} - - { - event.preventDefault() - void download() - }} - title={duplicateError ?? undefined} - > - {isDownloading ? ( - - ) : ( - - )} - {isDownloading ? 'Downloading' : 'Download'} - - - - {deploymentUrl ? ( - - ) : ( +
+ +
+ + - )} + / + + + + + + +
+ +
+ + + + + + { + event.preventDefault() + void duplicate() + }} + title={duplicateError ?? undefined} + > + {isDuplicating ? ( + + ) : ( + + )} + {isDuplicating ? 'Duplicating' : 'Duplicate'} + + { + event.preventDefault() + void download() + }} + title={duplicateError ?? undefined} + > + {isDownloading ? ( + + ) : ( + + )} + {isDownloading ? 'Downloading' : 'Download'} + + + + {deploymentUrl ? ( + + ) : ( + + )} +
-
-
+ + ) } 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 (
-
+
-
+
-