The Open Standard for Generative UI
Add pairwise chat comparison (#797)
Zahle Khan1f14d23bedef
diff --git a/docs/README.md b/docs/README.mdindex b014ab032..332d32d37 100644--- a/docs/README.md+++ b/docs/README.md@@ -17,11 +17,16 @@ pnpm --filter @openuidev/docs devpnpm --filter @openuidev/docs build```-### `/chat` demo configuration+### Chat and comparison demo configuration-The standalone `/chat` page always starts in **OpenUI OSS** mode. Its selected mode is not-stored across reloads. Live OSS generation uses the existing server-side-`OPENROUTER_API_KEY`.+`/chat` remains the standalone OpenUI OSS and Cloud chat and starts in **OpenUI OSS** mode. Its+selected mode is not stored across reloads.++`/compare` compares two visible response modes at a time and defaults to **Rendered Markdown vs+OpenUI Cloud**. Use its page-level switcher to show **Markdown vs OSS** or **OSS vs Cloud**. The+selected pair is stored in the `pair` query parameter. All three comparison providers remain+mounted and receive each shared prompt; switching the visible pair resets the demo. Markdown and+OSS generation use the existing server-side `OPENROUTER_API_KEY`.OpenUI Cloud requires the following server-side variables. If either is missing, Cloud requestsshow the unavailable state at runtime:@@ -32,8 +37,8 @@ THESYS_API_KEY=your-cloud-key```Do not expose `THESYS_API_KEY` through a `NEXT_PUBLIC_*` variable. The browser generates an-anonymous user ID, retains it in `sessionStorage`, and sends it with Cloud requests so persisted-conversations remain scoped to that tab session.+anonymous user ID, retains it in `sessionStorage`, and sends it with Cloud requests. Active+comparison threads are not restored after a refresh.The Cloud feature flag is intentionally fail-closed. Keep it disabled on public deployments untila shared, cross-instance session-and-IP rate limiter, Cloud organization budgets/token scopes, and@@ -71,6 +76,8 @@ docs/│ │ └── theme-builder/ # Theme creator interface│ ││ ├── blog/ # Blog pages+│ ├── chat/ # Standalone OpenUI OSS and Cloud chat+│ ├── compare/ # Pairwise Markdown, OSS, and Cloud comparison│ ├── demo/ # Demo route│ ├── playground/ # Interactive playground│ │diff --git a/docs/app/api/chat/route.ts b/docs/app/api/chat/route.tsindex f197cdf55..4ea8edbbb 100644--- a/docs/app/api/chat/route.ts+++ b/docs/app/api/chat/route.ts@@ -4,7 +4,48 @@ import OpenAI from "openai";import type { ChatCompletionMessageParam } from "openai/resources/chat/completions.mjs";import { join } from "path";-const systemPrompt = readFileSync(join(process.cwd(), "generated/chat-system-prompt.txt"), "utf-8");+const openUiSystemPrompt = readFileSync(+ join(process.cwd(), "generated/chat-system-prompt.txt"),+ "utf-8",+);++const markdownSystemPrompt = `You are a helpful assistant. Respond using clear, well-structured GitHub-Flavored Markdown.++Use headings, lists, tables, links, block quotes, and fenced code blocks when they make the response easier to understand. Use the available tools when they are relevant, and incorporate their results into the answer.++Return only Markdown content. Do not emit OpenUI Lang, component syntax, JSON UI descriptions, or instructions for a renderer.`;++type ResponseMode = "markdown" | "openui";++interface ChatRequestBody {+ messages: unknown[];+ responseMode?: ResponseMode;+}++function invalidRequest(message: string) {+ return Response.json({ error: { message } }, { status: 400 });+}++function parseRequestBody(body: unknown): ChatRequestBody | Response {+ if (!body || typeof body !== "object" || Array.isArray(body)) {+ return invalidRequest("Request body must be a JSON object");+ }++ const { messages, responseMode } = body as Record<string, unknown>;++ if (!Array.isArray(messages)) {+ return invalidRequest("messages must be an array");+ }++ if (responseMode !== undefined && responseMode !== "markdown" && responseMode !== "openui") {+ return invalidRequest('responseMode must be either "markdown" or "openui"');+ }++ return {+ messages,+ responseMode: responseMode as ResponseMode | undefined,+ };+}// ── Tool implementations ──@@ -209,7 +250,19 @@ function sseToolCallArgs(// ── Route handler ──export async function POST(req: NextRequest) {- const { messages } = await req.json();+ let body: unknown;+ try {+ body = await req.json();+ } catch {+ return invalidRequest("Request body must be valid JSON");+ }++ const parsedBody = parseRequestBody(body);+ if (parsedBody instanceof Response) {+ return parsedBody;+ }++ const { messages, responseMode = "openui" } = parsedBody;const apiKey = process.env.OPENROUTER_API_KEY;if (!apiKey) {@@ -226,7 +279,11 @@ export async function POST(req: NextRequest) {const MODEL = "openai/gpt-5.4";const cleanMessages = (messages as any[])- .filter((m) => m.role !== "tool")+ .filter(+ (m) =>+ m.role !== "tool" &&+ (responseMode === "openui" || (m.role !== "system" && m.role !== "developer")),+ ).map((m) => {if (m.role === "assistant" && m.tool_calls?.length) {const { tool_calls: _tc, ...rest } = m;@@ -236,7 +293,10 @@ export async function POST(req: NextRequest) {});const chatMessages: ChatCompletionMessageParam[] = [- { role: "system" as const, content: systemPrompt },+ {+ role: "system" as const,+ content: responseMode === "markdown" ? markdownSystemPrompt : openUiSystemPrompt,+ },...cleanMessages,];diff --git a/docs/app/chat/_components/agent-surfaces/cloud-agent-surface.tsx b/docs/app/chat/_components/agent-surfaces/cloud-agent-surface.tsxindex 562fb6453..03b1194b0 100644--- a/docs/app/chat/_components/agent-surfaces/cloud-agent-surface.tsx+++ b/docs/app/chat/_components/agent-surfaces/cloud-agent-surface.tsx@@ -1,7 +1,8 @@"use client";+import { createCloudChatLLM } from "@/lib/openui-cloud/chat-llm";import { DEFAULT_MODEL } from "@/lib/openui-cloud/models";-import { CLOUD_USER_ID_HEADER } from "@/lib/openui-cloud/user-id";+import { CLOUD_USER_ID_HEADER, getOrCreateCloudUserId } from "@/lib/openui-cloud/user-id";import { defineArtifactCategories } from "@openuidev/react-headless";import { AgentInterface } from "@openuidev/react-ui";import {@@ -12,9 +13,7 @@ import {} from "@openuidev/thesys";import { useCallback, useEffect, useMemo, useState } from "react";import styles from "../../chat-page.module.css";-import { createCloudChatLLM } from "./cloud-chat-llm";import { CloudModelSwitcher } from "./cloud-model-switcher";-import { getOrCreateCloudUserId } from "./cloud-user-id";const { artifactRenderers, artifactCategories } = defineArtifactCategories([{ name: "Presentations", renderers: [presentationArtifactRenderer] },diff --git a/docs/app/chat/_components/agent-surfaces/cloud-user-id.ts b/docs/app/chat/_components/agent-surfaces/cloud-user-id.tsdeleted file mode 100644index a0391545a..000000000--- a/docs/app/chat/_components/agent-surfaces/cloud-user-id.ts+++ /dev/null@@ -1,28 +0,0 @@-import { isCloudUserId } from "@/lib/openui-cloud/user-id";--const CLOUD_USER_ID_STORAGE_KEY = "openui-cloud-user-id";--export function getOrCreateCloudUserId(): string {- const storedUserId = readStoredUserId();- if (isCloudUserId(storedUserId)) return storedUserId;-- const userId = `openui_docs_${crypto.randomUUID()}`;- storeUserId(userId);- return userId;-}--function readStoredUserId(): string | null {- try {- return sessionStorage.getItem(CLOUD_USER_ID_STORAGE_KEY);- } catch {- return null;- }-}--function storeUserId(userId: string): void {- try {- sessionStorage.setItem(CLOUD_USER_ID_STORAGE_KEY, userId);- } catch {- // Continue with the generated ID when browser storage is unavailable.- }-}diff --git a/docs/app/compare/_components/agent-surfaces/cloud-agent-surface.tsx b/docs/app/compare/_components/agent-surfaces/cloud-agent-surface.tsxnew file mode 100644index 000000000..fd65d8217--- /dev/null+++ b/docs/app/compare/_components/agent-surfaces/cloud-agent-surface.tsx@@ -0,0 +1,54 @@+"use client";++import { createCloudChatLLM } from "@/lib/openui-cloud/chat-llm";+import { CLOUD_USER_ID_HEADER, getOrCreateCloudUserId } from "@/lib/openui-cloud/user-id";+import { AgentInterface } from "@openuidev/react-ui";+import { artifactRenderers, chatLibrary, useOpenuiCloudStorage } from "@openuidev/thesys";+import { useMemo, useState } from "react";+import type { ComparisonControllerRegistry } from "../comparison-mode-controller";+import { ComparisonModeControllerBridge } from "../comparison-mode-controller";+import { ComparisonSurfaceWelcome } from "./comparison-surface-welcome";++interface CloudAgentSurfaceProps {+ registry: ComparisonControllerRegistry;+}++export function CloudAgentSurface({ registry }: CloudAgentSurfaceProps) {+ const [userId] = useState(getOrCreateCloudUserId);+ const [llm] = useState(createCloudChatLLM);+ const cloudFetch = useMemo<typeof fetch>(() => {+ return async (input, init) => {+ if (typeof input !== "string" || input !== "/api/openui-cloud/frontend-token") {+ return fetch(input, init);+ }++ const headers = new Headers(init?.headers);+ headers.set(CLOUD_USER_ID_HEADER, userId);+ return fetch(input, { ...init, headers });+ };+ }, [userId]);+ const cloudStorage = useOpenuiCloudStorage({+ token: "/api/openui-cloud/frontend-token",+ fetch: cloudFetch,+ });++ return (+ <div className="chat-agent-surface">+ <AgentInterface+ storage={cloudStorage}+ llm={llm}+ componentLibrary={chatLibrary}+ artifactRenderers={artifactRenderers}+ scrollVariant="always"+ >+ <AgentInterface.Sidebar />+ <AgentInterface.Welcome>+ <ComparisonSurfaceWelcome mode="cloud" />+ </AgentInterface.Welcome>+ <AgentInterface.Composer>+ <ComparisonModeControllerBridge mode="cloud" registry={registry} />+ </AgentInterface.Composer>+ </AgentInterface>+ </div>+ );+}diff --git a/docs/app/compare/_components/agent-surfaces/comparison-surface-welcome.tsx b/docs/app/compare/_components/agent-surfaces/comparison-surface-welcome.tsxnew file mode 100644index 000000000..d7ba7e940--- /dev/null+++ b/docs/app/compare/_components/agent-surfaces/comparison-surface-welcome.tsx@@ -0,0 +1,33 @@+"use client";++import { AlignLeft, Blocks, Sparkles } from "lucide-react";+import styles from "../../chat-page.module.css";+import type { ComparisonMode } from "../comparison-mode-controller";++const CONTENT = {+ markdown: {+ icon: AlignLeft,+ description: "AI responses without OpenUI.",+ },+ oss: {+ icon: Blocks,+ description: "AI responses with OpenUI OSS.",+ },+ cloud: {+ icon: Sparkles,+ description: "AI responses with OpenUI Cloud.",+ },+} as const;++export function ComparisonSurfaceWelcome({ mode }: { mode: ComparisonMode }) {+ const { icon: Icon, description } = CONTENT[mode];++ return (+ <div className={styles.surfaceWelcome}>+ <span className={styles.surfaceWelcomeIcon} aria-hidden="true">+ <Icon size={24} strokeWidth={1.6} />+ </span>+ <p>{description}</p>+ </div>+ );+}diff --git a/docs/app/compare/_components/agent-surfaces/markdown-agent-surface.tsx b/docs/app/compare/_components/agent-surfaces/markdown-agent-surface.tsxnew file mode 100644index 000000000..d9300c1b5--- /dev/null+++ b/docs/app/compare/_components/agent-surfaces/markdown-agent-surface.tsx@@ -0,0 +1,40 @@+"use client";++import { AgentInterface } from "@openuidev/react-ui";+import type { ComparisonControllerRegistry } from "../comparison-mode-controller";+import { ComparisonModeControllerBridge } from "../comparison-mode-controller";+import { ComparisonSurfaceWelcome } from "./comparison-surface-welcome";+import { useComparisonChatLLM } from "./use-comparison-chat-llm";++interface MarkdownAgentSurfaceProps {+ themeMode: "light" | "dark";+ onCreditsExhausted: () => void;+ registry: ComparisonControllerRegistry;+}++export function MarkdownAgentSurface({+ themeMode,+ onCreditsExhausted,+ registry,+}: MarkdownAgentSurfaceProps) {+ const llm = useComparisonChatLLM("markdown", onCreditsExhausted);++ return (+ <div className="chat-agent-surface" data-chat-mode="markdown">+ <AgentInterface+ llm={llm}+ agentName="Markdown"+ scrollVariant="always"+ theme={{ mode: themeMode }}+ >+ <AgentInterface.Sidebar />+ <AgentInterface.Welcome>+ <ComparisonSurfaceWelcome mode="markdown" />+ </AgentInterface.Welcome>+ <AgentInterface.Composer>+ <ComparisonModeControllerBridge mode="markdown" registry={registry} />+ </AgentInterface.Composer>+ </AgentInterface>+ </div>+ );+}diff --git a/docs/app/compare/_components/agent-surfaces/oss-agent-surface.tsx b/docs/app/compare/_components/agent-surfaces/oss-agent-surface.tsxnew file mode 100644index 000000000..f28d9c14c--- /dev/null+++ b/docs/app/compare/_components/agent-surfaces/oss-agent-surface.tsx@@ -0,0 +1,38 @@+"use client";++import { AgentInterface } from "@openuidev/react-ui";+import { openuiChatLibrary } from "@openuidev/react-ui/genui-lib";+import type { ComparisonControllerRegistry } from "../comparison-mode-controller";+import { ComparisonModeControllerBridge } from "../comparison-mode-controller";+import { ComparisonSurfaceWelcome } from "./comparison-surface-welcome";+import { useComparisonChatLLM } from "./use-comparison-chat-llm";++interface OssAgentSurfaceProps {+ themeMode: "light" | "dark";+ onCreditsExhausted: () => void;+ registry: ComparisonControllerRegistry;+}++export function OssAgentSurface({ themeMode, onCreditsExhausted, registry }: OssAgentSurfaceProps) {+ const llm = useComparisonChatLLM("openui", onCreditsExhausted);++ return (+ <div className="chat-agent-surface" data-chat-mode="oss">+ <AgentInterface+ llm={llm}+ componentLibrary={openuiChatLibrary}+ agentName="OpenUI OSS"+ scrollVariant="always"+ theme={{ mode: themeMode }}+ >+ <AgentInterface.Sidebar />+ <AgentInterface.Welcome>+ <ComparisonSurfaceWelcome mode="oss" />+ </AgentInterface.Welcome>+ <AgentInterface.Composer>+ <ComparisonModeControllerBridge mode="oss" registry={registry} />+ </AgentInterface.Composer>+ </AgentInterface>+ </div>+ );+}diff --git a/docs/app/compare/_components/agent-surfaces/use-comparison-chat-llm.ts b/docs/app/compare/_components/agent-surfaces/use-comparison-chat-llm.tsnew file mode 100644index 000000000..ff9ed314c--- /dev/null+++ b/docs/app/compare/_components/agent-surfaces/use-comparison-chat-llm.ts@@ -0,0 +1,54 @@+"use client";++import { isDemoCreditsErrorPayload } from "@/lib/demo-credits";+import { openAIAdapter, openAIMessageFormat, type ChatLLM } from "@openuidev/react-ui";+import { useMemo } from "react";++type ComparisonResponseMode = "markdown" | "openui";++/**+ * Creates the local chat transport shared by the Markdown and OpenUI OSS+ * comparison surfaces while preserving their distinct response modes.+ */+export function useComparisonChatLLM(+ responseMode: ComparisonResponseMode,+ onCreditsExhausted: () => void,+): ChatLLM {+ return useMemo<ChatLLM>(+ () => ({+ send: async ({ messages, signal }) => {+ const response = await fetch("/api/chat", {+ method: "POST",+ headers: { "Content-Type": "application/json" },+ body: JSON.stringify({+ messages: openAIMessageFormat.toApi(messages),+ responseMode,+ }),+ signal,+ });++ if (!response.ok) {+ await notifyIfCreditsAreExhausted(response, onCreditsExhausted);+ }++ return response;+ },+ streamProtocol: openAIAdapter(),+ }),+ [onCreditsExhausted, responseMode],+ );+}++async function notifyIfCreditsAreExhausted(+ response: Response,+ onCreditsExhausted: () => void,+): Promise<void> {+ const errorPayload = await response+ .clone()+ .json()+ .catch(() => ({}));++ if (isDemoCreditsErrorPayload((errorPayload as { error?: unknown }).error)) {+ onCreditsExhausted();+ }+}diff --git a/docs/app/compare/_components/chat-page-header.tsx b/docs/app/compare/_components/chat-page-header.tsxnew file mode 100644index 000000000..fd5ab5926--- /dev/null+++ b/docs/app/compare/_components/chat-page-header.tsx@@ -0,0 +1,554 @@+"use client";++import { ClipboardCommandButton } from "@/app/(home)/components/Button/Button";+import { GitHubButton } from "@/app/(home)/components/GitHubButton/GitHubButton";+import trayStyles from "@/components/site-marketing-header.module.css";+import {+ ArrowLeft,+ ArrowLeftRight,+ ArrowRight,+ Check,+ ChevronDown,+ Menu,+ Moon,+ RotateCcw,+ Sun,+ X,+} from "lucide-react";+import { useTheme } from "next-themes";+import Link from "next/link";+import { useEffect, useRef, useState, type ReactNode } from "react";+import styles from "../chat-page.module.css";+import { getComparisonPair, type ComparisonPair } from "./chat-types";+import type { ComparisonMode } from "./comparison-mode-controller";+import { useHasMounted } from "./use-has-mounted";++// Same runner set and order as the homepage hero's command dropdown.+const CLI_COMMANDS = [+ { id: "pnpm", runner: "pnpx", command: "pnpx @openuidev/cli@latest create" },+ { id: "bun", runner: "bunx", command: "bunx @openuidev/cli@latest create" },+ { id: "yarn", runner: "yarn dlx", command: "yarn dlx @openuidev/cli@latest create" },+ { id: "npm", runner: "npx", command: "npx @openuidev/cli@latest create" },+] as const;++// Display titles for the pair options, mirroring the panel headings: mode name+// plus a chip for the OpenUI flavor. aria-labels keep the canonical names.+interface PairSide {+ label: string;+ chip?: string;+ chipInverted?: boolean;+}++interface PairTitleDefinition {+ left: PairSide;+ right: PairSide;+}++type FeatureSupport = Readonly<Record<ComparisonMode, boolean>>;++interface ComparisonFeature {+ label: string;+ support: FeatureSupport;+}++interface ComparisonPairMetadata {+ description: string;+ title: PairTitleDefinition;+ features: readonly ComparisonFeature[];+}++const ALL_MODES_SUPPORTED: FeatureSupport = { markdown: true, oss: true, cloud: true };+const OSS_AND_CLOUD_SUPPORTED: FeatureSupport = { markdown: false, oss: true, cloud: true };+const CLOUD_ONLY_SUPPORTED: FeatureSupport = { markdown: false, oss: false, cloud: true };+const MARKDOWN_AND_OSS_SUPPORTED: FeatureSupport = { markdown: true, oss: true, cloud: false };++function comparisonFeature(label: string, support: FeatureSupport): ComparisonFeature {+ return { label, support };+}++const CHARTS_FEATURE = comparisonFeature("Charts and data visualizations", OSS_AND_CLOUD_SUPPORTED);+const INTERACTIVE_FEATURE = comparisonFeature(+ "Interactive forms and actions",+ OSS_AND_CLOUD_SUPPORTED,+);+const STREAMING_FEATURE = comparisonFeature("Progressive streaming", ALL_MODES_SUPPORTED);+const RESPONSIVE_OUTPUT_FEATURE = comparisonFeature("Responsive output", OSS_AND_CLOUD_SUPPORTED);+const STYLING_FEATURE = comparisonFeature("Styling and theming", OSS_AND_CLOUD_SUPPORTED);+const REPORTS_FEATURE = comparisonFeature("Reports and presentations", CLOUD_ONLY_SUPPORTED);++const SHARED_OPENUI_FEATURES = [CHARTS_FEATURE, INTERACTIVE_FEATURE, STREAMING_FEATURE] as const;+const MARKDOWN_OSS_FEATURES = [+ ...SHARED_OPENUI_FEATURES,+ RESPONSIVE_OUTPUT_FEATURE,+ STYLING_FEATURE,+] as const;++const PAIR_METADATA: Record<ComparisonPair, ComparisonPairMetadata> = {+ "markdown-oss": {+ description: "Test an AI app with and without OpenUI",+ title: { left: { label: "Markdown" }, right: { label: "OpenUI", chip: "OSS" } },+ features: MARKDOWN_OSS_FEATURES,+ },+ "oss-cloud": {+ description: "Compare open-source and Cloud responses",+ title: {+ left: { label: "OpenUI", chip: "OSS" },+ right: { label: "OpenUI", chip: "Cloud", chipInverted: true },+ },+ features: [+ ...SHARED_OPENUI_FEATURES,+ REPORTS_FEATURE,+ { label: "Built-in tools", support: CLOUD_ONLY_SUPPORTED },+ { label: "Responsive output by default", support: CLOUD_ONLY_SUPPORTED },+ { label: "Automatic UI error correction", support: CLOUD_ONLY_SUPPORTED },+ { label: "Self-hostable and open source", support: MARKDOWN_AND_OSS_SUPPORTED },+ ],+ },+ "markdown-cloud": {+ description: "Test an AI app with and without OpenUI Cloud",+ title: {+ left: { label: "Markdown" },+ right: { label: "OpenUI", chip: "Cloud", chipInverted: true },+ },+ features: [...MARKDOWN_OSS_FEATURES, REPORTS_FEATURE],+ },+};++function PairTitle({ pair }: { pair: ComparisonPair }) {+ const { left, right } = PAIR_METADATA[pair].title;+ const side = (part: PairSide) => (+ <>+ {part.label}+ {part.chip ? (+ <span+ className={`${styles.panelChip} ${+ part.chipInverted ? styles.panelChipInverted : ""+ }`.trim()}+ >+ {part.chip}+ </span>+ ) : null}+ </>+ );++ return (+ <span className={styles.pairTitleGroup}>+ <span className={`${styles.pairTitleSide} ${styles.pairTitleSideLeft}`}>{side(left)}</span>+ <span className={styles.pairTitleVs}>vs</span>+ <span className={styles.pairTitleSide}>{side(right)}</span>+ </span>+ );+}++// Shared open/close behavior for the header dropdowns: hover opens (mouse only,+// with a grace delay so the pointer can cross into the menu), click toggles,+// outside pointer-down and Escape close.+function useHeaderDropdown() {+ const [open, setOpen] = useState(false);+ const wrapRef = useRef<HTMLDivElement | null>(null);+ const triggerRef = useRef<HTMLButtonElement | null>(null);+ const closeTimeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null);++ useEffect(() => {+ return () => {+ if (closeTimeoutRef.current) clearTimeout(closeTimeoutRef.current);+ };+ }, []);++ const cancelScheduledClose = () => {+ if (closeTimeoutRef.current) clearTimeout(closeTimeoutRef.current);+ closeTimeoutRef.current = null;+ };++ const handleHoverOpen = (event: React.PointerEvent) => {+ if (event.pointerType !== "mouse") return;+ cancelScheduledClose();+ setOpen(true);+ };++ const handleHoverClose = (event: React.PointerEvent) => {+ if (event.pointerType !== "mouse") return;+ cancelScheduledClose();+ closeTimeoutRef.current = setTimeout(() => setOpen(false), 160);+ };++ useEffect(() => {+ if (!open) return;++ const handlePointerDown = (event: PointerEvent) => {+ if (!wrapRef.current?.contains(event.target as Node)) setOpen(false);+ };+ const handleKeyDown = (event: KeyboardEvent) => {+ if (event.key === "Escape") {+ setOpen(false);+ triggerRef.current?.focus();+ }+ };++ document.addEventListener("pointerdown", handlePointerDown);+ document.addEventListener("keydown", handleKeyDown);+ return () => {+ document.removeEventListener("pointerdown", handlePointerDown);+ document.removeEventListener("keydown", handleKeyDown);+ };+ }, [open]);++ return { open, setOpen, wrapRef, triggerRef, handleHoverOpen, handleHoverClose };+}++// Menu display order, independent of the default comparison pair.+const PAIR_MENU_ORDER: readonly ComparisonPair[] = ["markdown-oss", "markdown-cloud", "oss-cloud"];+const PAIR_MENU_OPTIONS = PAIR_MENU_ORDER.map((pair) => getComparisonPair(pair));++function PairSwitcher({+ pair,+ onPairChange,+}: {+ pair: ComparisonPair;+ onPairChange: (pair: ComparisonPair) => void;+}) {+ const { open, setOpen, wrapRef, triggerRef, handleHoverOpen, handleHoverClose } =+ useHeaderDropdown();+ const active = getComparisonPair(pair);++ return (+ <div+ className={styles.modeControl}+ ref={wrapRef}+ onPointerEnter={handleHoverOpen}+ onPointerLeave={handleHoverClose}+ >+ <button+ type="button"+ ref={triggerRef}+ className={styles.pairTrigger}+ aria-haspopup="menu"+ aria-expanded={open}+ aria-label={`Change comparison pair (current: ${active.label})`}+ onClick={() => setOpen((value) => !value)}+ >+ <span>Change</span>+ <ArrowLeftRight size={13} strokeWidth={2} aria-hidden="true" />+ </button>++ <div+ className={`${styles.menuOverlay} ${open ? styles.menuOverlayOpen : ""}`.trim()}+ aria-hidden="true"+ />++ <div className={`${styles.pairMenu} ${open ? styles.pairMenuOpen : ""}`.trim()}>+ <div className={styles.pairMenuCard} role="menu" aria-label="Comparison pair">+ {PAIR_MENU_OPTIONS.map((option) => (+ <button+ key={option.id}+ type="button"+ role="menuitemradio"+ aria-checked={option.id === pair}+ className={styles.pairMenuItem}+ onClick={() => {+ onPairChange(option.id);+ setOpen(false);+ }}+ >+ <span className={styles.pairMenuItemTitle}>+ <PairTitle pair={option.id} />+ </span>+ <span className={styles.pairMenuItemDescWrap}>+ <span className={styles.pairMenuItemDesc}>+ {PAIR_METADATA[option.id].description}+ </span>+ </span>+ </button>+ ))}+ </div>+ </div>+ </div>+ );+}++function BuildForFreeMenu() {+ const { open, setOpen, wrapRef, triggerRef, handleHoverOpen, handleHoverClose } =+ useHeaderDropdown();++ return (+ <div+ className={styles.ctaWrap}+ ref={wrapRef}+ onPointerEnter={handleHoverOpen}+ onPointerLeave={handleHoverClose}+ >+ <button+ type="button"+ ref={triggerRef}+ className={styles.ctaButton}+ aria-haspopup="menu"+ aria-expanded={open}+ onClick={() => setOpen((value) => !value)}+ >+ <span>Build for free</span>+ <ArrowRight+ size={15}+ strokeWidth={2}+ aria-hidden="true"+ className={styles.ctaChevron}+ data-open={open}+ />+ </button>++ <div className={`${styles.ctaMenu} ${open ? styles.ctaMenuOpen : ""}`.trim()}>+ <div+ className={styles.ctaMenuCard}+ role="menu"+ aria-label="Copy the setup command for a package manager"+ >+ {CLI_COMMANDS.map((item) => (+ <ClipboardCommandButton+ key={item.id}+ command={item.command}+ className={styles.ctaMenuItem}+ iconContainerClassName={styles.ctaMenuItemIcon}+ copyIconColor="currentColor"+ >+ <span className={styles.ctaMenuItemLabel}>+ <span className={styles.ctaMenuItemRunner}>{item.runner}</span>+ {item.command.slice(item.runner.length)}+ </span>+ </ClipboardCommandButton>+ ))}+ </div>+ </div>+ </div>+ );+}++function SupportIcon({ supported }: { supported: boolean }) {+ return supported ? (+ <Check size={15} strokeWidth={2.25} aria-hidden="true" className={styles.comparisonTick} />+ ) : (+ <X size={15} strokeWidth={2} aria-hidden="true" className={styles.comparisonCross} />+ );+}++function ViewComparisonTray({ pair }: { pair: ComparisonPair }) {+ const { open, setOpen, wrapRef, triggerRef } = useHeaderDropdown();+ const [leftMode, rightMode] = getComparisonPair(pair).modes;+ const { title, features } = PAIR_METADATA[pair];+ const { left, right } = title;++ const columnLabel = (part: PairSide) => (+ <span className={styles.comparisonColumnLabel}>+ {part.chip ? `${part.label} ${part.chip}` : part.label}+ </span>+ );++ return (+ <div className={styles.viewComparison} ref={wrapRef}>+ <div+ className={`${styles.menuOverlay} ${styles.menuOverlayMobileDark} ${+ open ? styles.menuOverlayOpen : ""+ }`.trim()}+ aria-hidden="true"+ />++ <div className={`${styles.comparisonTray} ${open ? styles.comparisonTrayOpen : ""}`.trim()}>+ <div className={styles.comparisonTrayInner}>+ <div className={styles.comparisonTrayCard} aria-label="Feature comparison">+ <div className={`${styles.comparisonRow} ${styles.comparisonHeaderRow}`}>+ {columnLabel(left)}+ <span />+ {columnLabel(right)}+ </div>+ {features.map((feature) => (+ <div key={feature.label} className={styles.comparisonRow}>+ <span className={styles.comparisonIconCell}>+ <SupportIcon supported={feature.support[leftMode]} />+ </span>+ <span className={styles.comparisonFeature}>{feature.label}</span>+ <span className={styles.comparisonIconCell}>+ <SupportIcon supported={feature.support[rightMode]} />+ </span>+ </div>+ ))}+ <Link+ href="/docs/agent/getting-started/openui-cloud"+ prefetch={false}+ className={styles.comparisonCta}+ >+ Learn more about OpenUI Cloud+ <ArrowRight size={15} strokeWidth={2} aria-hidden="true" />+ </Link>+ </div>+ </div>+ </div>++ <button+ type="button"+ ref={triggerRef}+ className={styles.viewComparisonChip}+ aria-expanded={open}+ onClick={() => setOpen((value) => !value)}+ >+ {open ? "Hide comparison" : "View comparison"}+ <ChevronDown+ size={13}+ strokeWidth={2}+ aria-hidden="true"+ className={styles.trayChevron}+ data-open={open}+ />+ </button>+ </div>+ );+}++// Mobile-only hamburger: pair options, reset + theme, and setup commands.+function MobileMenu({+ pair,+ onPairChange,+ onReset,+}: {+ pair: ComparisonPair;+ onPairChange: (pair: ComparisonPair) => void;+ onReset: () => void;+}) {+ const { open, setOpen, wrapRef, triggerRef } = useHeaderDropdown();+ const { resolvedTheme, setTheme } = useTheme();+ const mounted = useHasMounted();+ const isDark = mounted && resolvedTheme === "dark";++ return (+ <div className={styles.mobileMenuWrap} ref={wrapRef}>+ <button+ type="button"+ ref={triggerRef}+ className={styles.mobileMenuButton}+ aria-haspopup="menu"+ aria-expanded={open}+ aria-label="Menu"+ onClick={() => setOpen((value) => !value)}+ >+ {open ? (+ <X size={18} strokeWidth={2} aria-hidden="true" />+ ) : (+ <Menu size={18} strokeWidth={2} aria-hidden="true" />+ )}+ </button>++ {open ? (+ <>+ <div+ className={styles.mobileMenuBackdrop}+ aria-hidden="true"+ onClick={() => setOpen(false)}+ />+ <div className={styles.mobileMenuSheet}>+ <div className={`${trayStyles.mobileTray} ${styles.menuTrayFlush}`}>+ <div className={`${trayStyles.mobileTrayInner} ${styles.menuTrayPad}`}>+ <div className={trayStyles.mobileTraySection} role="menu" aria-label="Comparison">+ <div className={trayStyles.mobileTraySectionHeading}>Comparison</div>+ {PAIR_MENU_OPTIONS.map((option) => {+ const { left, right } = PAIR_METADATA[option.id].title;+ const sideText = (part: PairSide) =>+ part.chip ? `${part.label} ${part.chip}` : part.label;+ return (+ <button+ key={option.id}+ type="button"+ role="menuitemradio"+ aria-checked={option.id === pair}+ className={`${trayStyles.mobileTrayLink} ${styles.menuFlatLink}`}+ onClick={() => {+ onPairChange(option.id);+ setOpen(false);+ }}+ >+ <span className={styles.mobileMenuPairTitle}>+ {sideText(left)} <span className={styles.pairTitleVs}>vs</span>{" "}+ {sideText(right)}+ </span>+ </button>+ );+ })}+ </div>++ <div className={trayStyles.mobileTraySection}>+ <div className={trayStyles.mobileTraySectionHeading}>Preferences</div>+ <button+ type="button"+ className={`${trayStyles.mobileTrayLink} ${styles.menuFlatLink}`}+ onClick={() => {+ onReset();+ setOpen(false);+ }}+ >+ <RotateCcw size={15} strokeWidth={2} aria-hidden="true" />+ <span>Reset chats</span>+ </button>+ <button+ type="button"+ className={`${trayStyles.mobileTrayLink} ${styles.menuFlatLink}`}+ onClick={() => setTheme(isDark ? "light" : "dark")}+ >+ {isDark ? (+ <Sun size={15} strokeWidth={2} aria-hidden="true" />+ ) : (+ <Moon size={15} strokeWidth={2} aria-hidden="true" />+ )}+ <span>{isDark ? "Light mode" : "Dark mode"}</span>+ </button>+ </div>++ <div className={trayStyles.mobileTrayFooter}>+ <GitHubButton+ variant="desktopGlow"+ compact+ href="https://github.com/thesysdev/openui"+ arrow={<ArrowRight size={18} strokeWidth={2} aria-hidden="true" />}+ />+ </div>+ </div>+ </div>+ </div>+ </>+ ) : null}+ </div>+ );+}++interface ChatPageHeaderProps {+ pair: ComparisonPair;+ onPairChange: (pair: ComparisonPair) => void;+ onReset: () => void;+ leftHeading?: ReactNode;+ rightHeading?: ReactNode;+}++export function ChatPageHeader({+ pair,+ onPairChange,+ onReset,+ leftHeading,+ rightHeading,+}: ChatPageHeaderProps) {+ return (+ <header className={styles.header} aria-label="OpenUI chat controls">+ <div className={styles.headerRow}>+ <Link className={styles.backLink} href="/" prefetch={false} aria-label="Back to docs">+ <ArrowLeft aria-hidden="true" size={15} strokeWidth={2} />+ </Link>++ {leftHeading}++ <PairSwitcher pair={pair} onPairChange={onPairChange} />++ {rightHeading}++ <BuildForFreeMenu />++ <MobileMenu pair={pair} onPairChange={onPairChange} onReset={onReset} />+ </div>++ <ViewComparisonTray pair={pair} />+ </header>+ );+}diff --git a/docs/app/compare/_components/chat-types.ts b/docs/app/compare/_components/chat-types.tsnew file mode 100644index 000000000..5bba33de9--- /dev/null+++ b/docs/app/compare/_components/chat-types.ts@@ -0,0 +1,50 @@+import type { ComparisonMode } from "./comparison-mode-controller";++export type ComparisonPair = "markdown-oss" | "oss-cloud" | "markdown-cloud";++export const COMPARISON_PAIR_QUERY_PARAM = "pair";+export const DEFAULT_COMPARISON_PAIR: ComparisonPair = "markdown-cloud";++export interface ComparisonPairOption {+ id: ComparisonPair;+ label: string;+ modes: readonly [ComparisonMode, ComparisonMode];+}++export const COMPARISON_PAIRS: readonly ComparisonPairOption[] = [+ {+ id: "markdown-oss",+ label: "Markdown vs OSS",+ modes: ["markdown", "oss"],+ },+ {+ id: "oss-cloud",+ label: "OSS vs Cloud",+ modes: ["oss", "cloud"],+ },+ {+ id: "markdown-cloud",+ label: "Markdown vs Cloud",+ modes: ["markdown", "cloud"],+ },+] as const;++export const COMPARISON_MODE_LABELS: Record<ComparisonMode, string> = {+ markdown: "Rendered Markdown",+ oss: "OpenUI OSS",+ cloud: "OpenUI Cloud",+};++export function parseComparisonPair(value: string | string[] | null | undefined): ComparisonPair {+ const candidate = Array.isArray(value) ? value[0] : value;+ return COMPARISON_PAIRS.some((option) => option.id === candidate)+ ? (candidate as ComparisonPair)+ : DEFAULT_COMPARISON_PAIR;+}++export function getComparisonPair(pair: ComparisonPair): ComparisonPairOption {+ return (+ COMPARISON_PAIRS.find((option) => option.id === pair) ??+ COMPARISON_PAIRS.find((option) => option.id === DEFAULT_COMPARISON_PAIR)!+ );+}diff --git a/docs/app/compare/_components/compare-page-client.tsx b/docs/app/compare/_components/compare-page-client.tsxnew file mode 100644index 000000000..dd05ce3ee--- /dev/null+++ b/docs/app/compare/_components/compare-page-client.tsx@@ -0,0 +1,408 @@+"use client";++import { DemoCreditsDialog } from "@/components/DemoCreditsDialog";+import { OPENUI_CLOUD_UNAVAILABLE_MESSAGE } from "@/lib/openui-cloud/errors";+import { useTheme } from "next-themes";+import dynamic from "next/dynamic";+import {+ Component,+ useCallback,+ useEffect,+ useState,+ type CSSProperties,+ type KeyboardEvent,+ type ReactNode,+} from "react";+import styles from "../chat-page.module.css";+import { MarkdownAgentSurface } from "./agent-surfaces/markdown-agent-surface";+import { OssAgentSurface } from "./agent-surfaces/oss-agent-surface";+import { ChatPageHeader } from "./chat-page-header";+import {+ COMPARISON_MODE_LABELS,+ COMPARISON_PAIR_QUERY_PARAM,+ DEFAULT_COMPARISON_PAIR,+ getComparisonPair,+ type ComparisonPair,+} from "./chat-types";+import { ComparisonControls } from "./comparison-controls";+import type {+ ComparisonMode,+ ComparisonModeController,+ ComparisonModeSnapshot,+} from "./comparison-mode-controller";+import {+ createComparisonControllerRegistry,+ useComparisonModeSnapshot,+} from "./comparison-mode-controller";++const ALL_MODES = ["markdown", "oss", "cloud"] as const;++const CloudAgentSurface = dynamic(+ () => import("./agent-surfaces/cloud-agent-surface").then((module) => module.CloudAgentSurface),+ {+ ssr: false,+ loading: () => <ChatLoadingState label="Loading OpenUI Cloud…" />,+ },+);++interface SurfaceErrorBoundaryProps {+ children: ReactNode;+ fallbackMessage: string;+ onError?: () => void;+}++class SurfaceErrorBoundary extends Component<SurfaceErrorBoundaryProps, { hasError: boolean }> {+ state = { hasError: false };++ static getDerivedStateFromError() {+ return { hasError: true };+ }++ componentDidCatch() {+ this.props.onError?.();+ }++ render() {+ if (this.state.hasError) {+ return <SurfaceUnavailableState message={this.props.fallbackMessage} />;+ }+ return this.props.children;+ }+}++interface ComparePageClientProps {+ initialPair?: ComparisonPair;+}++export function ComparePageClient({+ initialPair = DEFAULT_COMPARISON_PAIR,+}: ComparePageClientProps) {+ const { resolvedTheme } = useTheme();+ const [pair, setPair] = useState<ComparisonPair>(initialPair);+ const selectedPair = getComparisonPair(pair);+ const [mobileMode, setMobileMode] = useState<(typeof ALL_MODES)[number]>(selectedPair.modes[0]);+ const [isCompact, setIsCompact] = useState(false);+ const [announcement, setAnnouncement] = useState("");+ const [creditsDialogOpen, setCreditsDialogOpen] = useState(false);+ const [unavailableModes, setUnavailableModes] = useState<Set<ComparisonMode>>(() => new Set());+ const [registry] = useState(createComparisonControllerRegistry);+ const themeMode = resolvedTheme === "dark" ? "dark" : "light";++ const markdown = useComparisonModeSnapshot(registry, "markdown");+ const oss = useComparisonModeSnapshot(registry, "oss");+ const cloud = useComparisonModeSnapshot(registry, "cloud");+ const snapshots = { markdown, oss, cloud } as const;+ const availableModeCount = ALL_MODES.length - unavailableModes.size;+ const allReady =+ availableModeCount > 0 &&+ ALL_MODES.every((mode) => unavailableModes.has(mode) || snapshots[mode].isReady);+ const anyRunning = ALL_MODES.some((mode) => snapshots[mode].isRunning);+ const hasStarted = ALL_MODES.some((mode) => snapshots[mode].messageCount > 0);++ useEffect(() => {+ const media = window.matchMedia("(max-width: 900px)");+ const update = () => setIsCompact(media.matches);+ update();+ media.addEventListener("change", update);+ return () => media.removeEventListener("change", update);+ }, []);++ useEffect(() => {+ const url = new URL(window.location.href);+ if (url.searchParams.get(COMPARISON_PAIR_QUERY_PARAM) === pair) return;++ url.searchParams.set(COMPARISON_PAIR_QUERY_PARAM, pair);+ window.history.replaceState(window.history.state, "", url);+ }, [pair]);++ const handleCreditsExhausted = useCallback(() => {+ setCreditsDialogOpen(true);+ }, [setCreditsDialogOpen]);++ const markModeUnavailable = useCallback(+ (mode: ComparisonMode) => {+ setUnavailableModes((current) => {+ if (current.has(mode)) return current;+ const next = new Set(current);+ next.add(mode);+ return next;+ });+ },+ [setUnavailableModes],+ );++ const getRegisteredControllers = useCallback(+ () =>+ ALL_MODES.map((mode) => registry.getController(mode)).filter(+ (controller): controller is ComparisonModeController => controller !== null,+ ),+ [registry],+ );++ const getReadyControllers = useCallback(() => {+ const controllers: ComparisonModeController[] = [];+ for (const mode of ALL_MODES) {+ if (unavailableModes.has(mode)) continue;+ const controller = registry.getController(mode);+ if (!controller) return null;+ controllers.push(controller);+ }+ return controllers.length > 0 ? controllers : null;+ }, [registry, unavailableModes]);++ const submitToAll = useCallback(+ (content: string) => {+ const controllers = getReadyControllers();+ if (!controllers) return;+ const states = controllers.map((controller) => controller.getSnapshot());+ if (states.some((state) => !state.isReady || state.isRunning)) return;++ void Promise.allSettled(controllers.map((controller) => controller.send(content)));+ },+ [getReadyControllers],+ );++ const stopAll = useCallback(() => {+ const controllers = getRegisteredControllers();+ if (controllers.length === 0) return;+ controllers.forEach((controller) => controller.cancel());+ setAnnouncement("Stopped all comparison responses.");+ }, [getRegisteredControllers, setAnnouncement]);++ const resetAll = useCallback(() => {+ const controllers = getRegisteredControllers();+ if (controllers.length === 0) return;+ controllers.forEach((controller) => controller.reset());+ setAnnouncement("All comparison conversations were reset.");+ }, [getRegisteredControllers, setAnnouncement]);++ const requestPairChange = (nextPair: ComparisonPair) => {+ if (nextPair === pair) return;+ const next = getComparisonPair(nextPair);+ setPair(nextPair);+ setMobileMode((current) => (next.modes.includes(current) ? current : next.modes[0]));++ // Switching comparisons starts from a clean slate: abort any streams and+ // clear the demo conversations (no-op when nothing has started yet).+ const controllers = getRegisteredControllers();+ if ((hasStarted || anyRunning) && controllers.length > 0) {+ controllers.forEach((controller) => controller.reset());+ setAnnouncement(`${next.label} selected. The demo was reset.`);+ return;+ }+ setAnnouncement(`${next.label} selected.`);+ };++ const selectAdjacentMobileMode = (event: KeyboardEvent<HTMLButtonElement>) => {+ if (event.key !== "ArrowLeft" && event.key !== "ArrowRight") return;+ event.preventDefault();+ const nextMode =+ mobileMode === selectedPair.modes[0] ? selectedPair.modes[1] : selectedPair.modes[0];+ setMobileMode(nextMode);+ requestAnimationFrame(() => document.getElementById(`comparison-tab-${nextMode}`)?.focus());+ };++ const renderPanelHeading = (mode: ComparisonMode) => (+ <div className={styles.headerPanelHeading}>+ <h2 id={`panel-heading-${mode}`}>+ {MODE_PANEL_HEADINGS[mode].title}+ {MODE_PANEL_HEADINGS[mode].chip ? (+ <span+ className={`${styles.panelChip} ${+ MODE_PANEL_HEADINGS[mode].chipInverted ? styles.panelChipInverted : ""+ }`.trim()}+ >+ {MODE_PANEL_HEADINGS[mode].chip}+ </span>+ ) : null}+ </h2>+ <ModeStatus snapshot={snapshots[mode]} unavailable={unavailableModes.has(mode)} />+ </div>+ );++ return (+ <main className={styles.page}>+ <h1 className={styles.srOnly}>Compare OpenUI response modes</h1>+ <ChatPageHeader+ pair={pair}+ onPairChange={requestPairChange}+ onReset={resetAll}+ leftHeading={renderPanelHeading(selectedPair.modes[0]!)}+ rightHeading={renderPanelHeading(selectedPair.modes[1]!)}+ />++ <div className={styles.comparisonViewport}>+ <div+ className={styles.mobilePanelTabs}+ role="tablist"+ aria-label="Visible comparison panel"+ >+ {selectedPair.modes.map((mode) => (+ <button+ key={mode}+ id={`comparison-tab-${mode}`}+ type="button"+ role="tab"+ className={styles.mobilePanelTab}+ aria-selected={mobileMode === mode}+ aria-controls={`comparison-panel-${mode}`}+ tabIndex={mobileMode === mode ? 0 : -1}+ onClick={() => setMobileMode(mode)}+ onKeyDown={selectAdjacentMobileMode}+ >+ {COMPARISON_MODE_LABELS[mode]}+ <ModeStatusDot snapshot={snapshots[mode]} unavailable={unavailableModes.has(mode)} />+ </button>+ ))}+ </div>++ <div className={styles.panelGrid} data-empty={!hasStarted || undefined}>+ {ALL_MODES.map((mode) => {+ const position = selectedPair.modes.indexOf(mode);+ const inPair = position !== -1;+ const visible = inPair && (!isCompact || mobileMode === mode);+ const snapshot = snapshots[mode];++ return (+ <section+ key={mode}+ id={`comparison-panel-${mode}`}+ role={isCompact ? "tabpanel" : undefined}+ aria-labelledby={isCompact ? `comparison-tab-${mode}` : `panel-heading-${mode}`}+ aria-busy={snapshot.isRunning}+ className={styles.modePanel}+ hidden={!visible}+ data-position={position === 1 ? "second" : "first"}+ style={{ "--comparison-panel-order": Math.max(0, position) } as CSSProperties}+ >+ <div className={styles.panelBody}>+ <SurfaceErrorBoundary+ onError={() => markModeUnavailable(mode)}+ fallbackMessage={+ mode === "cloud"+ ? OPENUI_CLOUD_UNAVAILABLE_MESSAGE+ : `${COMPARISON_MODE_LABELS[mode]} could not be rendered.`+ }+ >+ {mode === "markdown" && (+ <MarkdownAgentSurface+ themeMode={themeMode}+ onCreditsExhausted={handleCreditsExhausted}+ registry={registry}+ />+ )}+ {mode === "oss" && (+ <OssAgentSurface+ themeMode={themeMode}+ onCreditsExhausted={handleCreditsExhausted}+ registry={registry}+ />+ )}+ {mode === "cloud" && <CloudAgentSurface registry={registry} />}+ </SurfaceErrorBoundary>+ {!snapshot.isReady && !snapshot.threadError && !unavailableModes.has(mode) ? (+ <div className={styles.panelLoadingOverlay}>+ <ChatLoadingState label="Loading…" />+ </div>+ ) : null}+ </div>+ </section>+ );+ })}+ </div>++ <ComparisonControls+ comparisonPair={selectedPair.id}+ isReady={allReady}+ isRunning={anyRunning}+ hasStarted={hasStarted}+ onSubmit={submitToAll}+ onStop={stopAll}+ onReset={resetAll}+ isDegraded={unavailableModes.size > 0}+ cloudEnabled={selectedPair.modes.includes("cloud")}+ />+ </div>++ <p className={styles.srOnly} aria-live="polite">+ {announcement}+ </p>+ <p className={styles.srOnly} aria-live="polite" aria-atomic="true">+ {ALL_MODES.map(+ (mode) =>+ `${COMPARISON_MODE_LABELS[mode]} ${getModeStatus(+ snapshots[mode],+ unavailableModes.has(mode),+ )}`,+ ).join(". ")}+ </p>++ <DemoCreditsDialog open={creditsDialogOpen} onClose={() => setCreditsDialogOpen(false)} />+ </main>+ );+}++// Panel heading text: shared product name plus a distinguishing chip. The chip+// lives inside the h2 so the two "OpenUI" panels keep distinct accessible names.+const MODE_PANEL_HEADINGS: Record<+ ComparisonMode,+ { title: string; chip?: string; chipInverted?: boolean }+> = {+ markdown: { title: "Markdown" },+ oss: { title: "OpenUI", chip: "OSS" },+ cloud: { title: "OpenUI", chip: "Cloud", chipInverted: true },+};++function getModeStatus(snapshot: ComparisonModeSnapshot, unavailable = false) {+ if (unavailable || snapshot.threadError) return "error";+ if (!snapshot.isReady) return "loading";+ if (snapshot.isRunning) return "generating";+ return "ready";+}++function ModeStatus({+ snapshot,+ unavailable,+}: {+ snapshot: ComparisonModeSnapshot;+ unavailable: boolean;+}) {+ const status = getModeStatus(snapshot, unavailable);+ if (status !== "error") return null;++ return (+ <span className={styles.panelStatus} data-status={status}>+ <span aria-hidden="true" />+ Error+ </span>+ );+}++function ModeStatusDot({+ snapshot,+ unavailable,+}: {+ snapshot: ComparisonModeSnapshot;+ unavailable: boolean;+}) {+ const status = getModeStatus(snapshot, unavailable);+ if (status !== "error") return null;+ return <span className={styles.mobilePanelStatus} data-status={status} aria-hidden="true" />;+}++function ChatLoadingState({ label }: { label: string }) {+ return (+ <div className={styles.centeredState} role="status">+ <span className={styles.loadingIndicator} aria-hidden="true" />+ <p>{label}</p>+ </div>+ );+}++function SurfaceUnavailableState({ message }: { message: string }) {+ return (+ <div className={styles.centeredState} role="status">+ <p>{message}</p>+ </div>+ );+}diff --git a/docs/app/compare/_components/comparison-controls.tsx b/docs/app/compare/_components/comparison-controls.tsxnew file mode 100644index 000000000..503286369--- /dev/null+++ b/docs/app/compare/_components/comparison-controls.tsx@@ -0,0 +1,272 @@+"use client";++import {+ ArrowRight,+ ArrowUp,+ FileText,+ LayoutDashboard,+ ListChecks,+ Moon,+ Plane,+ Presentation,+ RotateCcw,+ Square,+ Sun,+ TrendingUp,+} from "lucide-react";+import { useTheme } from "next-themes";+import { useLayoutEffect, useRef, useState } from "react";+import styles from "../chat-page.module.css";+import type { ComparisonPair } from "./chat-types";+import { useHasMounted } from "./use-has-mounted";++const COMPARISON_SUGGESTIONS = [+ {+ label: "Exciting stocks to look out for this year",+ prompt:+ "Show me a chart of the top 5 US stocks outperforming the market in 2025 with key trendlines.",+ icon: TrendingUp,+ color: "#067647",+ },+ {+ label: "Hidden travel gems to explore",+ prompt:+ "Give me travel ideas for underrated destinations with notable landmarks and cultural highlights.",+ icon: Plane,+ color: "#dd517b",+ },+ {+ label: "Create an executive dashboard",+ prompt:+ "Visualize following SaaS metrics: MRR $1.28M, growth 8.4%, NRR 112%, churn 2.1%, CAC $740, and pipeline $3.6M. Highlight trends, risks, and the three actions leadership should take.",+ icon: LayoutDashboard,+ color: "#b54708",+ },+ {+ label: "Create an editable launch plan",+ prompt:+ "Create an editable launch plan for a developer tool. Include owner, phase, deadline, status, dependency, and risk. Let me update statuses and show the next three actions.",+ icon: ListChecks,+ color: "#175cd3",+ tag: "Only on Cloud",+ cloudOnly: true,+ pairOnly: "oss-cloud",+ },+ {+ label: "Create a report on Electric vehicles",+ prompt:+ "Create a report on electric vehicles covering adoption trends, key manufacturers, and market outlook.",+ icon: FileText,+ color: "#6941c6",+ tag: "Only on Cloud",+ cloudOnly: true,+ },+ {+ label: "Create a presentation on coffee culture",+ prompt:+ "Create a presentation on global coffee culture covering regions, brewing styles, and cafe trends.",+ icon: Presentation,+ color: "#cd8200",+ tag: "Only on Cloud",+ cloudOnly: true,+ },+] as const;++interface ComparisonControlsProps {+ comparisonPair: ComparisonPair;+ isReady: boolean;+ isRunning: boolean;+ hasStarted: boolean;+ onSubmit: (content: string) => void;+ onStop: () => void;+ onReset: () => void;+ isDegraded: boolean;+ /** Whether the currently selected comparison pair includes OpenUI Cloud. */+ cloudEnabled: boolean;+}++export function ComparisonControls({+ comparisonPair,+ isReady,+ isRunning,+ hasStarted,+ onSubmit,+ onStop,+ onReset,+ isDegraded,+ cloudEnabled,+}: ComparisonControlsProps) {+ const [text, setText] = useState("");+ const inputRef = useRef<HTMLTextAreaElement>(null);+ const { resolvedTheme, setTheme } = useTheme();+ // Theme is unknown until mounted; gate the icon to avoid hydration mismatch.+ const mounted = useHasMounted();+ const isDark = mounted && resolvedTheme === "dark";++ useLayoutEffect(() => {+ const input = inputRef.current;+ if (!input) return;++ const resize = () => {+ input.style.height = "0px";+ input.style.height = `${Math.max(24, Math.min(input.scrollHeight, 154))}px`;+ };++ resize();++ // A zero-width layout (e.g. the page loading in a hidden pane) wraps the+ // content onto one-character lines and locks in a bogus height, so+ // re-measure whenever the field's width changes.+ let lastWidth = input.getBoundingClientRect().width;+ const observer = new ResizeObserver((entries) => {+ const width = entries[0]?.contentRect.width ?? 0;+ if (width === lastWidth) return;+ lastWidth = width;+ resize();+ });+ observer.observe(input);+ return () => observer.disconnect();+ }, [text]);++ const submit = (content: string) => {+ const next = content.trim();+ if (!next || !isReady || isRunning) return;++ onSubmit(next);+ setText("");+ };++ const reset = () => {+ setText("");+ onReset();+ requestAnimationFrame(() => inputRef.current?.focus());+ };++ return (+ <div className={styles.comparisonControls}>+ {!hasStarted && (+ <div className={styles.suggestionScroller} aria-label="Try a comparison prompt">+ <div className={styles.suggestionRow}>+ {COMPARISON_SUGGESTIONS.filter(+ (suggestion) => !("pairOnly" in suggestion) || suggestion.pairOnly === comparisonPair,+ ).map((suggestion) => {+ const SuggestionIcon = suggestion.icon;+ const needsCloud = "cloudOnly" in suggestion && suggestion.cloudOnly;+ return (+ <button+ key={suggestion.label}+ type="button"+ className={styles.suggestionButton}+ onClick={() => submit(suggestion.prompt)}+ disabled={!isReady || isRunning || (needsCloud && !cloudEnabled)}+ title={+ needsCloud && !cloudEnabled+ ? "Switch to a comparison that includes OpenUI Cloud to try this"+ : undefined+ }+ >+ <SuggestionIcon+ size={15}+ strokeWidth={1.9}+ color={suggestion.color}+ aria-hidden="true"+ />+ <span className={styles.suggestionLabel}>+ {suggestion.label}+ <ArrowRight+ size={14}+ strokeWidth={2}+ aria-hidden="true"+ className={styles.suggestionArrow}+ />+ </span>+ {"tag" in suggestion && suggestion.tag ? (+ <span className={styles.suggestionTag}>{suggestion.tag}</span>+ ) : null}+ </button>+ );+ })}+ </div>+ </div>+ )}++ <div className={styles.composerRow}>+ <button+ type="button"+ className={styles.themeToggle}+ aria-label={isDark ? "Switch to light mode" : "Switch to dark mode"}+ title={isDark ? "Switch to light mode" : "Switch to dark mode"}+ onClick={() => setTheme(isDark ? "light" : "dark")}+ >+ {isDark ? (+ <Sun size={17} strokeWidth={2} aria-hidden="true" />+ ) : (+ <Moon size={17} strokeWidth={2} aria-hidden="true" />+ )}+ </button>+ <div className={styles.sharedComposer} data-running={isRunning || undefined}>+ <label className={styles.srOnly} htmlFor="comparison-composer">+ {isDegraded+ ? "Ask all available comparison modes"+ : "Ask Rendered Markdown, OpenUI OSS, and OpenUI Cloud"}+ </label>+ <textarea+ ref={inputRef}+ id="comparison-composer"+ value={text}+ rows={1}+ className={styles.sharedComposerInput}+ placeholder={isReady ? "Ask anything" : "Preparing comparison…"}+ disabled={!isReady}+ onChange={(event) => setText(event.target.value)}+ onKeyDown={(event) => {+ if (event.key === "Enter" && !event.shiftKey) {+ event.preventDefault();+ submit(text);+ }+ }}+ />+ <button+ type="button"+ className={styles.composerSubmit}+ onClick={isRunning ? onStop : () => submit(text)}+ disabled={!isRunning && (!isReady || text.trim().length === 0)}+ aria-label={+ isRunning+ ? "Stop all responses"+ : isDegraded+ ? "Send to available comparison modes"+ : "Send to all three modes"+ }+ >+ {isRunning ? (+ <Square size={16} fill="currentColor" aria-hidden="true" />+ ) : (+ <ArrowUp size={18} aria-hidden="true" />+ )}+ </button>+ </div>++ <button+ type="button"+ className={styles.resetButton}+ onClick={reset}+ aria-label="Reset all comparison conversations"+ title="Reset all conversations"+ >+ <RotateCcw size={17} aria-hidden="true" />+ </button>+ </div>++ {isDegraded ? (+ <p className={styles.degradedNotice} role="status">+ An unavailable mode will be skipped. Reload the page to retry it.+ </p>+ ) : (+ <p className={styles.srOnly}>+ One submission sends the prompt to Rendered Markdown, OpenUI OSS, and OpenUI Cloud.+ </p>+ )}+ </div>+ );+}diff --git a/docs/app/compare/_components/comparison-mode-controller.tsx b/docs/app/compare/_components/comparison-mode-controller.tsxnew file mode 100644index 000000000..16f71a548--- /dev/null+++ b/docs/app/compare/_components/comparison-mode-controller.tsx@@ -0,0 +1,230 @@+"use client";++import { useThread, useThreadList } from "@openuidev/react-headless";+import { useCallback, useEffect, useMemo, useRef, useSyncExternalStore } from "react";++export type ComparisonMode = "markdown" | "oss" | "cloud";++/**+ * The live state a shared comparison composer needs from one AgentInterface.+ * `isReady` means that the mode is mounted and can accept a new user message.+ */+export interface ComparisonModeSnapshot {+ isReady: boolean;+ isRunning: boolean;+ isLoadingMessages: boolean;+ threadError: Error | null;+ messageCount: number;+}++export interface ComparisonModeController {+ readonly mode: ComparisonMode;+ send: (content: string) => Promise<void>;+ cancel: () => void;+ reset: () => void;+ getSnapshot: () => ComparisonModeSnapshot;+ subscribe: (listener: () => void) => () => void;+}++export interface ComparisonControllerRegistry {+ register: (mode: ComparisonMode, controller: ComparisonModeController) => () => void;+ getController: (mode: ComparisonMode) => ComparisonModeController | null;+ getSnapshot: (mode: ComparisonMode) => ComparisonModeSnapshot;+ subscribe: (mode: ComparisonMode, listener: () => void) => () => void;+}++export interface ComparisonModeControllerBridgeProps {+ mode: ComparisonMode;+ registry: ComparisonControllerRegistry;+}++const UNAVAILABLE_SNAPSHOT: ComparisonModeSnapshot = Object.freeze({+ isReady: false,+ isRunning: false,+ isLoadingMessages: false,+ threadError: null,+ messageCount: 0,+});++/**+ * Creates the registry shared by the comparison page and its three mounted+ * AgentInterface instances. Create this once (for example, with useState) so+ * registration is not repeated on every parent render.+ */+export function createComparisonControllerRegistry(): ComparisonControllerRegistry {+ const controllers = new Map<ComparisonMode, ComparisonModeController>();+ const snapshots = new Map<ComparisonMode, ComparisonModeSnapshot>();+ const controllerUnsubscribers = new Map<ComparisonMode, () => void>();+ const listeners = new Map<ComparisonMode, Set<() => void>>();++ const emit = (mode: ComparisonMode) => {+ listeners.get(mode)?.forEach((listener) => listener());+ };++ const unregisterCurrent = (mode: ComparisonMode, controller: ComparisonModeController) => {+ if (controllers.get(mode) !== controller) return;++ controllerUnsubscribers.get(mode)?.();+ controllerUnsubscribers.delete(mode);+ controllers.delete(mode);+ snapshots.delete(mode);+ emit(mode);+ };++ return {+ register(mode, controller) {+ const previousController = controllers.get(mode);+ if (previousController && previousController !== controller) {+ unregisterCurrent(mode, previousController);+ }++ controllers.set(mode, controller);+ snapshots.set(mode, controller.getSnapshot());++ if (previousController !== controller) {+ const unsubscribe = controller.subscribe(() => {+ if (controllers.get(mode) !== controller) return;++ const nextSnapshot = controller.getSnapshot();+ if (snapshots.get(mode) === nextSnapshot) return;++ snapshots.set(mode, nextSnapshot);+ emit(mode);+ });+ controllerUnsubscribers.set(mode, unsubscribe);+ emit(mode);+ }++ let isRegistered = true;+ return () => {+ if (!isRegistered) return;+ isRegistered = false;+ unregisterCurrent(mode, controller);+ };+ },++ getController(mode) {+ return controllers.get(mode) ?? null;+ },++ getSnapshot(mode) {+ return snapshots.get(mode) ?? UNAVAILABLE_SNAPSHOT;+ },++ subscribe(mode, listener) {+ const modeListeners = listeners.get(mode) ?? new Set<() => void>();+ modeListeners.add(listener);+ listeners.set(mode, modeListeners);++ return () => {+ modeListeners.delete(listener);+ if (modeListeners.size === 0) listeners.delete(mode);+ };+ },+ };+}++/** Subscribe a parent coordinator to one mode without mirroring state manually. */+export function useComparisonModeSnapshot(+ registry: ComparisonControllerRegistry,+ mode: ComparisonMode,+): ComparisonModeSnapshot {+ const subscribe = useCallback(+ (listener: () => void) => registry.subscribe(mode, listener),+ [mode, registry],+ );+ const getSnapshot = useCallback(() => registry.getSnapshot(mode), [mode, registry]);++ return useSyncExternalStore(subscribe, getSnapshot, getSnapshot);+}++/**+ * Invisible bridge between one AgentInterface store and the shared comparison+ * controls. Mount it as the child of that interface's AgentInterface.Composer.+ */+export function ComparisonModeControllerBridge({+ mode,+ registry,+}: ComparisonModeControllerBridgeProps) {+ const processMessage = useThread((state) => state.processMessage);+ const cancelMessage = useThread((state) => state.cancelMessage);+ const switchToNewThread = useThreadList((state) => state.switchToNewThread);+ const isRunning = useThread((state) => state.isRunning);+ const isLoadingMessages = useThread((state) => state.isLoadingMessages);+ const threadError = useThread((state) => state.threadError);+ const messageCount = useThread((state) => state.messages.length);++ const currentRef = useRef({+ processMessage,+ cancelMessage,+ switchToNewThread,+ isRunning,+ isLoadingMessages,+ });++ useEffect(() => {+ currentRef.current = {+ processMessage,+ cancelMessage,+ switchToNewThread,+ isRunning,+ isLoadingMessages,+ };+ }, [cancelMessage, isLoadingMessages, isRunning, processMessage, switchToNewThread]);++ const snapshot = useMemo<ComparisonModeSnapshot>(+ () => ({+ isReady: !isLoadingMessages,+ isRunning,+ isLoadingMessages,+ threadError,+ messageCount,+ }),+ [isLoadingMessages, isRunning, messageCount, threadError],+ );+ const snapshotRef = useRef(snapshot);+ const snapshotListenersRef = useRef(new Set<() => void>());++ const send = useCallback(async (content: string) => {+ const current = currentRef.current;+ if (!content.trim() || current.isRunning || current.isLoadingMessages) return;++ await current.processMessage({ role: "user", content });+ }, []);++ const cancel = useCallback(() => {+ currentRef.current.cancelMessage();+ }, []);++ const reset = useCallback(() => {+ // switchToNewThread cancels an active run before clearing the selected+ // thread and messages. Persisted storage records are intentionally kept.+ currentRef.current.switchToNewThread();+ }, []);++ const controller = useMemo<ComparisonModeController>(+ () => ({+ mode,+ send,+ cancel,+ reset,+ getSnapshot: () => snapshotRef.current,+ subscribe: (listener) => {+ snapshotListenersRef.current.add(listener);+ return () => snapshotListenersRef.current.delete(listener);+ },+ }),+ [cancel, mode, reset, send],+ );++ useEffect(() => {+ if (snapshotRef.current === snapshot) return;++ snapshotRef.current = snapshot;+ snapshotListenersRef.current.forEach((listener) => listener());+ }, [snapshot]);++ useEffect(() => registry.register(mode, controller), [controller, mode, registry]);++ return null;+}diff --git a/docs/app/compare/_components/use-has-mounted.ts b/docs/app/compare/_components/use-has-mounted.tsnew file mode 100644index 000000000..b7131987b--- /dev/null+++ b/docs/app/compare/_components/use-has-mounted.ts@@ -0,0 +1,12 @@+"use client";++import { useSyncExternalStore } from "react";++const subscribe = () => () => {};+const getClientSnapshot = () => true;+const getServerSnapshot = () => false;++/** Returns false during SSR and the hydration pass, then true on the client. */+export function useHasMounted() {+ return useSyncExternalStore(subscribe, getClientSnapshot, getServerSnapshot);+}diff --git a/docs/app/compare/chat-page.module.css b/docs/app/compare/chat-page.module.cssnew file mode 100644index 000000000..a1e929082--- /dev/null+++ b/docs/app/compare/chat-page.module.css@@ -0,0 +1,1396 @@+.page {+ display: flex;+ width: 100%;+ height: 100dvh;+ min-width: 0;+ flex-direction: column;+ overflow: hidden;+ color: var(--openui-text-neutral-primary);+ background: var(--openui-background);+}++/* The --home-* surface tokens are re-declared locally because the chat page+ renders outside .homeTheme (same trick as GitHubButton.module.css+ .glowBtnCompact). Declared on the header so the back button, pair switcher,+ and CTA dropdown all share them. */+.header {+ --home-surface-ink: #0a0a0a;+ --home-surface-raised: #f7f7f8;+ --home-bevel:+ inset 0 2px 1px -0.5px rgba(255, 255, 255, 1), inset 0 -3px 6px -1px rgba(0, 0, 0, 0.1);+ --home-bevel-on-dark:+ inset 0 7px 12px -6px rgba(255, 255, 255, 0.16), inset 0 -5px 8px -2px rgba(0, 0, 0, 0.6);+ position: relative;+ z-index: 5;+ flex: none;+ background: var(--openui-foreground);+ padding: 8px;+}++/* "View comparison" tab hanging centered below the top bar. z-index -2 keeps+ it BELOW the pair menu's blur overlay (z -1) in the header's stacking+ context, so it blurs with the page when the Change dropdown is open. */+.viewComparison {+ position: absolute;+ top: 100%;+ right: 0;+ left: 0;+ z-index: -2;+ display: flex;+ width: fit-content;+ margin-inline: auto;+ flex-direction: column;+ align-items: center;+ pointer-events: none;+}++.viewComparisonChip {+ display: inline-flex;+ align-items: center;+ gap: 5px;+ border: 1px solid var(--openui-border-default);+ border-top: 0;+ border-radius: 0 0 10px 10px;+ background: var(--openui-foreground);+ padding: 5px 14px 6px;+ color: var(--openui-text-neutral-secondary);+ font: var(--openui-text-label-xs);+ white-space: nowrap;+ cursor: pointer;+ pointer-events: auto;+ box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);+ transition: color 120ms ease;+}++.viewComparisonChip:hover {+ color: var(--openui-text-neutral-primary);+}++/* While the tray is open, the chip tucks over the card's bottom border so no+ line runs across its top and it reads as part of the tray. */+.comparisonTrayOpen + .viewComparisonChip {+ margin-top: -1px;+}++/* Dark mode, expanded only: the whole tray (card + attached chip) takes the+ "Change" switch's sunken tint — flattened to an OPAQUE color (foreground ++ the same 4% white) so the chip can cover the card's bottom border and no+ stroke crosses its top. */+:global([data-theme="dark"]) .comparisonTrayCard,+:global([data-theme="dark"]) .viewComparisonChip[aria-expanded="true"] {+ background: color-mix(in srgb, var(--openui-foreground) 96%, #fff);+}++.trayChevron,+.ctaChevron {+ transition: transform 160ms ease;+}++.trayChevron[data-open="true"] {+ transform: rotate(180deg);+}++.viewComparisonChip:focus-visible,+.ctaMenuItem:focus-visible {+ outline: 2px solid var(--openui-border-accent-emphasis);+ outline-offset: -2px;+}++/* Comparison tray: slides open above the chip, which rides at its bottom. */+.comparisonTray {+ display: grid;+ width: 26rem;+ max-width: calc(100vw - 24px);+ grid-template-rows: 0fr;+ transition: grid-template-rows 260ms ease;+}++.comparisonTrayOpen {+ grid-template-rows: 1fr;+}++/* Side/bottom padding pulled back with negative margins gives the card's+ shadow room to render inside the overflow clip without shifting layout. */+.comparisonTrayInner {+ overflow: hidden;+ min-height: 0;+ /* Clip window sized to fully contain the card shadow (extent ≈ 24px below,+ 14px to the sides), so it never gets cropped. */+ margin: 0 -36px -36px;+ padding: 0 36px 36px;+}++.comparisonTrayCard {+ display: flex;+ flex-direction: column;+ border: 1px solid var(--openui-border-default);+ /* The header's bottom stroke acts as the tray's top edge. */+ border-top: 0;+ border-radius: 0 0 12px 12px;+ background: var(--openui-foreground);+ box-shadow: 0 10px 24px -10px rgba(0, 0, 0, 0.08);+ padding: 14px;+ /* Hidden while closed so it can't peek through the shadow padding window or+ swallow clicks meant for the page beneath. */+ opacity: 0;+ visibility: hidden;+ pointer-events: none;+ transition:+ opacity 200ms ease,+ visibility 0s linear 200ms;+}++.comparisonTrayOpen .comparisonTrayCard {+ opacity: 1;+ visibility: visible;+ pointer-events: auto;+ transition:+ opacity 200ms ease,+ visibility 0s;+}++.comparisonRow {+ display: grid;+ grid-template-columns: 6rem 1fr 6rem;+ align-items: center;+ padding-block: 9px;+}++/* End-to-end separators between repeated rows. */+.comparisonRow + .comparisonRow,+.pairMenuItem + .pairMenuItem,+.suggestionButton + .suggestionButton {+ border-top: 1px solid var(--openui-border-default);+}++.comparisonHeaderRow {+ padding-block: 11px;+}++.comparisonColumnLabel {+ display: inline-flex;+ align-items: center;+ justify-content: center;+ gap: 6px;+ color: var(--openui-text-neutral-primary);+ font: var(--openui-text-label-sm);+ white-space: nowrap;+}++/* Centre column holds the features; the column sits centred in the tray while+ the text inside stays left-aligned. */+.comparisonFeature {+ color: var(--openui-text-neutral-secondary);+ font: var(--openui-text-body-sm);+ font-size: 0.8125rem;+ text-align: left;+}++.comparisonIconCell {+ display: inline-flex;+ justify-content: center;+}++/* Primary CTA at the tray's base — compact variant. */+.comparisonCta {+ display: flex;+ min-height: 34px;+ align-items: center;+ justify-content: center;+ gap: 6px;+ margin-top: 12px;+ border-radius: 9px;+ background: var(--openui-inverted-background);+ color: var(--openui-background);+ font: var(--openui-text-label-sm);+ text-decoration: none;+ transition: opacity 120ms ease;+}++.comparisonCta:hover,+.ctaButton:hover {+ opacity: 0.88;+}++.comparisonTick {+ color: #12b76a;+}++.comparisonCross {+ color: var(--openui-text-neutral-tertiary);+}++/* Bottom stroke drawn as a child layer (not border-bottom) so it paints above+ the negative-z .menuOverlay and stays sharp while the page blurs. */+.header::after {+ content: "";+ position: absolute;+ right: 0;+ bottom: 0;+ left: 0;+ height: 1px;+ background: var(--openui-border-default);+ pointer-events: none;+}++/* Match the two title columns to the two panel columns. The edge controls are+ positioned independently so their unequal widths cannot skew either title;+ the full-bleed margin cancels the header padding at the panel boundary. */+.headerRow {+ position: relative;+ display: grid;+ min-height: 2.25rem;+ margin-inline: -8px;+ min-width: 0;+ align-items: center;+ grid-template-columns: repeat(2, minmax(0, 1fr));+}++/* Panel title + chip + status, hoisted into the top bar over each panel. */+.headerPanelHeading {+ display: flex;+ min-width: 0;+ align-items: center;+ justify-self: center;+ gap: 12px;+}++.headerPanelHeading h2 {+ display: inline-flex;+ align-items: center;+ gap: 8px;+ margin: 0;+ color: var(--openui-text-neutral-primary);+ font: var(--openui-text-heading-sm);+ font-size: 0.9375rem;+ font-weight: 500;+ white-space: nowrap;+}++.headerRow > .backLink {+ position: absolute;+ left: 8px;+ justify-self: start;+}++.headerRow > .ctaWrap {+ position: absolute;+ right: 8px;+ justify-self: end;+}++/* Icon-only text button. */+.backLink {+ display: inline-flex;+ box-sizing: border-box;+ width: 2.25rem;+ height: 2.25rem;+ flex: none;+ align-items: center;+ justify-content: center;+ border-radius: 10px;+ background: transparent;+ color: var(--openui-text-neutral-primary);+ text-decoration: none;+ transition: background-color 120ms ease;+}++/* Shared hover and keyboard-focus treatment for interactive controls. */+.backLink:hover,+.mobileMenuButton:hover,+.mobileMenuButton[aria-expanded="true"],+.ctaMenuItem:hover,+.resetButton:hover,+.themeToggle:hover {+ background: var(--openui-highlight);+}++.comparisonCta:focus-visible,+.backLink:focus-visible,+.pairTrigger:focus-visible,+.pairMenuItem:focus-visible,+.mobileMenuButton:focus-visible,+.mobilePanelTab:focus-visible,+.suggestionButton:focus-visible,+.composerSubmit:focus-visible,+.resetButton:focus-visible,+.themeToggle:focus-visible {+ outline: 2px solid var(--openui-border-accent-emphasis);+ outline-offset: 2px;+}++/* "Build for free" dropdown — same component recipe as the homepage hero's+ command dropdown (HeroSection.module.css .command*). The --home-* surface+ tokens are re-declared locally because the chat page renders outside+ .homeTheme (same trick as GitHubButton.module.css .glowBtnCompact). */+.ctaWrap {+ position: relative;+ flex: none;+}++/* Text button. */+.ctaButton {+ display: flex;+ box-sizing: border-box;+ height: 2.25rem;+ align-items: center;+ gap: 0.375rem;+ padding-inline: 0.625rem;+ border: 0;+ border-radius: 10px;+ background: var(--home-surface-ink);+ box-shadow: var(--home-bevel-on-dark);+ color: #fff;+ font-family: "Inter", "Segoe UI", sans-serif;+ font-size: 0.9375rem;+ font-weight: 500;+ line-height: 1;+ white-space: nowrap;+ cursor: pointer;+ transition: opacity 120ms ease;+}++.ctaButton:focus-visible {+ outline: 2px solid var(--openui-text-neutral-primary);+ outline-offset: 2px;+}++/* Right arrow tips down while the menu is open. */+.ctaChevron[data-open="true"] {+ transform: rotate(90deg);+}++/* Blurs the page beneath the header while a menu is open. Negative z-index+ keeps it under the header's own background (the top bar stays sharp), while+ the header's stacking context keeps it above the page content. */+.menuOverlay {+ position: fixed;+ inset: 0;+ z-index: -1;+ background: color-mix(in srgb, var(--openui-background) 25%, transparent);+ backdrop-filter: blur(7px);+ opacity: 0;+ visibility: hidden;+ pointer-events: none;+ transition:+ opacity 0.18s ease,+ visibility 0s linear 0.18s;+}++.menuOverlayOpen {+ opacity: 1;+ visibility: visible;+ transition:+ opacity 0.18s ease,+ visibility 0s;+}++/* Darker variant used by the mobile tray; matches the homepage mobile menu's+ backdrop. Inert on desktop. */+.menuOverlayMobileDark,+.mobileMenuBackdrop {+ background: rgb(0 0 0 / 60%);+ backdrop-filter: blur(12px);+}++.menuOverlayMobileDark {+ display: none;+}++:global([data-theme="dark"]) .menuOverlayMobileDark,+:global([data-theme="dark"]) .mobileMenuBackdrop {+ background: rgb(255 255 255 / 0.1);+}++/* Mobile hamburger menu (shown only under the 900px breakpoint). The sheet+ itself reuses the homepage mobile tray component's styles. */+.mobileMenuWrap {+ position: relative;+ display: none;+}++.mobileMenuButton {+ display: grid;+ width: 2.25rem;+ height: 2.25rem;+ place-items: center;+ border: 0;+ border-radius: 10px;+ background: transparent;+ color: var(--openui-text-neutral-primary);+ cursor: pointer;+ transition: background-color 120ms ease;+}++.mobileMenuBackdrop,+.mobileMenuSheet {+ position: fixed;+ top: 53px;+ right: 0;+ left: 0;+}++.mobileMenuBackdrop {+ bottom: 0;+ z-index: 50;+ cursor: pointer;+ animation: chatMobileMenuFade 0.2s ease;+}++.mobileMenuSheet {+ z-index: 60;+ animation: chatMobileMenuSlide 0.2s ease;+}++@keyframes chatMobileMenuFade {+ from {+ opacity: 0;+ }+}++@keyframes chatMobileMenuSlide {+ from {+ opacity: 0;+ transform: translateY(-8px);+ }+}++.mobileMenuPairTitle {+ min-width: 0;+ flex: 1;+}++/* Doubled selectors: these must beat the homepage tray module's rules of+ equal specificity regardless of stylesheet injection order. Layout and+ spacing intentionally come from the homepage module untouched, so the two+ mobile menus stay consistent. */++/* The header's bottom stroke is the only line between bar and sheet. */+.menuTrayFlush.menuTrayFlush {+ border-top: 0;+}++/* A little more air above the first section. */+.menuTrayPad.menuTrayPad {+ padding-top: 1.25rem;+}++/* Slightly roomier rows than the homepage default. */+.menuFlatLink.menuFlatLink {+ min-height: 2.75rem;+ padding-block: 0.5rem;+}++.menuFlatLink.menuFlatLink:hover {+ background: transparent;+}++/* Fade-only reveal, as on the hero. */+.ctaMenu,+.pairMenu {+ position: absolute;+ top: calc(100% + 8px);+ z-index: 60;+ opacity: 0;+ visibility: hidden;+ pointer-events: none;+ transition:+ opacity 0.18s ease,+ visibility 0s linear 0.18s;+}++.ctaMenu {+ right: 0;+ width: 22.5rem;+}++/* Shared dropdown card recipe. */+.ctaMenuCard,+.pairMenuCard {+ display: flex;+ flex-direction: column;+ border: 1px solid var(--openui-border-default);+ border-radius: 12px;+ background: var(--openui-foreground);+ box-shadow: var(--openui-shadow-l);+}++.ctaMenuCard {+ gap: 2px;+ padding: 0.375rem;+}++.ctaMenuItem {+ display: flex;+ width: 100%;+ min-height: 40px;+ align-items: center;+ justify-content: space-between;+ gap: 0.5rem;+ padding: 8px 12px;+ border: 0;+ border-radius: 8px;+ background: transparent;+ color: var(--openui-text-neutral-primary);+ font-size: 0.8125rem;+ line-height: 1.25rem;+ white-space: nowrap;+ cursor: pointer;+ transition: background-color 120ms ease;+}++.ctaMenuItemLabel {+ overflow: hidden;+ text-overflow: ellipsis;+}++.ctaMenuItemRunner {+ font-weight: 600;+ color: var(--openui-text-neutral-primary);+}++/* Copy icon: space reserved, revealed on row hover. */+.ctaMenuItemIcon {+ display: inline-flex;+ width: 1.5rem;+ height: 1.5rem;+ flex-shrink: 0;+ align-items: center;+ justify-content: center;+ color: var(--openui-text-neutral-secondary);+ opacity: 0;+ transition: opacity 0.12s ease;+}++.ctaMenuItem:hover .ctaMenuItemIcon,+.ctaMenuItem:focus-visible .ctaMenuItemIcon {+ opacity: 1;+}++/* Pair switcher dropdown: absolutely centered on the screen, out of the grid,+ so the surrounding headings never push it off-center. Centered via auto+ margins, NOT transform — a transformed ancestor would become the containing+ block for the fixed-position .menuOverlay inside. */+/* No z-index here: a stacking context would trap the negative-z overlay above+ the header's siblings and blur the top bar itself. */+.modeControl {+ position: absolute;+ inset: 0;+ width: fit-content;+ height: fit-content;+ margin: auto;+}++/* Small sunken chip, matching .panelChip. */+.pairTrigger {+ display: inline-flex;+ box-sizing: border-box;+ align-items: center;+ gap: 5px;+ border: 1px solid var(--openui-border-default);+ border-radius: 8px;+ background: var(--openui-sunk);+ padding: 4px 11px;+ color: var(--openui-text-neutral-secondary);+ font: var(--openui-text-label-xs);+ white-space: nowrap;+ cursor: pointer;+ transition:+ color 120ms ease,+ border-color 120ms ease;+}++.pairTrigger:hover,+.pairTrigger[aria-expanded="true"] {+ border-color: var(--openui-text-neutral-secondary);+ color: var(--openui-text-neutral-primary);+}++.pairMenu {+ left: 50%;+ width: 22rem;+ transform: translateX(-50%);+}++.ctaMenuOpen,+.pairMenuOpen {+ opacity: 1;+ visibility: visible;+ pointer-events: auto;+ transition:+ opacity 0.18s ease,+ visibility 0s;+}++.pairMenuCard {+ overflow: hidden;+}++.pairMenuItem {+ position: relative;+ display: flex;+ flex-direction: column;+ align-items: stretch;+ gap: 0;+ border: 0;+ border-radius: 0;+ background: transparent;+ padding: 14px 18px;+ text-align: center;+ cursor: pointer;+ transition: background-color 120ms ease;+}++.pairMenuItemTitle {+ display: flex;+ align-items: center;+ color: var(--openui-text-neutral-primary);+ font: var(--openui-text-label-sm);+}++/* Symmetric grid: "vs" occupies the exact center of every row. */+.pairTitleGroup {+ display: grid;+ width: 100%;+ min-width: 0;+ grid-template-columns: 1fr auto 1fr;+ align-items: center;+ gap: 8px;+}++.pairTitleSide,+.suggestionLabel {+ display: inline-flex;+ min-width: 0;+ align-items: center;+ gap: 6px;+}++.pairTitleSideLeft {+ justify-content: flex-end;+}++.pairTitleVs {+ color: var(--openui-text-neutral-tertiary);+}++/* Description reveals on row hover/focus with a gentle height expansion. */+.pairMenuItemDescWrap {+ display: grid;+ grid-template-rows: 0fr;+ transition: grid-template-rows 220ms ease;+}++.pairMenuItem:hover .pairMenuItemDescWrap,+.pairMenuItem:focus-visible .pairMenuItemDescWrap {+ grid-template-rows: 1fr;+}++.pairMenuItemDesc {+ overflow: hidden;+ min-height: 0;+ padding-top: 5px;+ color: var(--openui-text-neutral-secondary);+ font: var(--openui-text-body-sm);+ font-size: 0.75rem;+}++.comparisonViewport {+ display: flex;+ min-width: 0;+ min-height: 0;+ flex: 1;+ flex-direction: column;+ overflow: hidden;+ background: var(--openui-foreground);+}++.panelGrid {+ display: grid;+ min-width: 0;+ min-height: 0;+ flex: 1;+ grid-template-columns: repeat(2, minmax(0, 1fr));+ overflow: hidden;+}++.modePanel {+ position: relative;+ display: flex;+ min-width: 0;+ min-height: 0;+ order: var(--comparison-panel-order);+ flex-direction: column;+ overflow: hidden;+ background: var(--openui-foreground);+}++.modePanel[hidden] {+ display: none !important;+}++.modePanel[data-position="second"] {+ border-inline-start: 1px solid var(--openui-border-default);+}++/* Empty state: the divider fades out toward the bottom instead of running as+ a hard stroke into the controls area. border-image (not a pseudo-element)+ because the panel's overflow: hidden would clip anything drawn inside it. */+.panelGrid[data-empty] .modePanel[data-position="second"] {+ border-image: linear-gradient(+ to bottom,+ var(--openui-border-default) 30%,+ color-mix(in srgb, var(--openui-border-default) 0%, transparent) 80%+ )+ 1;+}++.panelChip {+ display: inline-flex;+ align-items: center;+ border: 0;+ border-radius: 7px;+ background: var(--openui-sunk);+ padding: 3px 10px;+ color: var(--openui-text-neutral-secondary);+ font: var(--openui-text-label-xs);+ white-space: nowrap;+}++/* Inverted chip (Cloud): ink-on-paper flips with the theme. */+.panelChipInverted {+ background: var(--openui-inverted-background);+ color: var(--openui-background);+}++.panelStatus {+ display: inline-flex;+ align-items: center;+ gap: 6px;+ color: var(--openui-text-neutral-tertiary);+ font: var(--openui-text-label-xs);+}++.panelStatus > span,+.mobilePanelStatus {+ width: 7px;+ height: 7px;+ flex: none;+ border-radius: 50%;+ background: #f04438;+}++.panelBody {+ position: relative;+ display: flex;+ min-width: 0;+ min-height: 0;+ flex: 1;+ overflow: hidden;+}++.panelBody > * {+ width: 100%;+ height: 100%;+ min-width: 0;+ min-height: 0;+}++/* Covers a panel while its surface initializes (e.g. right after switching+ comparisons); the surface stays mounted beneath so controllers register. */+.panelLoadingOverlay {+ position: absolute;+ inset: 0;+ z-index: 3;+ display: flex;+ align-items: center;+ justify-content: center;+ background: var(--openui-foreground);+}++.panelBody :global(.chat-agent-surface),+.panelBody :global(.openui-agent-container) {+ width: 100% !important;+ height: 100% !important;+ min-width: 0 !important;+ min-height: 0 !important;+ overflow: hidden !important;+}++/* Comparison owns all navigation and input chrome. Both internal desktop and+ mobile branches are suppressed because each pane measures its own width. */+.panelBody :global(.openui-agent-sidebar-container),+.panelBody :global(.openui-agent-sidebar-container__overlay),+.panelBody :global(.openui-agent-mobile-header),+.panelBody :global(.openui-agent-thread-header),+.panelBody :global(.openui-agent-composer-slot),+.panelBody :global(.openui-agent-workspace-sidebar),+.panelBody :global(.openui-agent-workspace-sidebar__overlay) {+ display: none !important;+}++.panelBody :global(.openui-agent-thread-container),+.panelBody :global(.openui-agent-thread-wrapper) {+ width: 100% !important;+ min-width: 0 !important;+ min-height: 0 !important;+ flex: 1 1 100% !important;+}++.panelBody :global(.openui-agent-thread-chat-panel) {+ min-width: 0 !important;+ min-height: 0 !important;+}++.panelBody+ :global(+ .openui-agent-thread-container:not(.openui-agent-thread-container--detailed-view-active)+ .openui-agent-thread-chat-panel+ ) {+ width: 100% !important;+ flex: 1 1 100% !important;+}++.panelBody :global(.openui-agent-thread-messages) {+ max-width: none;+ padding-top: 20px;+ padding-inline: 24px;+}++.panelBody :global(.openui-agent-thread-message-assistant) {+ min-width: 0;+ padding-right: 0;+}++.panelBody :global(.openui-agent-thread-message-loading),+.panelBody :global(.openui-agent-thread-error) {+ padding-inline: 24px;+}++.panelBody :global(.openui-agent-thread-scroll-area) {+ overscroll-behavior: contain;+}++.surfaceWelcome {+ display: flex;+ max-width: 560px;+ flex-direction: column;+ align-items: center;+ gap: 22px;+ text-align: center;+}++.surfaceWelcomeIcon {+ display: grid;+ width: 56px;+ height: 56px;+ place-items: center;+ border-radius: 14px;+ color: var(--openui-text-neutral-tertiary);+ background: var(--openui-sunk);+}++.surfaceWelcome p {+ margin: 0;+ color: var(--openui-text-neutral-secondary);+ font: var(--openui-text-body-md);+ font-size: 0.9375rem;+ font-weight: 400;+}++.comparisonControls {+ position: relative;+ z-index: 4;+ flex: none;+ background: var(--openui-foreground);+ padding: 12px 24px max(14px, env(safe-area-inset-bottom));+}++.suggestionScroller {+ width: 100%;+ overflow-x: auto;+ scrollbar-width: none;+}++.suggestionScroller::-webkit-scrollbar {+ display: none;+}++/* Starters: one card with end-to-end separators between rows. Width matches+ the composer input below it. */+.suggestionRow {+ display: flex;+ width: min(100%, 52rem);+ margin-inline: auto;+ margin-bottom: 10px;+ flex-direction: column;+ overflow: hidden;+ border: 1px solid var(--openui-border-default);+ border-radius: 14px;+ background: var(--openui-foreground);+ box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);+}++.suggestionButton {+ display: flex;+ width: 100%;+ min-height: 44px;+ align-items: center;+ gap: 9px;+ border: 0;+ background: transparent;+ padding: 9px 16px;+ color: var(--openui-text-neutral-primary);+ font: var(--openui-text-label-sm);+ text-align: left;+ cursor: pointer;+}++/* Arrow slides in next to the text on hover. */+.suggestionArrow {+ flex: none;+ color: var(--openui-text-neutral-secondary);+ opacity: 0;+ transform: translateX(-4px);+ transition:+ opacity 140ms ease,+ transform 140ms ease;+}++.suggestionButton:hover:not(:disabled) .suggestionArrow,+.suggestionButton:focus-visible .suggestionArrow {+ opacity: 1;+ transform: translateX(0);+}++.suggestionTag {+ display: inline-flex;+ flex: none;+ align-items: center;+ margin-left: auto;+ border-radius: 7px;+ background: var(--openui-sunk);+ padding: 3px 10px;+ color: var(--openui-text-neutral-secondary);+ font: var(--openui-text-label-xs);+ white-space: nowrap;+}++.suggestionButton:disabled {+ opacity: 0.55;+ cursor: not-allowed;+}++/* Inactive rows lose their icon color too. */+.suggestionButton:disabled svg {+ stroke: var(--openui-text-neutral-tertiary);+}++/* The input field spans the full centered column; the reset button hangs+ outside it so the field itself sits dead-centre on the screen. */+.composerRow {+ position: relative;+ display: flex;+ width: min(100%, 52rem);+ align-items: flex-end;+ gap: 10px;+ margin: 0 auto;+}++.sharedComposer {+ display: flex;+ min-width: 0;+ min-height: 54px;+ flex: 1;+ align-items: center;+ gap: 8px;+ border: 1px solid var(--openui-border-default);+ border-radius: 16px;+ background: var(--openui-foreground);+ padding: 5px 5px 5px 16px;+ box-shadow: var(--openui-shadow-s);+ transition:+ border-color 140ms ease,+ box-shadow 140ms ease;+}++.sharedComposer:focus-within {+ border-color: var(--openui-border-interactive-emphasis);+ box-shadow: 0 0 0 3px color-mix(in srgb, var(--openui-border-accent-emphasis) 14%, transparent);+}++.sharedComposer[data-running="true"] {+ border-color: var(--openui-border-interactive-emphasis);+}++.sharedComposerInput {+ width: 100%;+ min-width: 0;+ min-height: 32px;+ max-height: 154px;+ flex: 1;+ resize: none;+ overflow-y: auto;+ border: 0;+ outline: 0;+ background: transparent;+ padding: 5px 0 3px;+ color: var(--openui-text-neutral-primary);+ font: var(--openui-text-body-default);+}++.sharedComposerInput::placeholder {+ color: var(--openui-text-neutral-tertiary);+}++.composerSubmit,+.resetButton {+ display: grid;+ width: 44px;+ height: 44px;+ flex: none;+ place-items: center;+ border: 1px solid var(--openui-border-default);+ border-radius: 12px;+ cursor: pointer;+}++.composerSubmit {+ border-color: var(--openui-text-black);+ background: var(--openui-text-black);+ color: var(--openui-text-white);+}++.composerSubmit:disabled {+ opacity: 0.38;+ cursor: not-allowed;+}++/* Borderless square icon buttons, floated outside the centered column:+ theme toggle on the left, reset on the right. */+.resetButton,+.themeToggle {+ position: absolute;+ bottom: 5px;+ width: 44px;+ height: 44px;+ border: 0;+ border-radius: 10px;+ background: transparent;+ color: var(--openui-text-neutral-primary);+}++.resetButton {+ left: calc(100% + 10px);+}++.themeToggle {+ display: grid;+ right: calc(100% + 10px);+ place-items: center;+ cursor: pointer;+}++.mobilePanelTabs {+ display: none;+}++.degradedNotice {+ margin: 8px 0 0;+ color: var(--openui-text-neutral-tertiary);+ font: var(--openui-text-label-xs);+ text-align: center;+}++.centeredState {+ display: flex;+ width: 100%;+ height: 100%;+ min-height: 220px;+ align-items: center;+ justify-content: center;+ gap: 10px;+ padding: 24px;+ color: var(--openui-text-neutral-secondary);+ background: var(--openui-foreground);+ font: var(--openui-text-body-default);+ text-align: center;+}++.centeredState p {+ margin: 0;+}++.loadingIndicator {+ width: 16px;+ height: 16px;+ flex: none;+ border: 2px solid var(--openui-border-default);+ border-top-color: var(--openui-text-neutral-primary);+ border-radius: 999px;+ animation: chat-loading-spin 700ms linear infinite;+}++@keyframes chat-loading-spin {+ to {+ transform: rotate(360deg);+ }+}++.srOnly {+ position: absolute;+ width: 1px;+ height: 1px;+ padding: 0;+ margin: -1px;+ overflow: hidden;+ clip: rect(0, 0, 0, 0);+ white-space: nowrap;+ border: 0;+}++@media (max-width: 1180px) {+ .ctaWrap {+ display: none;+ }+}++@media (max-width: 900px) {+ .header {+ padding: 8px 12px;+ }++ .headerRow {+ display: flex;+ margin-inline: 0;+ flex-wrap: wrap;+ gap: 6px 12px;+ }++ .headerRow > .backLink {+ position: static;+ }++ /* The Change chip moves into the hamburger menu; View comparison sits in+ the bar beside it. */+ .modeControl {+ display: none;+ }++ .mobileMenuWrap {+ display: flex;+ margin-left: auto;+ }++ /* Starts below the bar (like the hamburger backdrop) so the top bar never+ dims or blurs. */+ .menuOverlayMobileDark {+ display: block;+ top: 53px;+ }++ .viewComparison {+ top: 12px;+ right: 0;+ left: 0;+ z-index: auto;+ margin: 0 auto;+ flex-direction: column-reverse;+ align-items: center;+ }++ /* In the bar the chip looks like the Change switch, not a hanging tab. */+ .viewComparisonChip {+ margin-top: 0;+ border: 1px solid var(--openui-border-default);+ border-radius: 8px;+ background: var(--openui-sunk);+ box-shadow: none;+ }++ .comparisonTrayOpen + .viewComparisonChip {+ margin-top: 0;+ }++ /* The tray detaches from the chip and drops edge to edge below the bar,+ styled like the hamburger sheet. */+ .comparisonTray {+ position: fixed;+ top: 53px;+ right: 0;+ left: 0;+ width: auto;+ max-width: none;+ }++ .comparisonTrayInner {+ margin: 0 0 -36px;+ padding: 0 0 36px;+ }++ .comparisonTrayCard {+ border: 0;+ border-radius: 0 0 28px 28px;+ box-shadow: var(--openui-shadow-xl);+ padding: 1rem 1.25rem 1.5rem;+ }++ /* Narrower icon columns give the feature text room to breathe. */+ .comparisonRow {+ grid-template-columns: 4rem 1fr 4rem;+ }++ /* All starter rows share one height, content top-aligned; tagged ones+ stack label over tag and fill the band with symmetric padding. */+ .suggestionButton {+ min-height: 64px;+ align-content: flex-start;+ align-items: flex-start;+ padding-block: 12px;+ }++ /* Optically centre the icon against the first text line. */+ .suggestionButton > svg:first-child {+ margin-top: 3px;+ }++ /* Tagged starters: full-width text line, tag dropped underneath (aligned+ with the text, past the icon indent). */+ .suggestionButton:has(.suggestionTag) {+ flex-wrap: wrap;+ row-gap: 2px;+ }++ .suggestionButton:has(.suggestionTag)::after {+ content: "";+ order: 1;+ flex-basis: 100%;+ }++ .suggestionLabel {+ flex: 1;+ }++ /* Plain gray text on mobile instead of a chip. */+ .suggestionTag {+ order: 2;+ margin-left: 24px;+ border-radius: 0;+ background: transparent;+ padding: 0;+ color: var(--openui-text-neutral-secondary);+ }++ .mobilePanelTabs {+ display: flex;+ min-height: 48px;+ flex: none;+ border-bottom: 1px solid var(--openui-border-default);+ background: var(--openui-foreground);+ padding: 4px 8px 0;+ }++ .mobilePanelTab {+ position: relative;+ display: flex;+ min-width: 0;+ min-height: 44px;+ flex: 1;+ align-items: center;+ justify-content: center;+ gap: 8px;+ border: 0;+ border-bottom: 2px solid transparent;+ background: transparent;+ color: var(--openui-text-neutral-secondary);+ font: var(--openui-text-label-sm);+ cursor: pointer;+ }++ .mobilePanelTab[aria-selected="true"] {+ border-bottom-color: var(--openui-text-neutral-primary);+ color: var(--openui-text-neutral-primary);+ }++ .panelGrid {+ display: flex;+ }++ .modePanel {+ width: 100%;+ flex: 1;+ }++ .modePanel[data-position="second"] {+ border-inline-start: 0;+ }++ .headerPanelHeading {+ display: none;+ }++ .panelBody :global(.openui-agent-thread-messages),+ .panelBody :global(.openui-agent-thread-message-loading),+ .panelBody :global(.openui-agent-thread-error) {+ padding-inline: 16px;+ }++ /* No floating panel header below 900px, so no clearance needed. */+ .panelBody :global(.openui-agent-thread-messages) {+ padding-top: 0;+ }++ .comparisonControls {+ padding: 10px 12px max(10px, env(safe-area-inset-bottom));+ }++ /* Reset and theme live in the hamburger menu; the input takes the full+ width of the controls area. */+ .resetButton,+ .themeToggle {+ display: none;+ }+}++@media (max-width: 560px) {+ .suggestionButton {+ padding-inline: 12px;+ }++ .sharedComposer {+ min-height: 50px;+ padding-left: 13px;+ }++ .surfaceWelcome {+ gap: 16px;+ }++ .surfaceWelcomeIcon {+ width: 48px;+ height: 48px;+ }+}++@media (prefers-reduced-motion: reduce) {+ .ctaButton,+ .ctaChevron,+ .ctaMenu,+ .ctaMenuItem,+ .menuOverlay,+ .comparisonTray,+ .comparisonTrayCard,+ .trayChevron,+ .viewComparisonChip,+ .pairMenuItemDescWrap,+ .suggestionButton,+ .sharedComposer {+ transition: none;+ }++ .mobileMenuBackdrop,+ .mobileMenuSheet,+ .loadingIndicator {+ animation: none;+ }+}diff --git a/docs/app/compare/layout.tsx b/docs/app/compare/layout.tsxnew file mode 100644index 000000000..62d083a86--- /dev/null+++ b/docs/app/compare/layout.tsx@@ -0,0 +1,6 @@+import { WebsiteThemeProvider } from "@/components/website-theme-provider";+import type { ReactNode } from "react";++export default function CompareLayout({ children }: { children: ReactNode }) {+ return <WebsiteThemeProvider>{children}</WebsiteThemeProvider>;+}diff --git a/docs/app/compare/page.tsx b/docs/app/compare/page.tsxnew file mode 100644index 000000000..2ca6504be--- /dev/null+++ b/docs/app/compare/page.tsx@@ -0,0 +1,16 @@+import type { Metadata } from "next";+import { parseComparisonPair } from "./_components/chat-types";+import { ComparePageClient } from "./_components/compare-page-client";++export const metadata: Metadata = {+ title: "Compare OpenUI",+ description: "Compare rendered Markdown, OpenUI OSS, and OpenUI Cloud side by side.",+ alternates: {+ canonical: "/compare",+ },+};++export default async function ComparePage(props: PageProps<"/compare">) {+ const searchParams = await props.searchParams;+ return <ComparePageClient initialPair={parseComparisonPair(searchParams.pair)} />;+}diff --git a/docs/app/layout.tsx b/docs/app/layout.tsxindex ec7cb3a06..83016d89a 100644--- a/docs/app/layout.tsx+++ b/docs/app/layout.tsx@@ -89,17 +89,17 @@ export default function Layout({ children }: LayoutProps<"/">) {<PHProvider><RootProvider theme={{ defaultTheme: "light" }}>{children}</RootProvider></PHProvider>+ <Script+ src="https://www.googletagmanager.com/gtag/js?id=G-MZ0TZ82NM2"+ strategy="afterInteractive"+ />+ <Script id="ga-init" strategy="afterInteractive">{`+ window.dataLayer = window.dataLayer || [];+ function gtag(){dataLayer.push(arguments);}+ gtag('js', new Date());+ gtag('config', 'G-MZ0TZ82NM2');+ `}</Script></body>- <Script- src="https://www.googletagmanager.com/gtag/js?id=G-MZ0TZ82NM2"- strategy="afterInteractive"- />- <Script id="ga-init" strategy="afterInteractive">{`- window.dataLayer = window.dataLayer || [];- function gtag(){dataLayer.push(arguments);}- gtag('js', new Date());- gtag('config', 'G-MZ0TZ82NM2');- `}</Script></html>);}diff --git a/docs/app/sitemap.ts b/docs/app/sitemap.tsindex 127621a3c..a8a31298f 100644--- a/docs/app/sitemap.ts+++ b/docs/app/sitemap.ts@@ -1,6 +1,6 @@import { BASE_URL, blog, source } from "@/lib/source";-const STATIC_PATHS = ["/", "/playground", "/chat", "/blog"];+const STATIC_PATHS = ["/", "/playground", "/compare", "/chat", "/blog"];export default async function sitemap() {const staticRoutes = STATIC_PATHS.map((path) => ({diff --git a/docs/components/site-primary-nav.tsx b/docs/components/site-primary-nav.tsxindex 440bdfd7f..0dbe18b03 100644--- a/docs/components/site-primary-nav.tsx+++ b/docs/components/site-primary-nav.tsx@@ -41,6 +41,11 @@ export const PRIMARY_SITE_NAV_ITEMS: NavItem[] = [description: "Try OpenUI OSS and Cloud in a live chat.",href: "/chat",},+ {+ title: "Compare OpenUI",+ description: "Compare Markdown, OpenUI OSS, and Cloud side by side.",+ href: "/compare",+ },{title: "Dashboard Demo",description: "Testdrive a dashboard building experience.",diff --git a/docs/app/chat/_components/agent-surfaces/cloud-chat-llm.ts b/docs/lib/openui-cloud/chat-llm.tssimilarity index 100%rename from docs/app/chat/_components/agent-surfaces/cloud-chat-llm.tsrename to docs/lib/openui-cloud/chat-llm.tsdiff --git a/docs/lib/openui-cloud/user-id.ts b/docs/lib/openui-cloud/user-id.tsindex b35f50e61..08f7871be 100644--- a/docs/lib/openui-cloud/user-id.ts+++ b/docs/lib/openui-cloud/user-id.ts@@ -1,5 +1,6 @@export const CLOUD_USER_ID_HEADER = "x-openui-cloud-user-id";+const CLOUD_USER_ID_STORAGE_KEY = "openui-cloud-user-id";const CLOUD_USER_ID_PATTERN =/^openui_docs_[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/;@@ -12,3 +13,29 @@ export function readCloudUserId(request: Request): string | null {const userId = request.headers.get(CLOUD_USER_ID_HEADER);return isCloudUserId(userId) ? userId : null;}++/** Return the anonymous Cloud user ID retained for this browser session. */+export function getOrCreateCloudUserId(): string {+ const storedUserId = readStoredUserId();+ if (isCloudUserId(storedUserId)) return storedUserId;++ const userId = `openui_docs_${crypto.randomUUID()}`;+ storeUserId(userId);+ return userId;+}++function readStoredUserId(): string | null {+ try {+ return sessionStorage.getItem(CLOUD_USER_ID_STORAGE_KEY);+ } catch {+ return null;+ }+}++function storeUserId(userId: string): void {+ try {+ sessionStorage.setItem(CLOUD_USER_ID_STORAGE_KEY, userId);+ } catch {+ // Continue with the generated ID when browser storage is unavailable.+ }+}