Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
TypeScript agentic-aiagentsaiai-agentsaiagentsdeveloper-toolsfunction-callinggpt-4javascriptjsllmllmopsmcppythonremote-mcp-serverssetypescript
Codex's first pass
Brendan O'Learyd2fb7defda2d
diff --git a/docs/app/(home)/docs/layout.tsx b/docs/app/(home)/docs/layout.tsxindex ea2e3b5a2..583018819 100644--- a/docs/app/(home)/docs/layout.tsx+++ b/docs/app/(home)/docs/layout.tsx@@ -1,8 +1,6 @@import { source } from '@/lib/source';-import { DocsLayout } from 'fumadocs-ui/layouts/docs';-import { decorateSidebarBadges } from '@/lib/decorate-sidebar-badges';-import { buildSidebarNavIndex } from '@/lib/sidebar-nav-index';-import { SidebarAnalytics } from '@/components/sidebar-analytics';+import { ProductDocsLayout } from '@/components/product-docs-layout';+import { buildProductPageTree } from '@/lib/product-page-tree';interface BadgeFrontmatter {experimental?: boolean;@@ -17,20 +15,19 @@ const newUrls = new Set(pages.filter((page) => (page.data as BadgeFrontmatter).isNew).map((page) => page.url),);-const tree = decorateSidebarBadges(source.pageTree, experimentalUrls, newUrls);-const navIndex = buildSidebarNavIndex(tree);+const trees = {+ 'for-you': buildProductPageTree(source.pageTree, 'for-you'),+ platform: buildProductPageTree(source.pageTree, 'platform'),+};export default function Layout({ children }: LayoutProps<'/docs'>) {return (- <DocsLayout- tree={tree}- nav={{ enabled: true, title: null }}- sidebar={{ collapsible: false, footer: null, tabs: false }}- themeSwitch={{ enabled: false }}- searchToggle={{ enabled: false }}+ <ProductDocsLayout+ experimentalUrls={[...experimentalUrls]}+ newUrls={[...newUrls]}+ trees={trees}>- <SidebarAnalytics index={navIndex} />{children}- </DocsLayout>+ </ProductDocsLayout>);}diff --git a/docs/app/(home)/layout.tsx b/docs/app/(home)/layout.tsxindex bd15310d6..c0b0b789a 100644--- a/docs/app/(home)/layout.tsx+++ b/docs/app/(home)/layout.tsx@@ -1,12 +1,25 @@import { HomeLayout } from 'fumadocs-ui/layouts/home';+import { headers } from 'next/headers';import { baseOptions } from '@/lib/layout.shared';import { EveChatMount } from '@/components/eve-chat-mount';+import { DocsProductProvider } from '@/components/docs-product-context';+import {+ DEFAULT_DOCS_PRODUCT,+ DOCS_PRODUCT_HEADER,+ parseDocsProduct,+} from '@/lib/home-navigation';++export default async function Layout({ children }: LayoutProps<'/'>) {+ const requestHeaders = await headers();+ const initialProduct =+ parseDocsProduct(requestHeaders.get(DOCS_PRODUCT_HEADER)) ?? DEFAULT_DOCS_PRODUCT;-export default function Layout({ children }: LayoutProps<'/'>) {return (- <HomeLayout {...baseOptions()}>- {children}- <EveChatMount />- </HomeLayout>+ <DocsProductProvider initialProduct={initialProduct}>+ <HomeLayout {...baseOptions()}>+ {children}+ <EveChatMount />+ </HomeLayout>+ </DocsProductProvider>);}diff --git a/docs/app/global.css b/docs/app/global.cssindex c46678bfb..04b736a3b 100644--- a/docs/app/global.css+++ b/docs/app/global.css@@ -425,7 +425,7 @@ a:focus-visible {}/* Hide empty sidebar header when no title is set */-#nd-sidebar > div:first-child:has(a:empty) {+#nd-sidebar > div:first-child:has(a:empty):not(:has(.docs-product-switcher)) {display: none;}@@ -1179,3 +1179,70 @@ html:not(.dark) .terminal-theme-claude {outline: 2px solid light-dark(rgb(0 0 0 / 0.2), rgb(255 255 255 / 0.25));outline-offset: 1px;}++/* Product switching is the only navigation that receives a named transition.+ The origin is measured from the switcher trigger before navigation. */+html.docs-product-transition .docs-product-shell {+ view-transition-name: docs-product-shell;+}++::view-transition-old(docs-product-shell) {+ animation: none;+ z-index: 1;+}++::view-transition-new(docs-product-shell) {+ animation: 700ms cubic-bezier(0.785, 0.135, 0.15, 0.86) both docs-circle-reveal;+ clip-path: circle(var(--docs-reveal-radius) at var(--docs-reveal-x) var(--docs-reveal-y));+ z-index: 2;+ --docs-reveal-radius: 0%;+ --docs-pixel-size: 20;+ --docs-dissolve-amount: 0.65;+}++@supports (background: paint(docs-pixelated-circle)) {+ ::view-transition-new(docs-product-shell) {+ clip-path: none;+ mask-image: paint(docs-pixelated-circle);+ }+}++@property --docs-reveal-radius {+ syntax: '<percentage>';+ initial-value: 0%;+ inherits: false;+}++@property --docs-pixel-size {+ syntax: '<number>';+ initial-value: 20;+ inherits: false;+}++@property --docs-dissolve-amount {+ syntax: '<number>';+ initial-value: 0.65;+ inherits: false;+}++@keyframes docs-circle-reveal {+ from {+ --docs-reveal-radius: 0%;+ }+ to {+ --docs-reveal-radius: 150%;+ }+}++@media (prefers-reduced-motion: reduce) {+ html.docs-product-transition .docs-product-shell {+ view-transition-name: none;+ }++ ::view-transition-old(docs-product-shell),+ ::view-transition-new(docs-product-shell) {+ animation: none;+ clip-path: none;+ mask-image: none;+ }+}diff --git a/docs/app/layout.tsx b/docs/app/layout.tsxindex 7592d0296..bbd9955d1 100644--- a/docs/app/layout.tsx+++ b/docs/app/layout.tsx@@ -9,6 +9,7 @@ import CustomSearchDialog from '@/components/custom-search-dialog';import { ScrollReset } from '@/components/scroll-reset';import { source, referenceSource } from '@/lib/source';import { TOOLKIT_COUNT_LABEL } from '@/lib/toolkit-count';+import { ProductTransitionLoader } from '@/components/product-transition-loader';const defaultLinkSlugs: { slug: string[]; source: typeof source }[] = [{ slug: ['quickstart'], source },@@ -111,6 +112,7 @@ export default function Layout({ children }: LayoutProps<'/'>) {</head><body className="flex flex-col min-h-dvh font-sans"><ScrollReset />+ <ProductTransitionLoader /><Analytics /><PostHogProvider><RootProviderdiff --git a/docs/components/docs-product-context.tsx b/docs/components/docs-product-context.tsxnew file mode 100644index 000000000..4fd74415d--- /dev/null+++ b/docs/components/docs-product-context.tsx@@ -0,0 +1,178 @@+'use client';++import {+ createContext,+ useCallback,+ useContext,+ useEffect,+ useMemo,+ useRef,+ useState,+ type ReactNode,+} from 'react';+import { flushSync } from 'react-dom';+import { usePathname, useRouter } from 'next/navigation';+import { useTheme } from 'fumadocs-ui/provider/base';+import {+ classifyDocsProduct,+ DOCS_PRODUCTS,+ serializeDocsProductCookie,+ shouldAnimateDocsProductSwitch,+ type DocsProduct,+} from '@/lib/home-navigation';++interface DocsProductContextValue {+ product: DocsProduct;+ navigateToProduct: (+ product: DocsProduct,+ href: string,+ origin?: HTMLElement | null,+ ) => void;+ persistProduct: (product: DocsProduct) => void;+}++interface ViewTransitionHandle {+ finished: Promise<void>;+}++type ViewTransitionDocument = Document & {+ startViewTransition?: (+ update: () => void | Promise<void>,+ ) => ViewTransitionHandle;+};++const DocsProductContext = createContext<DocsProductContextValue | null>(null);++function writeProductCookie(product: DocsProduct): void {+ document.cookie = serializeDocsProductCookie(product);+}++export function DocsProductProvider({+ initialProduct,+ children,+}: {+ initialProduct: DocsProduct;+ children: ReactNode;+}) {+ const pathname = usePathname();+ const router = useRouter();+ const { setTheme } = useTheme();+ const [persistedProduct, setPersistedProduct] = useState(initialProduct);+ const [pendingProduct, setPendingProduct] = useState<DocsProduct | null>(null);+ const pendingNavigation = useRef<{+ from: string;+ resolve: () => void;+ } | null>(null);++ const inferredProduct = classifyDocsProduct(pathname);+ const product = pendingProduct ?? inferredProduct ?? persistedProduct;++ const persistProduct = useCallback((nextProduct: DocsProduct) => {+ writeProductCookie(nextProduct);+ setPersistedProduct(nextProduct);+ }, []);++ useEffect(() => {+ if (inferredProduct) {+ writeProductCookie(inferredProduct);+ }++ if (pendingNavigation.current && pendingNavigation.current.from !== pathname) {+ pendingNavigation.current.resolve();+ pendingNavigation.current = null;+ }++ const frame = window.requestAnimationFrame(() => {+ if (inferredProduct) setPersistedProduct(inferredProduct);+ setPendingProduct(null);+ });+ return () => window.cancelAnimationFrame(frame);+ }, [inferredProduct, pathname]);++ useEffect(() => {+ return () => {+ pendingNavigation.current?.resolve();+ pendingNavigation.current = null;+ document.documentElement.classList.remove('docs-product-transition');+ };+ }, []);++ const navigateToProduct = useCallback(+ (nextProduct: DocsProduct, href: string, origin?: HTMLElement | null) => {+ const commitNavigation = () => {+ writeProductCookie(nextProduct);+ flushSync(() => {+ setPersistedProduct(nextProduct);+ setPendingProduct(nextProduct);+ setTheme(DOCS_PRODUCTS[nextProduct].defaultTheme);+ });+ router.push(href);+ };++ const viewTransitionDocument = document as ViewTransitionDocument;+ const reduceMotion = window.matchMedia('(prefers-reduced-motion: reduce)').matches;+ const startViewTransition =+ viewTransitionDocument.startViewTransition?.bind(viewTransitionDocument);+ const shouldAnimate = shouldAnimateDocsProductSwitch(+ typeof startViewTransition === 'function',+ reduceMotion,+ );++ if (!shouldAnimate || !startViewTransition) {+ commitNavigation();+ return;+ }++ const root = document.documentElement;+ const rect = origin?.getBoundingClientRect();+ root.style.setProperty('--docs-reveal-x', `${rect ? rect.left + rect.width / 2 : 32}px`);+ root.style.setProperty('--docs-reveal-y', `${rect ? rect.top + rect.height / 2 : 32}px`);+ root.classList.add('docs-product-transition');++ let cleaned = false;+ const cleanup = () => {+ if (cleaned) return;+ cleaned = true;+ root.classList.remove('docs-product-transition');+ root.style.removeProperty('--docs-reveal-x');+ root.style.removeProperty('--docs-reveal-y');+ };+ window.setTimeout(cleanup, 6000);++ try {+ const transition = startViewTransition(() => {+ return new Promise<void>(resolve => {+ pendingNavigation.current?.resolve();+ const timeout = window.setTimeout(resolve, 5000);+ pendingNavigation.current = {+ from: pathname,+ resolve: () => {+ window.clearTimeout(timeout);+ resolve();+ },+ };+ commitNavigation();+ });+ });+ void transition.finished.catch(() => undefined).finally(cleanup);+ } catch {+ cleanup();+ commitNavigation();+ }+ },+ [pathname, router, setTheme],+ );++ const value = useMemo(+ () => ({ product, navigateToProduct, persistProduct }),+ [navigateToProduct, persistProduct, product],+ );++ return <DocsProductContext.Provider value={value}>{children}</DocsProductContext.Provider>;+}++export function useDocsProduct(): DocsProductContextValue {+ const value = useContext(DocsProductContext);+ if (!value) throw new Error('useDocsProduct must be used inside DocsProductProvider');+ return value;+}diff --git a/docs/components/home-surfaces.tsx b/docs/components/home-surfaces.tsxindex cb555573b..2f21446ab 100644--- a/docs/components/home-surfaces.tsx+++ b/docs/components/home-surfaces.tsx@@ -1,8 +1,14 @@-import Link from 'next/link';import { ArrowUp, ArrowUpRight, Mic, Plus } from 'lucide-react';import type { ComponentType } from 'react';-import { HOME_INTENTS, homeIntentAnchor, type HomeIntent } from '@/lib/home-navigation';+import {+ DOCS_PRODUCTS,+ HOME_INTENTS,+ homeIntentAnchor,+ type HomeIntent,+} from '@/lib/home-navigation';import { MOCK_FADE_STYLE } from './home-shared';+import { ProductLockup } from './product-lockup';+import { ProductSelectionLink } from './product-selection-link';/*** Each product is described by the same mock the dashboard onboarding@@ -33,23 +39,18 @@ function IntentCard({ intent }: { intent: HomeIntent }) {return (<article className="grid overflow-hidden border border-fd-border bg-fd-card shadow-[0_1px_0_rgba(15,15,15,0.04)] md:grid-cols-[minmax(0,1fr)_calc(50%-0.75rem)]">- <div className="relative overflow-hidden border-b border-fd-border bg-fd-background p-5 pb-40 sm:p-6 sm:pb-44 md:min-h-72 md:border-b-0 md:border-r md:pb-6">+ <ProductSelectionLink+ aria-label={`Explore ${intent.product} docs`}+ className="relative overflow-hidden border-b border-fd-border bg-fd-background p-5 pb-40 no-underline transition-colors hover:bg-fd-accent/20 focus-visible:outline-2 focus-visible:outline-offset-[-2px] focus-visible:outline-fd-ring sm:p-6 sm:pb-44 md:min-h-72 md:border-b-0 md:border-r md:pb-6"+ href={DOCS_PRODUCTS[intent.productId].landingRoute}+ product={intent.productId}+ ><div className="relative z-[1] flex flex-col gap-2.5"><h3className="flex items-center gap-2"id={homeIntentAnchor(intent.product)}>- <img- alt="Composio"- className="h-[22px] w-auto dark:hidden"- src="/Composio Logo.svg"- />- <img- alt="Composio"- className="hidden h-[22px] w-auto dark:block"- src="/Composio Logo Dark.svg"- />- <ProductBadge product={intent.product} />+ <ProductLockup product={intent.productId} /></h3><p className="max-w-[42ch] text-pretty text-[14px] leading-[1.55] text-fd-foreground/70">{intent.description}@@ -58,13 +59,14 @@ function IntentCard({ intent }: { intent: HomeIntent }) {<div aria-hidden="true" className="pointer-events-none select-none"><Visual /></div>- </div>+ </ProductSelectionLink><ul className="flex flex-col divide-y divide-fd-border">{intent.links.map(link => (<li className="flex flex-1" key={link.href}>- <Link+ <ProductSelectionLinkclassName="group flex flex-1 items-center justify-between gap-4 px-4 py-5 no-underline transition-colors hover:bg-fd-accent/40 sm:px-5 sm:py-6"href={link.href}+ product={intent.productId}><span className="flex min-w-0 flex-col gap-0.5"><span className="text-[14px] font-medium text-fd-foreground">@@ -78,7 +80,7 @@ function IntentCard({ intent }: { intent: HomeIntent }) {aria-hidden="true"className="size-3.5 shrink-0 text-fd-foreground/50 transition-transform group-hover:-translate-y-px group-hover:translate-x-px"/>- </Link>+ </ProductSelectionLink></li>))}</ul>@@ -86,63 +88,6 @@ function IntentCard({ intent }: { intent: HomeIntent }) {);}-const PLATFORM_BADGE_GRADIENT =- 'linear-gradient(135deg, #00e68a, #00b4d8, #0077ff)';--/**- * Port of the dashboard's `ComposioProductBadge` (composio_dashboard- * `composio-product-badge.tsx`) so the docs fork and the dashboard product- * switcher name the two products with the same mark.- */-function ProductBadge({ product }: { product: HomeIntent['product'] }) {- const isPlatform = product === 'Platform';-- return (- <span- className={- 'relative flex items-center rounded-[5px] px-[9px] py-[7px] font-mono text-[14px] font-semibold uppercase leading-none tracking-wide ' +- (isPlatform- ? 'product-badge-platform'- : 'text-[#0007cd] dark:text-[#4d6fff]')- }- style={- isPlatform- ? {- background: PLATFORM_BADGE_GRADIENT,- backgroundClip: 'text',- WebkitBackgroundClip: 'text',- WebkitTextFillColor: 'transparent',- }- : undefined- }- >- <span- aria-hidden="true"- className={- 'pointer-events-none absolute inset-0 rounded-[5px] ' +- (isPlatform- ? 'product-badge-platform-border'- : 'border border-[#0007cd] dark:border-[#4d6fff]')- }- style={- isPlatform- ? {- padding: '1px',- background: PLATFORM_BADGE_GRADIENT,- WebkitMask:- 'linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0)',- WebkitMaskComposite: 'xor',- mask: 'linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0)',- maskComposite: 'exclude',- }- : undefined- }- />- {product}- </span>- );-}-const FOR_YOU_CLIENT_LOGOS = [{ src: '/images/clients/claude.svg', label: 'Claude' },{ src: '/images/clients/codex.png', label: 'Codex' },diff --git a/docs/components/product-docs-layout.tsx b/docs/components/product-docs-layout.tsxnew file mode 100644index 000000000..f599bc3fb--- /dev/null+++ b/docs/components/product-docs-layout.tsx@@ -0,0 +1,57 @@+'use client';++import { useMemo, type ReactNode } from 'react';+import type { Root } from 'fumadocs-core/page-tree';+import { DocsLayout } from 'fumadocs-ui/layouts/docs';+import { decorateSidebarBadges } from '@/lib/decorate-sidebar-badges';+import { buildSidebarNavIndex } from '@/lib/sidebar-nav-index';+import type { DocsProduct } from '@/lib/home-navigation';+import { SidebarAnalytics } from './sidebar-analytics';+import { useDocsProduct } from './docs-product-context';++interface ProductDocsLayoutProps {+ children: ReactNode;+ trees: Record<DocsProduct, Root>;+ experimentalUrls: string[];+ newUrls: string[];+}++function ProductDocsLayoutInner({+ children,+ trees,+ experimentalUrls,+ newUrls,+}: ProductDocsLayoutProps) {+ const { product } = useDocsProduct();+ const tree = useMemo(+ () => decorateSidebarBadges(+ trees[product],+ new Set(experimentalUrls),+ new Set(newUrls),+ ),+ [experimentalUrls, newUrls, product, trees],+ );+ const navIndex = useMemo(() => buildSidebarNavIndex(tree), [tree]);++ return (+ <DocsLayout+ containerProps={{ className: 'docs-product-shell' }}+ nav={{ enabled: true, title: null }}+ searchToggle={{ enabled: false }}+ sidebar={{+ collapsible: false,+ footer: null,+ tabs: false,+ }}+ themeSwitch={{ enabled: false }}+ tree={tree}+ >+ <SidebarAnalytics index={navIndex} />+ {children}+ </DocsLayout>+ );+}++export function ProductDocsLayout(props: ProductDocsLayoutProps) {+ return <ProductDocsLayoutInner {...props} />;+}diff --git a/docs/components/product-lockup.tsx b/docs/components/product-lockup.tsxnew file mode 100644index 000000000..a09ef4429--- /dev/null+++ b/docs/components/product-lockup.tsx@@ -0,0 +1,86 @@+import Image from 'next/image';+import { DOCS_PRODUCTS, type DocsProduct } from '@/lib/home-navigation';++const PLATFORM_BADGE_GRADIENT =+ 'linear-gradient(135deg, #00e68a, #00b4d8, #0077ff)';++export function ProductBadge({ product }: { product: DocsProduct }) {+ const isPlatform = product === 'platform';++ return (+ <span+ className={+ 'relative flex items-center rounded-[5px] px-[9px] py-[7px] font-mono text-[14px] font-semibold uppercase leading-none tracking-wide ' ++ (isPlatform+ ? 'product-badge-platform'+ : 'text-[#0007cd] dark:text-[#4d6fff]')+ }+ style={+ isPlatform+ ? {+ background: PLATFORM_BADGE_GRADIENT,+ backgroundClip: 'text',+ WebkitBackgroundClip: 'text',+ WebkitTextFillColor: 'transparent',+ }+ : undefined+ }+ >+ <span+ aria-hidden="true"+ className={+ 'pointer-events-none absolute inset-0 rounded-[5px] ' ++ (isPlatform+ ? 'product-badge-platform-border'+ : 'border border-[#0007cd] dark:border-[#4d6fff]')+ }+ style={+ isPlatform+ ? {+ padding: '1px',+ background: PLATFORM_BADGE_GRADIENT,+ WebkitMask:+ 'linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0)',+ WebkitMaskComposite: 'xor',+ mask: 'linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0)',+ maskComposite: 'exclude',+ }+ : undefined+ }+ />+ {DOCS_PRODUCTS[product].product}+ </span>+ );+}++export function ProductLockup({+ product,+ compactOnMobile = false,+}: {+ product: DocsProduct;+ compactOnMobile?: boolean;+}) {+ return (+ <span className="inline-flex min-w-0 items-center gap-2">+ <span className={compactOnMobile ? 'max-[420px]:hidden' : undefined}>+ <Image+ alt="Composio"+ className="h-[22px] w-auto dark:hidden"+ height={20}+ priority+ src="/Composio Logo.svg"+ width={110}+ />+ <Image+ alt="Composio"+ className="hidden h-[22px] w-auto dark:block"+ height={20}+ priority+ src="/Composio Logo Dark.svg"+ width={110}+ />+ </span>+ <ProductBadge product={product} />+ </span>+ );+}diff --git a/docs/components/product-selection-link.tsx b/docs/components/product-selection-link.tsxnew file mode 100644index 000000000..b3c8ccad8--- /dev/null+++ b/docs/components/product-selection-link.tsx@@ -0,0 +1,43 @@+'use client';++import Link, { type LinkProps } from 'next/link';+import type { AnchorHTMLAttributes, MouseEvent, ReactNode } from 'react';+import type { DocsProduct } from '@/lib/home-navigation';+import { useDocsProduct } from './docs-product-context';++type ProductSelectionLinkProps = LinkProps &+ Omit<AnchorHTMLAttributes<HTMLAnchorElement>, keyof LinkProps> & {+ children: ReactNode;+ product: DocsProduct;+ };++export function ProductSelectionLink({+ product,+ href,+ children,+ onClick,+ ...props+}: ProductSelectionLinkProps) {+ const { navigateToProduct, persistProduct } = useDocsProduct();++ const handleClick = (event: MouseEvent<HTMLAnchorElement>) => {+ onClick?.(event);+ if (event.defaultPrevented) return;++ const modified =+ event.button !== 0 || event.metaKey || event.ctrlKey || event.shiftKey || event.altKey;+ if (modified || props.target === '_blank') {+ persistProduct(product);+ return;+ }++ event.preventDefault();+ navigateToProduct(product, String(href), event.currentTarget);+ };++ return (+ <Link href={href} onClick={handleClick} {...props}>+ {children}+ </Link>+ );+}diff --git a/docs/components/product-switcher.tsx b/docs/components/product-switcher.tsxnew file mode 100644index 000000000..d81f6076b--- /dev/null+++ b/docs/components/product-switcher.tsx@@ -0,0 +1,126 @@+'use client';++import { useRef, useState } from 'react';+import type { ComponentProps } from 'react';+import { usePathname, useRouter } from 'next/navigation';+import { Check, ChevronsUpDown } from 'lucide-react';+import {+ Popover,+ PopoverContent,+ PopoverTrigger,+} from 'fumadocs-ui/components/ui/popover';+import {+ DOCS_PRODUCT_ORDER,+ DOCS_PRODUCTS,+ docsProductDestination,+ type DocsProduct,+} from '@/lib/home-navigation';+import { ProductLockup } from './product-lockup';+import { useDocsProduct } from './docs-product-context';+import { cn } from '@/lib/utils';++export function ProductSwitcher({ placement = 'sidebar' }: { placement?: 'nav' | 'sidebar' }) {+ const pathname = usePathname();+ const router = useRouter();+ const { product, navigateToProduct } = useDocsProduct();+ const [open, setOpen] = useState(false);+ const triggerRef = useRef<HTMLButtonElement>(null);+ const current = DOCS_PRODUCTS[product];++ const selectProduct = (nextProduct: DocsProduct) => {+ if (nextProduct === product) {+ setOpen(false);+ return;+ }++ const destination = docsProductDestination(pathname, nextProduct);+ setOpen(false);+ navigateToProduct(nextProduct, destination, triggerRef.current);+ };++ return (+ <Popover open={open} onOpenChange={setOpen}>+ <PopoverTrigger asChild>+ <button+ aria-expanded={open}+ aria-haspopup="dialog"+ aria-label={`Switch Composio product. Current product: ${current.product}`}+ className={cn(+ 'docs-product-switcher group flex items-center gap-2 text-left text-fd-foreground transition-colors hover:bg-fd-accent/50 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-fd-ring',+ placement === 'nav'+ ? 'h-10 min-w-0 px-1.5 max-sm:gap-1'+ : 'min-h-14 w-full justify-between border border-fd-border bg-fd-background px-3 py-2 shadow-xs',+ )}+ onFocus={() => {+ for (const productId of DOCS_PRODUCT_ORDER) {+ if (productId !== product) {+ router.prefetch(docsProductDestination(pathname, productId));+ }+ }+ }}+ onMouseEnter={() => {+ for (const productId of DOCS_PRODUCT_ORDER) {+ if (productId !== product) {+ router.prefetch(docsProductDestination(pathname, productId));+ }+ }+ }}+ ref={triggerRef}+ type="button"+ >+ <ProductLockup compactOnMobile={placement === 'nav'} product={product} />+ <span className="inline-flex shrink-0 items-center gap-1 text-xs font-medium text-fd-muted-foreground group-hover:text-fd-foreground">+ {placement === 'sidebar' && 'Switch'}+ <ChevronsUpDown aria-hidden="true" className="size-3.5" />+ </span>+ </button>+ </PopoverTrigger>+ <PopoverContent+ align="start"+ className="w-[min(20rem,calc(100vw-2rem))] p-1"+ side="bottom"+ sideOffset={8}+ >+ <div aria-label="Choose a Composio product" role="radiogroup">+ {DOCS_PRODUCT_ORDER.map((productId, index) => {+ const option = DOCS_PRODUCTS[productId];+ const isCurrent = productId === product;+ return (+ <div key={productId}>+ {index > 0 && <div aria-hidden="true" className="mx-2 my-1 h-px bg-fd-border" />}+ <button+ aria-checked={isCurrent}+ aria-current={isCurrent ? 'page' : undefined}+ aria-label={`${option.product}: ${option.switcherDescription}`}+ className="flex w-full items-start gap-3 p-2.5 text-left transition-colors hover:bg-fd-accent/60 focus-visible:outline-2 focus-visible:outline-offset-[-2px] focus-visible:outline-fd-ring"+ onClick={() => selectProduct(productId)}+ role="radio"+ type="button"+ >+ <span className="flex min-w-0 flex-1 flex-col gap-2">+ <ProductLockup product={productId} />+ <span className="text-sm font-normal text-fd-muted-foreground">+ {option.switcherDescription}+ </span>+ </span>+ <Check+ aria-hidden="true"+ className={`mt-1 size-4 shrink-0 text-fd-primary ${isCurrent ? '' : 'invisible'}`}+ />+ </button>+ </div>+ );+ })}+ </div>+ </PopoverContent>+ </Popover>+ );+}++export function ProductNavTitle({ className }: ComponentProps<'a'>) {+ return (+ <div className={cn(className, 'min-w-0')}>+ <ProductSwitcher placement="nav" />+ </div>+ );+}diff --git a/docs/components/product-transition-loader.tsx b/docs/components/product-transition-loader.tsxnew file mode 100644index 000000000..128b69cb2--- /dev/null+++ b/docs/components/product-transition-loader.tsx@@ -0,0 +1,30 @@+'use client';++import { useEffect } from 'react';++export function ProductTransitionLoader() {+ useEffect(() => {+ if (typeof CSS === 'undefined' || !('paintWorklet' in CSS)) return;++ const properties = [+ { name: '--docs-reveal-radius', syntax: '<percentage>', initialValue: '0%' },+ { name: '--docs-pixel-size', syntax: '<number>', initialValue: '20' },+ { name: '--docs-dissolve-amount', syntax: '<number>', initialValue: '0.65' },+ ];++ for (const property of properties) {+ try {+ CSS.registerProperty({ ...property, inherits: false });+ } catch {+ // The CSS @property rule or React Strict Mode may register it first.+ }+ }++ const paintWorklet = (CSS as typeof CSS & {+ paintWorklet: { addModule: (url: string) => Promise<void> };+ }).paintWorklet;+ void paintWorklet.addModule('/pixelated-circle-worklet.js').catch(() => undefined);+ }, []);++ return null;+}diff --git a/docs/lib/home-navigation.ts b/docs/lib/home-navigation.tsindex 30e2c7f4e..b87ca7451 100644--- a/docs/lib/home-navigation.ts+++ b/docs/lib/home-navigation.ts@@ -1,3 +1,14 @@+export type DocsProduct = 'for-you' | 'platform';++export type ProductSidebarItem =+ | { type: 'page'; url: string; label?: string }+ | { type: 'folder'; path: string; label?: string };++export interface ProductSidebarGroup {+ label: string;+ items: readonly ProductSidebarItem[];+}+export interface HomeIntentLink {title: string;description: string;@@ -6,60 +17,231 @@ export interface HomeIntentLink {export interface HomeIntent {id: 'build' | 'use';+ productId: DocsProduct;product: 'Platform' | 'For You';title: string;description: string;- links: HomeIntentLink[];+ links: readonly HomeIntentLink[];}-export const HOME_INTENTS: HomeIntent[] = [- {- id: 'build',- product: 'Platform',- title: 'Build with Composio',- description: 'Build Composio into your own agent or application — tools, auth, and triggers for every one of your users.',- links: [- {- title: 'Quickstart',- description: 'Build an agent that discovers tools and works across your apps.',- href: '/docs/quickstart',- },- {- title: 'Framework guides',- description: 'Use OpenAI, Anthropic, Vercel AI SDK, or another framework.',- href: '/docs/providers',- },+interface DocsProductConfig {+ id: DocsProduct;+ product: HomeIntent['product'];+ switcherDescription: string;+ landingRoute: string;+ defaultTheme: 'light' | 'dark';+ routePrefixes: readonly string[];+ sidebar: readonly ProductSidebarGroup[];+ home: Omit<HomeIntent, 'productId' | 'product'>;+}++const SHARED_SIDEBAR_ITEMS = [+ { type: 'page', url: '/docs', label: 'Choose a product' },+ { type: 'folder', path: 'security', label: 'Security and data' },+] as const satisfies readonly ProductSidebarItem[];++/**+ * Canonical product model for the docs shell and homepage.+ *+ * Platform is the documented first-visit default because it preserves the+ * existing SDK-first docs behavior. Audience-specific URLs take precedence,+ * followed by the persisted cookie on shared URLs.+ */+export const DEFAULT_DOCS_PRODUCT: DocsProduct = 'platform';+export const DOCS_PRODUCT_COOKIE = 'composio-docs-product';+export const DOCS_PRODUCT_HEADER = 'x-composio-docs-product';++export const DOCS_PRODUCTS = {+ 'for-you': {+ id: 'for-you',+ product: 'For You',+ switcherDescription: 'Connect your apps to AI clients.',+ landingRoute: '/docs/agent-plugins',+ defaultTheme: 'light',+ routePrefixes: [+ '/docs/agent-plugins',+ '/docs/claude-code-plugin',+ '/docs/cli',+ '/docs/composio-connect',+ ],+ sidebar: [{- title: 'Sessions via MCP',- description: 'Expose a Composio session through a hosted MCP endpoint.',- href: '/docs/sessions-via-mcp',+ label: 'Get started',+ items: [+ { type: 'page', url: '/docs/agent-plugins' },+ { type: 'page', url: '/docs/cli' },+ { type: 'page', url: '/docs/composio-connect', label: 'Connect with MCP' },+ ],},+ { label: 'Shared resources', items: SHARED_SIDEBAR_ITEMS },],+ home: {+ id: 'use',+ title: 'Use Composio',+ description: 'Use Composio from the agents you already have — Claude Code, Codex, Cursor, or your terminal.',+ links: [+ {+ title: 'Agent plugins',+ description: 'Install the native Composio plugin for Codex or Claude Code.',+ href: '/docs/agent-plugins',+ },+ {+ title: 'Composio CLI',+ description: 'Search, connect, and run tools from your terminal.',+ href: '/docs/cli',+ },+ {+ title: 'Connect over MCP',+ description: 'Use Composio with Cursor or another existing MCP client.',+ href: '/docs/composio-connect',+ },+ ],+ },},- {- id: 'use',- product: 'For You',- title: 'Use Composio',- description: 'Use Composio from the agents you already have — Claude Code, Codex, Cursor, or your terminal.',- links: [+ platform: {+ id: 'platform',+ product: 'Platform',+ switcherDescription: 'Build agents with the Composio SDK.',+ landingRoute: '/docs/quickstart',+ defaultTheme: 'dark',+ routePrefixes: [+ '/docs/quickstart',+ '/docs/providers',+ '/docs/how-composio-works',+ '/docs/configuring-sessions',+ '/docs/authentication',+ '/docs/triggers',+ '/docs/skills',+ '/docs/sessions-via-mcp',+ '/docs/sandbox',+ '/docs/extending-sessions',+ '/docs/setting-up-triggers',+ '/docs/sessions-vs-direct-execution',+ '/docs/tools-direct',+ '/docs/auth-configuration',+ '/docs/migration-guide',+ '/docs/single-toolkit-mcp',+ ],+ sidebar: [{- title: 'Agent plugins',- description: 'Install the native Composio plugin for Codex or Claude Code.',- href: '/docs/agent-plugins',+ label: 'Get started',+ items: [+ { type: 'page', url: '/docs/quickstart' },+ { type: 'folder', path: 'providers', label: 'SDKs and frameworks' },+ ],},{- title: 'Composio CLI',- description: 'Search, connect, and run tools from your terminal.',- href: '/docs/cli',+ label: 'Build with Composio',+ items: [+ { type: 'page', url: '/docs/how-composio-works', label: 'Sessions' },+ { type: 'page', url: '/docs/configuring-sessions' },+ { type: 'folder', path: 'authentication' },+ { type: 'page', url: '/docs/skills', label: 'Tools and skills' },+ { type: 'page', url: '/docs/triggers' },+ ],},{- title: 'Connect over MCP',- description: 'Use Composio with Cursor or another existing MCP client.',- href: '/docs/composio-connect',+ label: 'Guides',+ items: [+ { type: 'page', url: '/docs/sessions-via-mcp' },+ { type: 'folder', path: 'sandbox' },+ { type: 'folder', path: 'extending-sessions' },+ { type: 'folder', path: 'setting-up-triggers' },+ ],},+ {+ label: 'Migration and legacy',+ items: [+ { type: 'folder', path: 'migration-guide' },+ { type: 'page', url: '/docs/sessions-vs-direct-execution' },+ { type: 'folder', path: 'tools-direct' },+ { type: 'folder', path: 'auth-configuration' },+ ],+ },+ { label: 'Shared resources', items: SHARED_SIDEBAR_ITEMS },],+ home: {+ id: 'build',+ title: 'Build with Composio',+ description: 'Build Composio into your own agent or application — tools, auth, and triggers for every one of your users.',+ links: [+ {+ title: 'Quickstart',+ description: 'Build an agent that discovers tools and works across your apps.',+ href: '/docs/quickstart',+ },+ {+ title: 'Framework guides',+ description: 'Use OpenAI, Anthropic, Vercel AI SDK, or another framework.',+ href: '/docs/providers',+ },+ {+ title: 'Sessions via MCP',+ description: 'Expose a Composio session through a hosted MCP endpoint.',+ href: '/docs/sessions-via-mcp',+ },+ ],+ },},-];+} as const satisfies Record<DocsProduct, DocsProductConfig>;++export const DOCS_PRODUCT_ORDER = ['for-you', 'platform'] as const;+const HOME_PRODUCT_ORDER = ['platform', 'for-you'] as const;++export const HOME_INTENTS: readonly HomeIntent[] = HOME_PRODUCT_ORDER.map(productId => {+ const config = DOCS_PRODUCTS[productId];+ return { ...config.home, productId, product: config.product };+});++const PRODUCT_COUNTERPARTS = [+ { platform: '/docs/quickstart', 'for-you': '/docs/agent-plugins' },+ { platform: '/docs/sessions-via-mcp', 'for-you': '/docs/composio-connect' },+] as const;++function matchesRoute(pathname: string, prefix: string): boolean {+ return pathname === prefix || pathname.startsWith(`${prefix}/`);+}++export function parseDocsProduct(value: string | null | undefined): DocsProduct | null {+ return value === 'for-you' || value === 'platform' ? value : null;+}++export function classifyDocsProduct(pathname: string): DocsProduct | null {+ for (const productId of DOCS_PRODUCT_ORDER) {+ if (DOCS_PRODUCTS[productId].routePrefixes.some(prefix => matchesRoute(pathname, prefix))) {+ return productId;+ }+ }+ return null;+}++export function resolveDocsProduct(+ pathname: string,+ persistedProduct?: string | null,+): DocsProduct {+ return (+ classifyDocsProduct(pathname) ??+ parseDocsProduct(persistedProduct) ??+ DEFAULT_DOCS_PRODUCT+ );+}++export function docsProductDestination(pathname: string, target: DocsProduct): string {+ const sourceProduct = target === 'platform' ? 'for-you' : 'platform';+ const counterpart = PRODUCT_COUNTERPARTS.find(pair => matchesRoute(pathname, pair[sourceProduct]));+ return counterpart?.[target] ?? DOCS_PRODUCTS[target].landingRoute;+}++export function serializeDocsProductCookie(product: DocsProduct): string {+ return `${DOCS_PRODUCT_COOKIE}=${product}; Path=/; Max-Age=31536000; SameSite=Lax`;+}++export function shouldAnimateDocsProductSwitch(+ supportsViewTransitions: boolean,+ prefersReducedMotion: boolean,+): boolean {+ return supportsViewTransitions && !prefersReducedMotion;+}/*** Slugify an intent's heading label into an anchor id. Called withdiff --git a/docs/lib/layout.shared.tsx b/docs/lib/layout.shared.tsxindex 92dddc973..04b4890e9 100644--- a/docs/lib/layout.shared.tsx+++ b/docs/lib/layout.shared.tsx@@ -3,6 +3,7 @@ import Image from 'next/image';import { Play } from 'lucide-react';import { SearchAndAskAI, SearchAndAskAIMobile } from '@/components/ask-ai-button';import { NavVersionSelector } from '@/components/version-selector';+import { ProductNavTitle } from '@/components/product-switcher';// Composio Logo Component with light/dark mode switchingfunction ComposioLogo() {@@ -36,6 +37,7 @@ export function baseOptions(): BaseLayoutProps {title: <ComposioLogo />,transparentMode: 'top',},+ slots: { navTitle: ProductNavTitle },themeSwitch: { enabled: true, mode: 'light-dark-system' },searchToggle: {components: {diff --git a/docs/lib/product-page-tree.ts b/docs/lib/product-page-tree.tsnew file mode 100644index 000000000..7edb0a9e2--- /dev/null+++ b/docs/lib/product-page-tree.ts@@ -0,0 +1,71 @@+import type { Folder, Item, Node, Root } from 'fumadocs-core/page-tree';+import {+ DOCS_PRODUCTS,+ type DocsProduct,+ type ProductSidebarItem,+} from './home-navigation';++function findPage(nodes: Node[], url: string): Item | null {+ for (const node of nodes) {+ if (node.type === 'page' && node.url === url) return node;+ if (node.type === 'folder') {+ if (node.index?.url === url) return node.index;+ const nested = findPage(node.children, url);+ if (nested) return nested;+ }+ }+ return null;+}++function findFolder(nodes: Node[], path: string): Folder | null {+ for (const node of nodes) {+ if (node.type !== 'folder') continue;+ if (node.$ref?.folder === path) return node;+ const nested = findFolder(node.children, path);+ if (nested) return nested;+ }+ return null;+}++function resolveSidebarItem(tree: Root, item: ProductSidebarItem): Node {+ const sourceNode =+ item.type === 'page'+ ? findPage(tree.children, item.url)+ : findFolder(tree.children, item.path);++ if (!sourceNode) {+ const target = item.type === 'page' ? item.url : item.path;+ throw new Error(`Product sidebar target does not exist: ${target}`);+ }++ return item.label ? { ...sourceNode, name: item.label } : sourceNode;+}++export function buildProductPageTree(tree: Root, product: DocsProduct): Root {+ const children = DOCS_PRODUCTS[product].sidebar.flatMap(group => [+ { type: 'separator' as const, name: group.label },+ ...group.items.map(item => resolveSidebarItem(tree, item)),+ ]);++ // Fumadocs memoizes trees by root ID, so each audience needs a distinct ID+ // for client-side product switches to replace the sidebar immediately.+ return { ...tree, $id: `docs-product:${product}`, children };+}++export function pageTreeUrls(tree: Root): string[] {+ const urls: string[] = [];++ function visit(nodes: Node[]): void {+ for (const node of nodes) {+ if (node.type === 'page') {+ urls.push(node.url);+ } else if (node.type === 'folder') {+ if (node.index) urls.push(node.index.url);+ visit(node.children);+ }+ }+ }++ visit(tree.children);+ return urls;+}diff --git a/docs/proxy.ts b/docs/proxy.tsindex 94b324e6c..34e53df56 100644--- a/docs/proxy.ts+++ b/docs/proxy.ts@@ -1,4 +1,9 @@import { NextRequest, NextResponse } from 'next/server';+import {+ DOCS_PRODUCT_COOKIE,+ DOCS_PRODUCT_HEADER,+ resolveDocsProduct,+} from './lib/home-navigation';/*** Convert kebab-case to camelCase@@ -11,7 +16,8 @@ function kebabToCamel(str: string): string {* Proxy handles:* 1. Markdown content negotiation for AI agents (Accept: text/markdown)* 2. Redirects for old Fern API reference URLs (kebab-case → camelCase)- * 3. Sets x-pathname header for 404 logging+ * 3. Resolves the server-rendered docs product from URL + cookie+ * 4. Sets x-pathname header for 404 logging*/export function proxy(request: NextRequest) {const { pathname } = request.nextUrl;@@ -49,7 +55,14 @@ export function proxy(request: NextRequest) {}}- const response = NextResponse.next();+ const requestHeaders = new Headers(request.headers);+ const product = resolveDocsProduct(+ pathname,+ request.cookies.get(DOCS_PRODUCT_COOKIE)?.value,+ );+ requestHeaders.set(DOCS_PRODUCT_HEADER, product);++ const response = NextResponse.next({ request: { headers: requestHeaders } });response.headers.set('x-pathname', pathname);return response;}diff --git a/docs/public/pixelated-circle-worklet.js b/docs/public/pixelated-circle-worklet.jsnew file mode 100644index 000000000..88d18f3d6--- /dev/null+++ b/docs/public/pixelated-circle-worklet.js@@ -0,0 +1,66 @@+// Runs in the CSS Paint Worklet global scope, not as an application module.+class PixelatedCirclePainter {+ static get inputProperties() {+ return [+ '--docs-reveal-x',+ '--docs-reveal-y',+ '--docs-reveal-radius',+ '--docs-pixel-size',+ '--docs-dissolve-amount',+ ];+ }++ hash(x, y) {+ const value = Math.sin(x * 12.9898 + y * 78.233) * 43758.5453;+ return value - Math.floor(value);+ }++ paint(context, size, properties) {+ const readNumber = (name, fallback) => {+ const value = Number.parseFloat(properties.get(name));+ return Number.isNaN(value) ? fallback : value;+ };+ const centerX = readNumber('--docs-reveal-x', 32);+ const centerY = readNumber('--docs-reveal-y', 32);+ const radiusPercent = readNumber('--docs-reveal-radius', 0);+ const pixelSize = readNumber('--docs-pixel-size', 20);+ const dissolveAmount = Math.min(+ 1,+ Math.max(0, readNumber('--docs-dissolve-amount', 0.65)),+ );+ const diagonal = Math.sqrt(size.width ** 2 + size.height ** 2);+ const baseRadius = (radiusPercent / 100) * diagonal;+ const radiusScale = dissolveAmount < 0.95 ? 1 / (1 - dissolveAmount) : 20;+ const radius = baseRadius * radiusScale;+ const innerEdge = radius * (1 - dissolveAmount);+ const fuzzyWidth = radius - innerEdge;++ for (let x = 0; x < size.width; x += pixelSize) {+ for (let y = 0; y < size.height; y += pixelSize) {+ const distance = Math.sqrt(+ (x + pixelSize / 2 - centerX) ** 2 ++ (y + pixelSize / 2 - centerY) ** 2,+ );+ let opacity = 0;++ if (distance <= innerEdge) {+ opacity = 1;+ } else if (distance <= radius && fuzzyWidth > 0) {+ const distanceOpacity = 1 - (distance - innerEdge) / fuzzyWidth;+ if (this.hash(x / pixelSize, y / pixelSize) < distanceOpacity) {+ opacity =+ distanceOpacity *+ (0.5 + 0.5 * this.hash(y / pixelSize, x / pixelSize));+ }+ }++ if (opacity > 0) {+ context.fillStyle = `rgba(0, 0, 0, ${opacity})`;+ context.fillRect(x, y, pixelSize, pixelSize);+ }+ }+ }+ }+}++registerPaint('docs-pixelated-circle', PixelatedCirclePainter);diff --git a/docs/tests/static/home-navigation.test.ts b/docs/tests/static/home-navigation.test.tsindex 04ba09cea..1f39993bb 100644--- a/docs/tests/static/home-navigation.test.ts+++ b/docs/tests/static/home-navigation.test.ts@@ -49,6 +49,9 @@ describe('Welcome navigation', () => {const source = await Bun.file(new URL('../../components/home-surfaces.tsx', import.meta.url)).text();+ const lockupSource = await Bun.file(+ new URL('../../components/product-lockup.tsx', import.meta.url)+ ).text();expect(source).toContain('id="two-ways-to-start"');for (const intent of HOME_INTENTS) {@@ -60,18 +63,20 @@ describe('Welcome navigation', () => {// same mock the dashboard onboarding path step uses for that product: an// agent chat composer plus client logos for For You, the SDK in a code// window for Platform.- expect(source).toContain('ProductBadge');- expect(source).toContain('background: PLATFORM_BADGE_GRADIENT');- expect(source).toContain("backgroundClip: 'text'");- expect(source).toContain("WebkitTextFillColor: 'transparent'");- expect(source).toContain("mask: 'linear-gradient(#fff 0 0) content-box");- expect(source).toContain('text-[#0007cd] dark:text-[#4d6fff]');- expect(source).toContain('product-badge-platform-border');- expect(source).toContain('/Composio Logo.svg');+ expect(source).toContain('ProductLockup');+ expect(source).toContain('ProductSelectionLink');+ expect(lockupSource).toContain('ProductBadge');+ expect(lockupSource).toContain('background: PLATFORM_BADGE_GRADIENT');+ expect(lockupSource).toContain("backgroundClip: 'text'");+ expect(lockupSource).toContain("WebkitTextFillColor: 'transparent'");+ expect(lockupSource).toContain("mask: 'linear-gradient(#fff 0 0) content-box");+ expect(lockupSource).toContain('text-[#0007cd] dark:text-[#4d6fff]');+ expect(lockupSource).toContain('product-badge-platform-border');+ expect(lockupSource).toContain('/Composio Logo.svg');// Both logo variants carry the same alt: `dark:hidden` / `hidden dark:block`// swap them in CSS, so an aria-hidden dark variant would drop "Composio"// from the heading's accessible name in dark mode only.- expect(source.match(/alt="Composio"/g) ?? []).toHaveLength(2);+ expect(lockupSource.match(/alt="Composio"/g) ?? []).toHaveLength(2);expect(source).toContain('INTENT_VISUALS');expect(source).toContain('How can I help?');expect(source).toContain('composio.create');diff --git a/docs/tests/static/product-navigation.test.ts b/docs/tests/static/product-navigation.test.tsnew file mode 100644index 000000000..493394ae6--- /dev/null+++ b/docs/tests/static/product-navigation.test.ts@@ -0,0 +1,127 @@+import { describe, expect, test } from 'bun:test';++import {+ classifyDocsProduct,+ DEFAULT_DOCS_PRODUCT,+ DOCS_PRODUCTS,+ docsProductDestination,+ parseDocsProduct,+ resolveDocsProduct,+ serializeDocsProductCookie,+ shouldAnimateDocsProductSwitch,+} from '../../lib/home-navigation';+import { buildProductPageTree, pageTreeUrls } from '../../lib/product-page-tree';+import { source } from '../../lib/source';++describe('Docs product navigation', () => {+ test('defines the product labels, descriptions, landings, and theme defaults once', () => {+ expect(DEFAULT_DOCS_PRODUCT).toBe('platform');+ expect(DOCS_PRODUCTS['for-you']).toMatchObject({+ product: 'For You',+ switcherDescription: 'Connect your apps to AI clients.',+ landingRoute: '/docs/agent-plugins',+ defaultTheme: 'light',+ });+ expect(DOCS_PRODUCTS.platform).toMatchObject({+ product: 'Platform',+ switcherDescription: 'Build agents with the Composio SDK.',+ landingRoute: '/docs/quickstart',+ defaultTheme: 'dark',+ });+ });++ test('classifies audience routes while leaving shared routes unclassified', () => {+ expect(classifyDocsProduct('/docs/agent-plugins')).toBe('for-you');+ expect(classifyDocsProduct('/docs/composio-connect')).toBe('for-you');+ expect(classifyDocsProduct('/docs/providers/openai')).toBe('platform');+ expect(classifyDocsProduct('/docs/authentication/controlling-scopes')).toBe('platform');+ expect(classifyDocsProduct('/docs')).toBeNull();+ expect(classifyDocsProduct('/docs/security/overview')).toBeNull();+ });++ test('uses route inference before persistence and the documented default last', () => {+ expect(resolveDocsProduct('/docs/quickstart', 'for-you')).toBe('platform');+ expect(resolveDocsProduct('/docs/security/overview', 'for-you')).toBe('for-you');+ expect(resolveDocsProduct('/docs/security/overview', 'platform')).toBe('platform');+ expect(resolveDocsProduct('/docs', 'invalid')).toBe('platform');+ expect(parseDocsProduct('for-you')).toBe('for-you');+ expect(parseDocsProduct('anything-else')).toBeNull();+ expect(serializeDocsProductCookie('for-you')).toContain(+ 'composio-docs-product=for-you',+ );+ expect(serializeDocsProductCookie('for-you')).toContain('SameSite=Lax');+ });++ test('uses meaningful counterparts and otherwise falls back to product landings', () => {+ expect(docsProductDestination('/docs/quickstart', 'for-you')).toBe(+ '/docs/agent-plugins',+ );+ expect(docsProductDestination('/docs/agent-plugins', 'platform')).toBe(+ '/docs/quickstart',+ );+ expect(docsProductDestination('/docs/sessions-via-mcp', 'for-you')).toBe(+ '/docs/composio-connect',+ );+ expect(docsProductDestination('/docs/composio-connect', 'platform')).toBe(+ '/docs/sessions-via-mcp',+ );+ expect(docsProductDestination('/docs/authentication', 'for-you')).toBe(+ '/docs/agent-plugins',+ );+ expect(docsProductDestination('/docs/cli', 'platform')).toBe('/docs/quickstart');+ });++ test('animates only when view transitions are available and motion is allowed', () => {+ expect(shouldAnimateDocsProductSwitch(true, false)).toBe(true);+ expect(shouldAnimateDocsProductSwitch(false, false)).toBe(false);+ expect(shouldAnimateDocsProductSwitch(true, true)).toBe(false);+ });++ test('builds audience-specific trees and keeps shared pages in both', () => {+ const forYouTree = buildProductPageTree(source.pageTree, 'for-you');+ const platformTree = buildProductPageTree(source.pageTree, 'platform');+ const forYouUrls = pageTreeUrls(forYouTree);+ const platformUrls = pageTreeUrls(platformTree);++ expect(forYouTree.$id).not.toBe(platformTree.$id);++ expect(forYouUrls).toContain('/docs/agent-plugins');+ expect(forYouUrls).toContain('/docs/cli');+ expect(forYouUrls).toContain('/docs/composio-connect');+ expect(forYouUrls).not.toContain('/docs/quickstart');++ for (const url of [+ '/docs/quickstart',+ '/docs/providers',+ '/docs/how-composio-works',+ '/docs/authentication',+ '/docs/skills',+ '/docs/triggers',+ ]) {+ expect(platformUrls).toContain(url);+ }+ expect(platformUrls).not.toContain('/docs/agent-plugins');++ for (const sharedUrl of ['/docs', '/docs/security/overview', '/docs/security/data-retention']) {+ expect(forYouUrls).toContain(sharedUrl);+ expect(platformUrls).toContain(sharedUrl);+ }+ });++ test('keeps accessibility-critical switcher semantics and visible focus styles', async () => {+ const switcherSource = await Bun.file(+ new URL('../../components/product-switcher.tsx', import.meta.url),+ ).text();+ const sharedLayoutSource = await Bun.file(+ new URL('../../lib/layout.shared.tsx', import.meta.url),+ ).text();++ expect(switcherSource).toContain('aria-label={`Switch Composio product. Current product:');+ expect(switcherSource).toContain('role="radiogroup"');+ expect(switcherSource).toContain('role="radio"');+ expect(switcherSource).toContain('aria-checked={isCurrent}');+ expect(switcherSource).toContain("aria-current={isCurrent ? 'page' : undefined}");+ expect(switcherSource).toContain('focus-visible:outline-2');+ expect(sharedLayoutSource).toContain('slots: { navTitle: ProductNavTitle }');+ });+});