@devries-cameron20 / composio-1 / commits / d2fb7defd
Fork 0

Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.

Codex's first pass

Brendan O'Leary committed Sep 2, 2026 at 09:04 UTC d2fb7defda2d7ebe2d29ffd9716a0ebb4fa6d528
18 files changed +1152 -142
docs/app/(home)/docs/layout.tsx
+11 -14
@@ -1,8 +1,6 @@
1 import { source } from '@/lib/source';
2 -import { DocsLayout } from 'fumadocs-ui/layouts/docs';
3 -import { decorateSidebarBadges } from '@/lib/decorate-sidebar-badges';
4 -import { buildSidebarNavIndex } from '@/lib/sidebar-nav-index';
5 -import { SidebarAnalytics } from '@/components/sidebar-analytics';
2 +import { ProductDocsLayout } from '@/components/product-docs-layout';
3 +import { buildProductPageTree } from '@/lib/product-page-tree';
4
5 interface BadgeFrontmatter {
6 experimental?: boolean;
@@ -17,20 +15,19 @@ const newUrls = new Set(
15 pages.filter((page) => (page.data as BadgeFrontmatter).isNew).map((page) => page.url),
16 );
17
20 -const tree = decorateSidebarBadges(source.pageTree, experimentalUrls, newUrls);
21 -const navIndex = buildSidebarNavIndex(tree);
18 +const trees = {
19 + 'for-you': buildProductPageTree(source.pageTree, 'for-you'),
20 + platform: buildProductPageTree(source.pageTree, 'platform'),
21 +};
22
23 export default function Layout({ children }: LayoutProps<'/docs'>) {
24 return (
25 - <DocsLayout
26 - tree={tree}
27 - nav={{ enabled: true, title: null }}
28 - sidebar={{ collapsible: false, footer: null, tabs: false }}
29 - themeSwitch={{ enabled: false }}
30 - searchToggle={{ enabled: false }}
25 + <ProductDocsLayout
26 + experimentalUrls={[...experimentalUrls]}
27 + newUrls={[...newUrls]}
28 + trees={trees}
29 >
32 - <SidebarAnalytics index={navIndex} />
30 {children}
34 - </DocsLayout>
31 + </ProductDocsLayout>
32 );
33 }
docs/app/(home)/layout.tsx
+18 -5
@@ -1,12 +1,25 @@
1 import { HomeLayout } from 'fumadocs-ui/layouts/home';
2 +import { headers } from 'next/headers';
3 import { baseOptions } from '@/lib/layout.shared';
4 import { EveChatMount } from '@/components/eve-chat-mount';
5 +import { DocsProductProvider } from '@/components/docs-product-context';
6 +import {
7 + DEFAULT_DOCS_PRODUCT,
8 + DOCS_PRODUCT_HEADER,
9 + parseDocsProduct,
10 +} from '@/lib/home-navigation';
11 +
12 +export default async function Layout({ children }: LayoutProps<'/'>) {
13 + const requestHeaders = await headers();
14 + const initialProduct =
15 + parseDocsProduct(requestHeaders.get(DOCS_PRODUCT_HEADER)) ?? DEFAULT_DOCS_PRODUCT;
16
5 -export default function Layout({ children }: LayoutProps<'/'>) {
17 return (
7 - <HomeLayout {...baseOptions()}>
8 - {children}
9 - <EveChatMount />
10 - </HomeLayout>
18 + <DocsProductProvider initialProduct={initialProduct}>
19 + <HomeLayout {...baseOptions()}>
20 + {children}
21 + <EveChatMount />
22 + </HomeLayout>
23 + </DocsProductProvider>
24 );
25 }
docs/app/global.css
+68 -1
@@ -425,7 +425,7 @@ a:focus-visible {
425 }
426
427 /* Hide empty sidebar header when no title is set */
428 -#nd-sidebar > div:first-child:has(a:empty) {
428 +#nd-sidebar > div:first-child:has(a:empty):not(:has(.docs-product-switcher)) {
429 display: none;
430 }
431
@@ -1179,3 +1179,70 @@ html:not(.dark) .terminal-theme-claude {
1179 outline: 2px solid light-dark(rgb(0 0 0 / 0.2), rgb(255 255 255 / 0.25));
1180 outline-offset: 1px;
1181 }
1182 +
1183 +/* Product switching is the only navigation that receives a named transition.
1184 + The origin is measured from the switcher trigger before navigation. */
1185 +html.docs-product-transition .docs-product-shell {
1186 + view-transition-name: docs-product-shell;
1187 +}
1188 +
1189 +::view-transition-old(docs-product-shell) {
1190 + animation: none;
1191 + z-index: 1;
1192 +}
1193 +
1194 +::view-transition-new(docs-product-shell) {
1195 + animation: 700ms cubic-bezier(0.785, 0.135, 0.15, 0.86) both docs-circle-reveal;
1196 + clip-path: circle(var(--docs-reveal-radius) at var(--docs-reveal-x) var(--docs-reveal-y));
1197 + z-index: 2;
1198 + --docs-reveal-radius: 0%;
1199 + --docs-pixel-size: 20;
1200 + --docs-dissolve-amount: 0.65;
1201 +}
1202 +
1203 +@supports (background: paint(docs-pixelated-circle)) {
1204 + ::view-transition-new(docs-product-shell) {
1205 + clip-path: none;
1206 + mask-image: paint(docs-pixelated-circle);
1207 + }
1208 +}
1209 +
1210 +@property --docs-reveal-radius {
1211 + syntax: '<percentage>';
1212 + initial-value: 0%;
1213 + inherits: false;
1214 +}
1215 +
1216 +@property --docs-pixel-size {
1217 + syntax: '<number>';
1218 + initial-value: 20;
1219 + inherits: false;
1220 +}
1221 +
1222 +@property --docs-dissolve-amount {
1223 + syntax: '<number>';
1224 + initial-value: 0.65;
1225 + inherits: false;
1226 +}
1227 +
1228 +@keyframes docs-circle-reveal {
1229 + from {
1230 + --docs-reveal-radius: 0%;
1231 + }
1232 + to {
1233 + --docs-reveal-radius: 150%;
1234 + }
1235 +}
1236 +
1237 +@media (prefers-reduced-motion: reduce) {
1238 + html.docs-product-transition .docs-product-shell {
1239 + view-transition-name: none;
1240 + }
1241 +
1242 + ::view-transition-old(docs-product-shell),
1243 + ::view-transition-new(docs-product-shell) {
1244 + animation: none;
1245 + clip-path: none;
1246 + mask-image: none;
1247 + }
1248 +}
docs/app/layout.tsx
+2
@@ -9,6 +9,7 @@ import CustomSearchDialog from '@/components/custom-search-dialog';
9 import { ScrollReset } from '@/components/scroll-reset';
10 import { source, referenceSource } from '@/lib/source';
11 import { TOOLKIT_COUNT_LABEL } from '@/lib/toolkit-count';
12 +import { ProductTransitionLoader } from '@/components/product-transition-loader';
13
14 const defaultLinkSlugs: { slug: string[]; source: typeof source }[] = [
15 { slug: ['quickstart'], source },
@@ -111,6 +112,7 @@ export default function Layout({ children }: LayoutProps<'/'>) {
112 </head>
113 <body className="flex flex-col min-h-dvh font-sans">
114 <ScrollReset />
115 + <ProductTransitionLoader />
116 <Analytics />
117 <PostHogProvider>
118 <RootProvider
docs/components/docs-product-context.tsx new
+178
@@ -0,0 +1,178 @@
1 +'use client';
2 +
3 +import {
4 + createContext,
5 + useCallback,
6 + useContext,
7 + useEffect,
8 + useMemo,
9 + useRef,
10 + useState,
11 + type ReactNode,
12 +} from 'react';
13 +import { flushSync } from 'react-dom';
14 +import { usePathname, useRouter } from 'next/navigation';
15 +import { useTheme } from 'fumadocs-ui/provider/base';
16 +import {
17 + classifyDocsProduct,
18 + DOCS_PRODUCTS,
19 + serializeDocsProductCookie,
20 + shouldAnimateDocsProductSwitch,
21 + type DocsProduct,
22 +} from '@/lib/home-navigation';
23 +
24 +interface DocsProductContextValue {
25 + product: DocsProduct;
26 + navigateToProduct: (
27 + product: DocsProduct,
28 + href: string,
29 + origin?: HTMLElement | null,
30 + ) => void;
31 + persistProduct: (product: DocsProduct) => void;
32 +}
33 +
34 +interface ViewTransitionHandle {
35 + finished: Promise<void>;
36 +}
37 +
38 +type ViewTransitionDocument = Document & {
39 + startViewTransition?: (
40 + update: () => void | Promise<void>,
41 + ) => ViewTransitionHandle;
42 +};
43 +
44 +const DocsProductContext = createContext<DocsProductContextValue | null>(null);
45 +
46 +function writeProductCookie(product: DocsProduct): void {
47 + document.cookie = serializeDocsProductCookie(product);
48 +}
49 +
50 +export function DocsProductProvider({
51 + initialProduct,
52 + children,
53 +}: {
54 + initialProduct: DocsProduct;
55 + children: ReactNode;
56 +}) {
57 + const pathname = usePathname();
58 + const router = useRouter();
59 + const { setTheme } = useTheme();
60 + const [persistedProduct, setPersistedProduct] = useState(initialProduct);
61 + const [pendingProduct, setPendingProduct] = useState<DocsProduct | null>(null);
62 + const pendingNavigation = useRef<{
63 + from: string;
64 + resolve: () => void;
65 + } | null>(null);
66 +
67 + const inferredProduct = classifyDocsProduct(pathname);
68 + const product = pendingProduct ?? inferredProduct ?? persistedProduct;
69 +
70 + const persistProduct = useCallback((nextProduct: DocsProduct) => {
71 + writeProductCookie(nextProduct);
72 + setPersistedProduct(nextProduct);
73 + }, []);
74 +
75 + useEffect(() => {
76 + if (inferredProduct) {
77 + writeProductCookie(inferredProduct);
78 + }
79 +
80 + if (pendingNavigation.current && pendingNavigation.current.from !== pathname) {
81 + pendingNavigation.current.resolve();
82 + pendingNavigation.current = null;
83 + }
84 +
85 + const frame = window.requestAnimationFrame(() => {
86 + if (inferredProduct) setPersistedProduct(inferredProduct);
87 + setPendingProduct(null);
88 + });
89 + return () => window.cancelAnimationFrame(frame);
90 + }, [inferredProduct, pathname]);
91 +
92 + useEffect(() => {
93 + return () => {
94 + pendingNavigation.current?.resolve();
95 + pendingNavigation.current = null;
96 + document.documentElement.classList.remove('docs-product-transition');
97 + };
98 + }, []);
99 +
100 + const navigateToProduct = useCallback(
101 + (nextProduct: DocsProduct, href: string, origin?: HTMLElement | null) => {
102 + const commitNavigation = () => {
103 + writeProductCookie(nextProduct);
104 + flushSync(() => {
105 + setPersistedProduct(nextProduct);
106 + setPendingProduct(nextProduct);
107 + setTheme(DOCS_PRODUCTS[nextProduct].defaultTheme);
108 + });
109 + router.push(href);
110 + };
111 +
112 + const viewTransitionDocument = document as ViewTransitionDocument;
113 + const reduceMotion = window.matchMedia('(prefers-reduced-motion: reduce)').matches;
114 + const startViewTransition =
115 + viewTransitionDocument.startViewTransition?.bind(viewTransitionDocument);
116 + const shouldAnimate = shouldAnimateDocsProductSwitch(
117 + typeof startViewTransition === 'function',
118 + reduceMotion,
119 + );
120 +
121 + if (!shouldAnimate || !startViewTransition) {
122 + commitNavigation();
123 + return;
124 + }
125 +
126 + const root = document.documentElement;
127 + const rect = origin?.getBoundingClientRect();
128 + root.style.setProperty('--docs-reveal-x', `${rect ? rect.left + rect.width / 2 : 32}px`);
129 + root.style.setProperty('--docs-reveal-y', `${rect ? rect.top + rect.height / 2 : 32}px`);
130 + root.classList.add('docs-product-transition');
131 +
132 + let cleaned = false;
133 + const cleanup = () => {
134 + if (cleaned) return;
135 + cleaned = true;
136 + root.classList.remove('docs-product-transition');
137 + root.style.removeProperty('--docs-reveal-x');
138 + root.style.removeProperty('--docs-reveal-y');
139 + };
140 + window.setTimeout(cleanup, 6000);
141 +
142 + try {
143 + const transition = startViewTransition(() => {
144 + return new Promise<void>(resolve => {
145 + pendingNavigation.current?.resolve();
146 + const timeout = window.setTimeout(resolve, 5000);
147 + pendingNavigation.current = {
148 + from: pathname,
149 + resolve: () => {
150 + window.clearTimeout(timeout);
151 + resolve();
152 + },
153 + };
154 + commitNavigation();
155 + });
156 + });
157 + void transition.finished.catch(() => undefined).finally(cleanup);
158 + } catch {
159 + cleanup();
160 + commitNavigation();
161 + }
162 + },
163 + [pathname, router, setTheme],
164 + );
165 +
166 + const value = useMemo(
167 + () => ({ product, navigateToProduct, persistProduct }),
168 + [navigateToProduct, persistProduct, product],
169 + );
170 +
171 + return <DocsProductContext.Provider value={value}>{children}</DocsProductContext.Provider>;
172 +}
173 +
174 +export function useDocsProduct(): DocsProductContextValue {
175 + const value = useContext(DocsProductContext);
176 + if (!value) throw new Error('useDocsProduct must be used inside DocsProductProvider');
177 + return value;
178 +}
docs/components/home-surfaces.tsx
+19 -74
@@ -1,8 +1,14 @@
1 -import Link from 'next/link';
1 import { ArrowUp, ArrowUpRight, Mic, Plus } from 'lucide-react';
2 import type { ComponentType } from 'react';
4 -import { HOME_INTENTS, homeIntentAnchor, type HomeIntent } from '@/lib/home-navigation';
3 +import {
4 + DOCS_PRODUCTS,
5 + HOME_INTENTS,
6 + homeIntentAnchor,
7 + type HomeIntent,
8 +} from '@/lib/home-navigation';
9 import { MOCK_FADE_STYLE } from './home-shared';
10 +import { ProductLockup } from './product-lockup';
11 +import { ProductSelectionLink } from './product-selection-link';
12
13 /**
14 * Each product is described by the same mock the dashboard onboarding
@@ -33,23 +39,18 @@ function IntentCard({ intent }: { intent: HomeIntent }) {
39
40 return (
41 <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)]">
36 - <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">
42 + <ProductSelectionLink
43 + aria-label={`Explore ${intent.product} docs`}
44 + 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"
45 + href={DOCS_PRODUCTS[intent.productId].landingRoute}
46 + product={intent.productId}
47 + >
48 <div className="relative z-[1] flex flex-col gap-2.5">
49 <h3
50 className="flex items-center gap-2"
51 id={homeIntentAnchor(intent.product)}
52 >
42 - <img
43 - alt="Composio"
44 - className="h-[22px] w-auto dark:hidden"
45 - src="/Composio Logo.svg"
46 - />
47 - <img
48 - alt="Composio"
49 - className="hidden h-[22px] w-auto dark:block"
50 - src="/Composio Logo Dark.svg"
51 - />
52 - <ProductBadge product={intent.product} />
53 + <ProductLockup product={intent.productId} />
54 </h3>
55 <p className="max-w-[42ch] text-pretty text-[14px] leading-[1.55] text-fd-foreground/70">
56 {intent.description}
@@ -58,13 +59,14 @@ function IntentCard({ intent }: { intent: HomeIntent }) {
59 <div aria-hidden="true" className="pointer-events-none select-none">
60 <Visual />
61 </div>
61 - </div>
62 + </ProductSelectionLink>
63 <ul className="flex flex-col divide-y divide-fd-border">
64 {intent.links.map(link => (
65 <li className="flex flex-1" key={link.href}>
65 - <Link
66 + <ProductSelectionLink
67 className="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"
68 href={link.href}
69 + product={intent.productId}
70 >
71 <span className="flex min-w-0 flex-col gap-0.5">
72 <span className="text-[14px] font-medium text-fd-foreground">
@@ -78,7 +80,7 @@ function IntentCard({ intent }: { intent: HomeIntent }) {
80 aria-hidden="true"
81 className="size-3.5 shrink-0 text-fd-foreground/50 transition-transform group-hover:-translate-y-px group-hover:translate-x-px"
82 />
81 - </Link>
83 + </ProductSelectionLink>
84 </li>
85 ))}
86 </ul>
@@ -86,63 +88,6 @@ function IntentCard({ intent }: { intent: HomeIntent }) {
88 );
89 }
90
89 -const PLATFORM_BADGE_GRADIENT =
90 - 'linear-gradient(135deg, #00e68a, #00b4d8, #0077ff)';
91 -
92 -/**
93 - * Port of the dashboard's `ComposioProductBadge` (composio_dashboard
94 - * `composio-product-badge.tsx`) so the docs fork and the dashboard product
95 - * switcher name the two products with the same mark.
96 - */
97 -function ProductBadge({ product }: { product: HomeIntent['product'] }) {
98 - const isPlatform = product === 'Platform';
99 -
100 - return (
101 - <span
102 - className={
103 - 'relative flex items-center rounded-[5px] px-[9px] py-[7px] font-mono text-[14px] font-semibold uppercase leading-none tracking-wide ' +
104 - (isPlatform
105 - ? 'product-badge-platform'
106 - : 'text-[#0007cd] dark:text-[#4d6fff]')
107 - }
108 - style={
109 - isPlatform
110 - ? {
111 - background: PLATFORM_BADGE_GRADIENT,
112 - backgroundClip: 'text',
113 - WebkitBackgroundClip: 'text',
114 - WebkitTextFillColor: 'transparent',
115 - }
116 - : undefined
117 - }
118 - >
119 - <span
120 - aria-hidden="true"
121 - className={
122 - 'pointer-events-none absolute inset-0 rounded-[5px] ' +
123 - (isPlatform
124 - ? 'product-badge-platform-border'
125 - : 'border border-[#0007cd] dark:border-[#4d6fff]')
126 - }
127 - style={
128 - isPlatform
129 - ? {
130 - padding: '1px',
131 - background: PLATFORM_BADGE_GRADIENT,
132 - WebkitMask:
133 - 'linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0)',
134 - WebkitMaskComposite: 'xor',
135 - mask: 'linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0)',
136 - maskComposite: 'exclude',
137 - }
138 - : undefined
139 - }
140 - />
141 - {product}
142 - </span>
143 - );
144 -}
145 -
91 const FOR_YOU_CLIENT_LOGOS = [
92 { src: '/images/clients/claude.svg', label: 'Claude' },
93 { src: '/images/clients/codex.png', label: 'Codex' },
docs/components/product-docs-layout.tsx new
+57
@@ -0,0 +1,57 @@
1 +'use client';
2 +
3 +import { useMemo, type ReactNode } from 'react';
4 +import type { Root } from 'fumadocs-core/page-tree';
5 +import { DocsLayout } from 'fumadocs-ui/layouts/docs';
6 +import { decorateSidebarBadges } from '@/lib/decorate-sidebar-badges';
7 +import { buildSidebarNavIndex } from '@/lib/sidebar-nav-index';
8 +import type { DocsProduct } from '@/lib/home-navigation';
9 +import { SidebarAnalytics } from './sidebar-analytics';
10 +import { useDocsProduct } from './docs-product-context';
11 +
12 +interface ProductDocsLayoutProps {
13 + children: ReactNode;
14 + trees: Record<DocsProduct, Root>;
15 + experimentalUrls: string[];
16 + newUrls: string[];
17 +}
18 +
19 +function ProductDocsLayoutInner({
20 + children,
21 + trees,
22 + experimentalUrls,
23 + newUrls,
24 +}: ProductDocsLayoutProps) {
25 + const { product } = useDocsProduct();
26 + const tree = useMemo(
27 + () => decorateSidebarBadges(
28 + trees[product],
29 + new Set(experimentalUrls),
30 + new Set(newUrls),
31 + ),
32 + [experimentalUrls, newUrls, product, trees],
33 + );
34 + const navIndex = useMemo(() => buildSidebarNavIndex(tree), [tree]);
35 +
36 + return (
37 + <DocsLayout
38 + containerProps={{ className: 'docs-product-shell' }}
39 + nav={{ enabled: true, title: null }}
40 + searchToggle={{ enabled: false }}
41 + sidebar={{
42 + collapsible: false,
43 + footer: null,
44 + tabs: false,
45 + }}
46 + themeSwitch={{ enabled: false }}
47 + tree={tree}
48 + >
49 + <SidebarAnalytics index={navIndex} />
50 + {children}
51 + </DocsLayout>
52 + );
53 +}
54 +
55 +export function ProductDocsLayout(props: ProductDocsLayoutProps) {
56 + return <ProductDocsLayoutInner {...props} />;
57 +}
docs/components/product-lockup.tsx new
+86
@@ -0,0 +1,86 @@
1 +import Image from 'next/image';
2 +import { DOCS_PRODUCTS, type DocsProduct } from '@/lib/home-navigation';
3 +
4 +const PLATFORM_BADGE_GRADIENT =
5 + 'linear-gradient(135deg, #00e68a, #00b4d8, #0077ff)';
6 +
7 +export function ProductBadge({ product }: { product: DocsProduct }) {
8 + const isPlatform = product === 'platform';
9 +
10 + return (
11 + <span
12 + className={
13 + 'relative flex items-center rounded-[5px] px-[9px] py-[7px] font-mono text-[14px] font-semibold uppercase leading-none tracking-wide ' +
14 + (isPlatform
15 + ? 'product-badge-platform'
16 + : 'text-[#0007cd] dark:text-[#4d6fff]')
17 + }
18 + style={
19 + isPlatform
20 + ? {
21 + background: PLATFORM_BADGE_GRADIENT,
22 + backgroundClip: 'text',
23 + WebkitBackgroundClip: 'text',
24 + WebkitTextFillColor: 'transparent',
25 + }
26 + : undefined
27 + }
28 + >
29 + <span
30 + aria-hidden="true"
31 + className={
32 + 'pointer-events-none absolute inset-0 rounded-[5px] ' +
33 + (isPlatform
34 + ? 'product-badge-platform-border'
35 + : 'border border-[#0007cd] dark:border-[#4d6fff]')
36 + }
37 + style={
38 + isPlatform
39 + ? {
40 + padding: '1px',
41 + background: PLATFORM_BADGE_GRADIENT,
42 + WebkitMask:
43 + 'linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0)',
44 + WebkitMaskComposite: 'xor',
45 + mask: 'linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0)',
46 + maskComposite: 'exclude',
47 + }
48 + : undefined
49 + }
50 + />
51 + {DOCS_PRODUCTS[product].product}
52 + </span>
53 + );
54 +}
55 +
56 +export function ProductLockup({
57 + product,
58 + compactOnMobile = false,
59 +}: {
60 + product: DocsProduct;
61 + compactOnMobile?: boolean;
62 +}) {
63 + return (
64 + <span className="inline-flex min-w-0 items-center gap-2">
65 + <span className={compactOnMobile ? 'max-[420px]:hidden' : undefined}>
66 + <Image
67 + alt="Composio"
68 + className="h-[22px] w-auto dark:hidden"
69 + height={20}
70 + priority
71 + src="/Composio Logo.svg"
72 + width={110}
73 + />
74 + <Image
75 + alt="Composio"
76 + className="hidden h-[22px] w-auto dark:block"
77 + height={20}
78 + priority
79 + src="/Composio Logo Dark.svg"
80 + width={110}
81 + />
82 + </span>
83 + <ProductBadge product={product} />
84 + </span>
85 + );
86 +}
docs/components/product-selection-link.tsx new
+43
@@ -0,0 +1,43 @@
1 +'use client';
2 +
3 +import Link, { type LinkProps } from 'next/link';
4 +import type { AnchorHTMLAttributes, MouseEvent, ReactNode } from 'react';
5 +import type { DocsProduct } from '@/lib/home-navigation';
6 +import { useDocsProduct } from './docs-product-context';
7 +
8 +type ProductSelectionLinkProps = LinkProps &
9 + Omit<AnchorHTMLAttributes<HTMLAnchorElement>, keyof LinkProps> & {
10 + children: ReactNode;
11 + product: DocsProduct;
12 + };
13 +
14 +export function ProductSelectionLink({
15 + product,
16 + href,
17 + children,
18 + onClick,
19 + ...props
20 +}: ProductSelectionLinkProps) {
21 + const { navigateToProduct, persistProduct } = useDocsProduct();
22 +
23 + const handleClick = (event: MouseEvent<HTMLAnchorElement>) => {
24 + onClick?.(event);
25 + if (event.defaultPrevented) return;
26 +
27 + const modified =
28 + event.button !== 0 || event.metaKey || event.ctrlKey || event.shiftKey || event.altKey;
29 + if (modified || props.target === '_blank') {
30 + persistProduct(product);
31 + return;
32 + }
33 +
34 + event.preventDefault();
35 + navigateToProduct(product, String(href), event.currentTarget);
36 + };
37 +
38 + return (
39 + <Link href={href} onClick={handleClick} {...props}>
40 + {children}
41 + </Link>
42 + );
43 +}
docs/components/product-switcher.tsx new
+126
@@ -0,0 +1,126 @@
1 +'use client';
2 +
3 +import { useRef, useState } from 'react';
4 +import type { ComponentProps } from 'react';
5 +import { usePathname, useRouter } from 'next/navigation';
6 +import { Check, ChevronsUpDown } from 'lucide-react';
7 +import {
8 + Popover,
9 + PopoverContent,
10 + PopoverTrigger,
11 +} from 'fumadocs-ui/components/ui/popover';
12 +import {
13 + DOCS_PRODUCT_ORDER,
14 + DOCS_PRODUCTS,
15 + docsProductDestination,
16 + type DocsProduct,
17 +} from '@/lib/home-navigation';
18 +import { ProductLockup } from './product-lockup';
19 +import { useDocsProduct } from './docs-product-context';
20 +import { cn } from '@/lib/utils';
21 +
22 +export function ProductSwitcher({ placement = 'sidebar' }: { placement?: 'nav' | 'sidebar' }) {
23 + const pathname = usePathname();
24 + const router = useRouter();
25 + const { product, navigateToProduct } = useDocsProduct();
26 + const [open, setOpen] = useState(false);
27 + const triggerRef = useRef<HTMLButtonElement>(null);
28 + const current = DOCS_PRODUCTS[product];
29 +
30 + const selectProduct = (nextProduct: DocsProduct) => {
31 + if (nextProduct === product) {
32 + setOpen(false);
33 + return;
34 + }
35 +
36 + const destination = docsProductDestination(pathname, nextProduct);
37 + setOpen(false);
38 + navigateToProduct(nextProduct, destination, triggerRef.current);
39 + };
40 +
41 + return (
42 + <Popover open={open} onOpenChange={setOpen}>
43 + <PopoverTrigger asChild>
44 + <button
45 + aria-expanded={open}
46 + aria-haspopup="dialog"
47 + aria-label={`Switch Composio product. Current product: ${current.product}`}
48 + className={cn(
49 + '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',
50 + placement === 'nav'
51 + ? 'h-10 min-w-0 px-1.5 max-sm:gap-1'
52 + : 'min-h-14 w-full justify-between border border-fd-border bg-fd-background px-3 py-2 shadow-xs',
53 + )}
54 + onFocus={() => {
55 + for (const productId of DOCS_PRODUCT_ORDER) {
56 + if (productId !== product) {
57 + router.prefetch(docsProductDestination(pathname, productId));
58 + }
59 + }
60 + }}
61 + onMouseEnter={() => {
62 + for (const productId of DOCS_PRODUCT_ORDER) {
63 + if (productId !== product) {
64 + router.prefetch(docsProductDestination(pathname, productId));
65 + }
66 + }
67 + }}
68 + ref={triggerRef}
69 + type="button"
70 + >
71 + <ProductLockup compactOnMobile={placement === 'nav'} product={product} />
72 + <span className="inline-flex shrink-0 items-center gap-1 text-xs font-medium text-fd-muted-foreground group-hover:text-fd-foreground">
73 + {placement === 'sidebar' && 'Switch'}
74 + <ChevronsUpDown aria-hidden="true" className="size-3.5" />
75 + </span>
76 + </button>
77 + </PopoverTrigger>
78 + <PopoverContent
79 + align="start"
80 + className="w-[min(20rem,calc(100vw-2rem))] p-1"
81 + side="bottom"
82 + sideOffset={8}
83 + >
84 + <div aria-label="Choose a Composio product" role="radiogroup">
85 + {DOCS_PRODUCT_ORDER.map((productId, index) => {
86 + const option = DOCS_PRODUCTS[productId];
87 + const isCurrent = productId === product;
88 + return (
89 + <div key={productId}>
90 + {index > 0 && <div aria-hidden="true" className="mx-2 my-1 h-px bg-fd-border" />}
91 + <button
92 + aria-checked={isCurrent}
93 + aria-current={isCurrent ? 'page' : undefined}
94 + aria-label={`${option.product}: ${option.switcherDescription}`}
95 + 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"
96 + onClick={() => selectProduct(productId)}
97 + role="radio"
98 + type="button"
99 + >
100 + <span className="flex min-w-0 flex-1 flex-col gap-2">
101 + <ProductLockup product={productId} />
102 + <span className="text-sm font-normal text-fd-muted-foreground">
103 + {option.switcherDescription}
104 + </span>
105 + </span>
106 + <Check
107 + aria-hidden="true"
108 + className={`mt-1 size-4 shrink-0 text-fd-primary ${isCurrent ? '' : 'invisible'}`}
109 + />
110 + </button>
111 + </div>
112 + );
113 + })}
114 + </div>
115 + </PopoverContent>
116 + </Popover>
117 + );
118 +}
119 +
120 +export function ProductNavTitle({ className }: ComponentProps<'a'>) {
121 + return (
122 + <div className={cn(className, 'min-w-0')}>
123 + <ProductSwitcher placement="nav" />
124 + </div>
125 + );
126 +}
docs/components/product-transition-loader.tsx new
+30
@@ -0,0 +1,30 @@
1 +'use client';
2 +
3 +import { useEffect } from 'react';
4 +
5 +export function ProductTransitionLoader() {
6 + useEffect(() => {
7 + if (typeof CSS === 'undefined' || !('paintWorklet' in CSS)) return;
8 +
9 + const properties = [
10 + { name: '--docs-reveal-radius', syntax: '<percentage>', initialValue: '0%' },
11 + { name: '--docs-pixel-size', syntax: '<number>', initialValue: '20' },
12 + { name: '--docs-dissolve-amount', syntax: '<number>', initialValue: '0.65' },
13 + ];
14 +
15 + for (const property of properties) {
16 + try {
17 + CSS.registerProperty({ ...property, inherits: false });
18 + } catch {
19 + // The CSS @property rule or React Strict Mode may register it first.
20 + }
21 + }
22 +
23 + const paintWorklet = (CSS as typeof CSS & {
24 + paintWorklet: { addModule: (url: string) => Promise<void> };
25 + }).paintWorklet;
26 + void paintWorklet.addModule('/pixelated-circle-worklet.js').catch(() => undefined);
27 + }, []);
28 +
29 + return null;
30 +}
docs/lib/home-navigation.ts
+219 -37
@@ -1,3 +1,14 @@
1 +export type DocsProduct = 'for-you' | 'platform';
2 +
3 +export type ProductSidebarItem =
4 + | { type: 'page'; url: string; label?: string }
5 + | { type: 'folder'; path: string; label?: string };
6 +
7 +export interface ProductSidebarGroup {
8 + label: string;
9 + items: readonly ProductSidebarItem[];
10 +}
11 +
12 export interface HomeIntentLink {
13 title: string;
14 description: string;
@@ -6,60 +17,231 @@ export interface HomeIntentLink {
17
18 export interface HomeIntent {
19 id: 'build' | 'use';
20 + productId: DocsProduct;
21 product: 'Platform' | 'For You';
22 title: string;
23 description: string;
12 - links: HomeIntentLink[];
24 + links: readonly HomeIntentLink[];
25 }
26
15 -export const HOME_INTENTS: HomeIntent[] = [
16 - {
17 - id: 'build',
18 - product: 'Platform',
19 - title: 'Build with Composio',
20 - description: 'Build Composio into your own agent or application — tools, auth, and triggers for every one of your users.',
21 - links: [
22 - {
23 - title: 'Quickstart',
24 - description: 'Build an agent that discovers tools and works across your apps.',
25 - href: '/docs/quickstart',
26 - },
27 - {
28 - title: 'Framework guides',
29 - description: 'Use OpenAI, Anthropic, Vercel AI SDK, or another framework.',
30 - href: '/docs/providers',
31 - },
27 +interface DocsProductConfig {
28 + id: DocsProduct;
29 + product: HomeIntent['product'];
30 + switcherDescription: string;
31 + landingRoute: string;
32 + defaultTheme: 'light' | 'dark';
33 + routePrefixes: readonly string[];
34 + sidebar: readonly ProductSidebarGroup[];
35 + home: Omit<HomeIntent, 'productId' | 'product'>;
36 +}
37 +
38 +const SHARED_SIDEBAR_ITEMS = [
39 + { type: 'page', url: '/docs', label: 'Choose a product' },
40 + { type: 'folder', path: 'security', label: 'Security and data' },
41 +] as const satisfies readonly ProductSidebarItem[];
42 +
43 +/**
44 + * Canonical product model for the docs shell and homepage.
45 + *
46 + * Platform is the documented first-visit default because it preserves the
47 + * existing SDK-first docs behavior. Audience-specific URLs take precedence,
48 + * followed by the persisted cookie on shared URLs.
49 + */
50 +export const DEFAULT_DOCS_PRODUCT: DocsProduct = 'platform';
51 +export const DOCS_PRODUCT_COOKIE = 'composio-docs-product';
52 +export const DOCS_PRODUCT_HEADER = 'x-composio-docs-product';
53 +
54 +export const DOCS_PRODUCTS = {
55 + 'for-you': {
56 + id: 'for-you',
57 + product: 'For You',
58 + switcherDescription: 'Connect your apps to AI clients.',
59 + landingRoute: '/docs/agent-plugins',
60 + defaultTheme: 'light',
61 + routePrefixes: [
62 + '/docs/agent-plugins',
63 + '/docs/claude-code-plugin',
64 + '/docs/cli',
65 + '/docs/composio-connect',
66 + ],
67 + sidebar: [
68 {
33 - title: 'Sessions via MCP',
34 - description: 'Expose a Composio session through a hosted MCP endpoint.',
35 - href: '/docs/sessions-via-mcp',
69 + label: 'Get started',
70 + items: [
71 + { type: 'page', url: '/docs/agent-plugins' },
72 + { type: 'page', url: '/docs/cli' },
73 + { type: 'page', url: '/docs/composio-connect', label: 'Connect with MCP' },
74 + ],
75 },
76 + { label: 'Shared resources', items: SHARED_SIDEBAR_ITEMS },
77 ],
78 + home: {
79 + id: 'use',
80 + title: 'Use Composio',
81 + description: 'Use Composio from the agents you already have — Claude Code, Codex, Cursor, or your terminal.',
82 + links: [
83 + {
84 + title: 'Agent plugins',
85 + description: 'Install the native Composio plugin for Codex or Claude Code.',
86 + href: '/docs/agent-plugins',
87 + },
88 + {
89 + title: 'Composio CLI',
90 + description: 'Search, connect, and run tools from your terminal.',
91 + href: '/docs/cli',
92 + },
93 + {
94 + title: 'Connect over MCP',
95 + description: 'Use Composio with Cursor or another existing MCP client.',
96 + href: '/docs/composio-connect',
97 + },
98 + ],
99 + },
100 },
39 - {
40 - id: 'use',
41 - product: 'For You',
42 - title: 'Use Composio',
43 - description: 'Use Composio from the agents you already have — Claude Code, Codex, Cursor, or your terminal.',
44 - links: [
101 + platform: {
102 + id: 'platform',
103 + product: 'Platform',
104 + switcherDescription: 'Build agents with the Composio SDK.',
105 + landingRoute: '/docs/quickstart',
106 + defaultTheme: 'dark',
107 + routePrefixes: [
108 + '/docs/quickstart',
109 + '/docs/providers',
110 + '/docs/how-composio-works',
111 + '/docs/configuring-sessions',
112 + '/docs/authentication',
113 + '/docs/triggers',
114 + '/docs/skills',
115 + '/docs/sessions-via-mcp',
116 + '/docs/sandbox',
117 + '/docs/extending-sessions',
118 + '/docs/setting-up-triggers',
119 + '/docs/sessions-vs-direct-execution',
120 + '/docs/tools-direct',
121 + '/docs/auth-configuration',
122 + '/docs/migration-guide',
123 + '/docs/single-toolkit-mcp',
124 + ],
125 + sidebar: [
126 {
46 - title: 'Agent plugins',
47 - description: 'Install the native Composio plugin for Codex or Claude Code.',
48 - href: '/docs/agent-plugins',
127 + label: 'Get started',
128 + items: [
129 + { type: 'page', url: '/docs/quickstart' },
130 + { type: 'folder', path: 'providers', label: 'SDKs and frameworks' },
131 + ],
132 },
133 {
51 - title: 'Composio CLI',
52 - description: 'Search, connect, and run tools from your terminal.',
53 - href: '/docs/cli',
134 + label: 'Build with Composio',
135 + items: [
136 + { type: 'page', url: '/docs/how-composio-works', label: 'Sessions' },
137 + { type: 'page', url: '/docs/configuring-sessions' },
138 + { type: 'folder', path: 'authentication' },
139 + { type: 'page', url: '/docs/skills', label: 'Tools and skills' },
140 + { type: 'page', url: '/docs/triggers' },
141 + ],
142 },
143 {
56 - title: 'Connect over MCP',
57 - description: 'Use Composio with Cursor or another existing MCP client.',
58 - href: '/docs/composio-connect',
144 + label: 'Guides',
145 + items: [
146 + { type: 'page', url: '/docs/sessions-via-mcp' },
147 + { type: 'folder', path: 'sandbox' },
148 + { type: 'folder', path: 'extending-sessions' },
149 + { type: 'folder', path: 'setting-up-triggers' },
150 + ],
151 },
152 + {
153 + label: 'Migration and legacy',
154 + items: [
155 + { type: 'folder', path: 'migration-guide' },
156 + { type: 'page', url: '/docs/sessions-vs-direct-execution' },
157 + { type: 'folder', path: 'tools-direct' },
158 + { type: 'folder', path: 'auth-configuration' },
159 + ],
160 + },
161 + { label: 'Shared resources', items: SHARED_SIDEBAR_ITEMS },
162 ],
163 + home: {
164 + id: 'build',
165 + title: 'Build with Composio',
166 + description: 'Build Composio into your own agent or application — tools, auth, and triggers for every one of your users.',
167 + links: [
168 + {
169 + title: 'Quickstart',
170 + description: 'Build an agent that discovers tools and works across your apps.',
171 + href: '/docs/quickstart',
172 + },
173 + {
174 + title: 'Framework guides',
175 + description: 'Use OpenAI, Anthropic, Vercel AI SDK, or another framework.',
176 + href: '/docs/providers',
177 + },
178 + {
179 + title: 'Sessions via MCP',
180 + description: 'Expose a Composio session through a hosted MCP endpoint.',
181 + href: '/docs/sessions-via-mcp',
182 + },
183 + ],
184 + },
185 },
62 -];
186 +} as const satisfies Record<DocsProduct, DocsProductConfig>;
187 +
188 +export const DOCS_PRODUCT_ORDER = ['for-you', 'platform'] as const;
189 +const HOME_PRODUCT_ORDER = ['platform', 'for-you'] as const;
190 +
191 +export const HOME_INTENTS: readonly HomeIntent[] = HOME_PRODUCT_ORDER.map(productId => {
192 + const config = DOCS_PRODUCTS[productId];
193 + return { ...config.home, productId, product: config.product };
194 +});
195 +
196 +const PRODUCT_COUNTERPARTS = [
197 + { platform: '/docs/quickstart', 'for-you': '/docs/agent-plugins' },
198 + { platform: '/docs/sessions-via-mcp', 'for-you': '/docs/composio-connect' },
199 +] as const;
200 +
201 +function matchesRoute(pathname: string, prefix: string): boolean {
202 + return pathname === prefix || pathname.startsWith(`${prefix}/`);
203 +}
204 +
205 +export function parseDocsProduct(value: string | null | undefined): DocsProduct | null {
206 + return value === 'for-you' || value === 'platform' ? value : null;
207 +}
208 +
209 +export function classifyDocsProduct(pathname: string): DocsProduct | null {
210 + for (const productId of DOCS_PRODUCT_ORDER) {
211 + if (DOCS_PRODUCTS[productId].routePrefixes.some(prefix => matchesRoute(pathname, prefix))) {
212 + return productId;
213 + }
214 + }
215 + return null;
216 +}
217 +
218 +export function resolveDocsProduct(
219 + pathname: string,
220 + persistedProduct?: string | null,
221 +): DocsProduct {
222 + return (
223 + classifyDocsProduct(pathname) ??
224 + parseDocsProduct(persistedProduct) ??
225 + DEFAULT_DOCS_PRODUCT
226 + );
227 +}
228 +
229 +export function docsProductDestination(pathname: string, target: DocsProduct): string {
230 + const sourceProduct = target === 'platform' ? 'for-you' : 'platform';
231 + const counterpart = PRODUCT_COUNTERPARTS.find(pair => matchesRoute(pathname, pair[sourceProduct]));
232 + return counterpart?.[target] ?? DOCS_PRODUCTS[target].landingRoute;
233 +}
234 +
235 +export function serializeDocsProductCookie(product: DocsProduct): string {
236 + return `${DOCS_PRODUCT_COOKIE}=${product}; Path=/; Max-Age=31536000; SameSite=Lax`;
237 +}
238 +
239 +export function shouldAnimateDocsProductSwitch(
240 + supportsViewTransitions: boolean,
241 + prefersReducedMotion: boolean,
242 +): boolean {
243 + return supportsViewTransitions && !prefersReducedMotion;
244 +}
245
246 /**
247 * Slugify an intent's heading label into an anchor id. Called with
docs/lib/layout.shared.tsx
+2
@@ -3,6 +3,7 @@ import Image from 'next/image';
3 import { Play } from 'lucide-react';
4 import { SearchAndAskAI, SearchAndAskAIMobile } from '@/components/ask-ai-button';
5 import { NavVersionSelector } from '@/components/version-selector';
6 +import { ProductNavTitle } from '@/components/product-switcher';
7
8 // Composio Logo Component with light/dark mode switching
9 function ComposioLogo() {
@@ -36,6 +37,7 @@ export function baseOptions(): BaseLayoutProps {
37 title: <ComposioLogo />,
38 transparentMode: 'top',
39 },
40 + slots: { navTitle: ProductNavTitle },
41 themeSwitch: { enabled: true, mode: 'light-dark-system' },
42 searchToggle: {
43 components: {
docs/lib/product-page-tree.ts new
+71
@@ -0,0 +1,71 @@
1 +import type { Folder, Item, Node, Root } from 'fumadocs-core/page-tree';
2 +import {
3 + DOCS_PRODUCTS,
4 + type DocsProduct,
5 + type ProductSidebarItem,
6 +} from './home-navigation';
7 +
8 +function findPage(nodes: Node[], url: string): Item | null {
9 + for (const node of nodes) {
10 + if (node.type === 'page' && node.url === url) return node;
11 + if (node.type === 'folder') {
12 + if (node.index?.url === url) return node.index;
13 + const nested = findPage(node.children, url);
14 + if (nested) return nested;
15 + }
16 + }
17 + return null;
18 +}
19 +
20 +function findFolder(nodes: Node[], path: string): Folder | null {
21 + for (const node of nodes) {
22 + if (node.type !== 'folder') continue;
23 + if (node.$ref?.folder === path) return node;
24 + const nested = findFolder(node.children, path);
25 + if (nested) return nested;
26 + }
27 + return null;
28 +}
29 +
30 +function resolveSidebarItem(tree: Root, item: ProductSidebarItem): Node {
31 + const sourceNode =
32 + item.type === 'page'
33 + ? findPage(tree.children, item.url)
34 + : findFolder(tree.children, item.path);
35 +
36 + if (!sourceNode) {
37 + const target = item.type === 'page' ? item.url : item.path;
38 + throw new Error(`Product sidebar target does not exist: ${target}`);
39 + }
40 +
41 + return item.label ? { ...sourceNode, name: item.label } : sourceNode;
42 +}
43 +
44 +export function buildProductPageTree(tree: Root, product: DocsProduct): Root {
45 + const children = DOCS_PRODUCTS[product].sidebar.flatMap(group => [
46 + { type: 'separator' as const, name: group.label },
47 + ...group.items.map(item => resolveSidebarItem(tree, item)),
48 + ]);
49 +
50 + // Fumadocs memoizes trees by root ID, so each audience needs a distinct ID
51 + // for client-side product switches to replace the sidebar immediately.
52 + return { ...tree, $id: `docs-product:${product}`, children };
53 +}
54 +
55 +export function pageTreeUrls(tree: Root): string[] {
56 + const urls: string[] = [];
57 +
58 + function visit(nodes: Node[]): void {
59 + for (const node of nodes) {
60 + if (node.type === 'page') {
61 + urls.push(node.url);
62 + } else if (node.type === 'folder') {
63 + if (node.index) urls.push(node.index.url);
64 + visit(node.children);
65 + }
66 + }
67 + }
68 +
69 + visit(tree.children);
70 + return urls;
71 +}
docs/proxy.ts
+15 -2
@@ -1,4 +1,9 @@
1 import { NextRequest, NextResponse } from 'next/server';
2 +import {
3 + DOCS_PRODUCT_COOKIE,
4 + DOCS_PRODUCT_HEADER,
5 + resolveDocsProduct,
6 +} from './lib/home-navigation';
7
8 /**
9 * Convert kebab-case to camelCase
@@ -11,7 +16,8 @@ function kebabToCamel(str: string): string {
16 * Proxy handles:
17 * 1. Markdown content negotiation for AI agents (Accept: text/markdown)
18 * 2. Redirects for old Fern API reference URLs (kebab-case → camelCase)
14 - * 3. Sets x-pathname header for 404 logging
19 + * 3. Resolves the server-rendered docs product from URL + cookie
20 + * 4. Sets x-pathname header for 404 logging
21 */
22 export function proxy(request: NextRequest) {
23 const { pathname } = request.nextUrl;
@@ -49,7 +55,14 @@ export function proxy(request: NextRequest) {
55 }
56 }
57
52 - const response = NextResponse.next();
58 + const requestHeaders = new Headers(request.headers);
59 + const product = resolveDocsProduct(
60 + pathname,
61 + request.cookies.get(DOCS_PRODUCT_COOKIE)?.value,
62 + );
63 + requestHeaders.set(DOCS_PRODUCT_HEADER, product);
64 +
65 + const response = NextResponse.next({ request: { headers: requestHeaders } });
66 response.headers.set('x-pathname', pathname);
67 return response;
68 }
docs/public/pixelated-circle-worklet.js new
+66
@@ -0,0 +1,66 @@
1 +// Runs in the CSS Paint Worklet global scope, not as an application module.
2 +class PixelatedCirclePainter {
3 + static get inputProperties() {
4 + return [
5 + '--docs-reveal-x',
6 + '--docs-reveal-y',
7 + '--docs-reveal-radius',
8 + '--docs-pixel-size',
9 + '--docs-dissolve-amount',
10 + ];
11 + }
12 +
13 + hash(x, y) {
14 + const value = Math.sin(x * 12.9898 + y * 78.233) * 43758.5453;
15 + return value - Math.floor(value);
16 + }
17 +
18 + paint(context, size, properties) {
19 + const readNumber = (name, fallback) => {
20 + const value = Number.parseFloat(properties.get(name));
21 + return Number.isNaN(value) ? fallback : value;
22 + };
23 + const centerX = readNumber('--docs-reveal-x', 32);
24 + const centerY = readNumber('--docs-reveal-y', 32);
25 + const radiusPercent = readNumber('--docs-reveal-radius', 0);
26 + const pixelSize = readNumber('--docs-pixel-size', 20);
27 + const dissolveAmount = Math.min(
28 + 1,
29 + Math.max(0, readNumber('--docs-dissolve-amount', 0.65)),
30 + );
31 + const diagonal = Math.sqrt(size.width ** 2 + size.height ** 2);
32 + const baseRadius = (radiusPercent / 100) * diagonal;
33 + const radiusScale = dissolveAmount < 0.95 ? 1 / (1 - dissolveAmount) : 20;
34 + const radius = baseRadius * radiusScale;
35 + const innerEdge = radius * (1 - dissolveAmount);
36 + const fuzzyWidth = radius - innerEdge;
37 +
38 + for (let x = 0; x < size.width; x += pixelSize) {
39 + for (let y = 0; y < size.height; y += pixelSize) {
40 + const distance = Math.sqrt(
41 + (x + pixelSize / 2 - centerX) ** 2 +
42 + (y + pixelSize / 2 - centerY) ** 2,
43 + );
44 + let opacity = 0;
45 +
46 + if (distance <= innerEdge) {
47 + opacity = 1;
48 + } else if (distance <= radius && fuzzyWidth > 0) {
49 + const distanceOpacity = 1 - (distance - innerEdge) / fuzzyWidth;
50 + if (this.hash(x / pixelSize, y / pixelSize) < distanceOpacity) {
51 + opacity =
52 + distanceOpacity *
53 + (0.5 + 0.5 * this.hash(y / pixelSize, x / pixelSize));
54 + }
55 + }
56 +
57 + if (opacity > 0) {
58 + context.fillStyle = `rgba(0, 0, 0, ${opacity})`;
59 + context.fillRect(x, y, pixelSize, pixelSize);
60 + }
61 + }
62 + }
63 + }
64 +}
65 +
66 +registerPaint('docs-pixelated-circle', PixelatedCirclePainter);
docs/tests/static/home-navigation.test.ts
+14 -9
@@ -49,6 +49,9 @@ describe('Welcome navigation', () => {
49 const source = await Bun.file(
50 new URL('../../components/home-surfaces.tsx', import.meta.url)
51 ).text();
52 + const lockupSource = await Bun.file(
53 + new URL('../../components/product-lockup.tsx', import.meta.url)
54 + ).text();
55
56 expect(source).toContain('id="two-ways-to-start"');
57 for (const intent of HOME_INTENTS) {
@@ -60,18 +63,20 @@ describe('Welcome navigation', () => {
63 // same mock the dashboard onboarding path step uses for that product: an
64 // agent chat composer plus client logos for For You, the SDK in a code
65 // window for Platform.
63 - expect(source).toContain('ProductBadge');
64 - expect(source).toContain('background: PLATFORM_BADGE_GRADIENT');
65 - expect(source).toContain("backgroundClip: 'text'");
66 - expect(source).toContain("WebkitTextFillColor: 'transparent'");
67 - expect(source).toContain("mask: 'linear-gradient(#fff 0 0) content-box");
68 - expect(source).toContain('text-[#0007cd] dark:text-[#4d6fff]');
69 - expect(source).toContain('product-badge-platform-border');
70 - expect(source).toContain('/Composio Logo.svg');
66 + expect(source).toContain('ProductLockup');
67 + expect(source).toContain('ProductSelectionLink');
68 + expect(lockupSource).toContain('ProductBadge');
69 + expect(lockupSource).toContain('background: PLATFORM_BADGE_GRADIENT');
70 + expect(lockupSource).toContain("backgroundClip: 'text'");
71 + expect(lockupSource).toContain("WebkitTextFillColor: 'transparent'");
72 + expect(lockupSource).toContain("mask: 'linear-gradient(#fff 0 0) content-box");
73 + expect(lockupSource).toContain('text-[#0007cd] dark:text-[#4d6fff]');
74 + expect(lockupSource).toContain('product-badge-platform-border');
75 + expect(lockupSource).toContain('/Composio Logo.svg');
76 // Both logo variants carry the same alt: `dark:hidden` / `hidden dark:block`
77 // swap them in CSS, so an aria-hidden dark variant would drop "Composio"
78 // from the heading's accessible name in dark mode only.
74 - expect(source.match(/alt="Composio"/g) ?? []).toHaveLength(2);
79 + expect(lockupSource.match(/alt="Composio"/g) ?? []).toHaveLength(2);
80 expect(source).toContain('INTENT_VISUALS');
81 expect(source).toContain('How can I help?');
82 expect(source).toContain('composio.create');
docs/tests/static/product-navigation.test.ts new
+127
@@ -0,0 +1,127 @@
1 +import { describe, expect, test } from 'bun:test';
2 +
3 +import {
4 + classifyDocsProduct,
5 + DEFAULT_DOCS_PRODUCT,
6 + DOCS_PRODUCTS,
7 + docsProductDestination,
8 + parseDocsProduct,
9 + resolveDocsProduct,
10 + serializeDocsProductCookie,
11 + shouldAnimateDocsProductSwitch,
12 +} from '../../lib/home-navigation';
13 +import { buildProductPageTree, pageTreeUrls } from '../../lib/product-page-tree';
14 +import { source } from '../../lib/source';
15 +
16 +describe('Docs product navigation', () => {
17 + test('defines the product labels, descriptions, landings, and theme defaults once', () => {
18 + expect(DEFAULT_DOCS_PRODUCT).toBe('platform');
19 + expect(DOCS_PRODUCTS['for-you']).toMatchObject({
20 + product: 'For You',
21 + switcherDescription: 'Connect your apps to AI clients.',
22 + landingRoute: '/docs/agent-plugins',
23 + defaultTheme: 'light',
24 + });
25 + expect(DOCS_PRODUCTS.platform).toMatchObject({
26 + product: 'Platform',
27 + switcherDescription: 'Build agents with the Composio SDK.',
28 + landingRoute: '/docs/quickstart',
29 + defaultTheme: 'dark',
30 + });
31 + });
32 +
33 + test('classifies audience routes while leaving shared routes unclassified', () => {
34 + expect(classifyDocsProduct('/docs/agent-plugins')).toBe('for-you');
35 + expect(classifyDocsProduct('/docs/composio-connect')).toBe('for-you');
36 + expect(classifyDocsProduct('/docs/providers/openai')).toBe('platform');
37 + expect(classifyDocsProduct('/docs/authentication/controlling-scopes')).toBe('platform');
38 + expect(classifyDocsProduct('/docs')).toBeNull();
39 + expect(classifyDocsProduct('/docs/security/overview')).toBeNull();
40 + });
41 +
42 + test('uses route inference before persistence and the documented default last', () => {
43 + expect(resolveDocsProduct('/docs/quickstart', 'for-you')).toBe('platform');
44 + expect(resolveDocsProduct('/docs/security/overview', 'for-you')).toBe('for-you');
45 + expect(resolveDocsProduct('/docs/security/overview', 'platform')).toBe('platform');
46 + expect(resolveDocsProduct('/docs', 'invalid')).toBe('platform');
47 + expect(parseDocsProduct('for-you')).toBe('for-you');
48 + expect(parseDocsProduct('anything-else')).toBeNull();
49 + expect(serializeDocsProductCookie('for-you')).toContain(
50 + 'composio-docs-product=for-you',
51 + );
52 + expect(serializeDocsProductCookie('for-you')).toContain('SameSite=Lax');
53 + });
54 +
55 + test('uses meaningful counterparts and otherwise falls back to product landings', () => {
56 + expect(docsProductDestination('/docs/quickstart', 'for-you')).toBe(
57 + '/docs/agent-plugins',
58 + );
59 + expect(docsProductDestination('/docs/agent-plugins', 'platform')).toBe(
60 + '/docs/quickstart',
61 + );
62 + expect(docsProductDestination('/docs/sessions-via-mcp', 'for-you')).toBe(
63 + '/docs/composio-connect',
64 + );
65 + expect(docsProductDestination('/docs/composio-connect', 'platform')).toBe(
66 + '/docs/sessions-via-mcp',
67 + );
68 + expect(docsProductDestination('/docs/authentication', 'for-you')).toBe(
69 + '/docs/agent-plugins',
70 + );
71 + expect(docsProductDestination('/docs/cli', 'platform')).toBe('/docs/quickstart');
72 + });
73 +
74 + test('animates only when view transitions are available and motion is allowed', () => {
75 + expect(shouldAnimateDocsProductSwitch(true, false)).toBe(true);
76 + expect(shouldAnimateDocsProductSwitch(false, false)).toBe(false);
77 + expect(shouldAnimateDocsProductSwitch(true, true)).toBe(false);
78 + });
79 +
80 + test('builds audience-specific trees and keeps shared pages in both', () => {
81 + const forYouTree = buildProductPageTree(source.pageTree, 'for-you');
82 + const platformTree = buildProductPageTree(source.pageTree, 'platform');
83 + const forYouUrls = pageTreeUrls(forYouTree);
84 + const platformUrls = pageTreeUrls(platformTree);
85 +
86 + expect(forYouTree.$id).not.toBe(platformTree.$id);
87 +
88 + expect(forYouUrls).toContain('/docs/agent-plugins');
89 + expect(forYouUrls).toContain('/docs/cli');
90 + expect(forYouUrls).toContain('/docs/composio-connect');
91 + expect(forYouUrls).not.toContain('/docs/quickstart');
92 +
93 + for (const url of [
94 + '/docs/quickstart',
95 + '/docs/providers',
96 + '/docs/how-composio-works',
97 + '/docs/authentication',
98 + '/docs/skills',
99 + '/docs/triggers',
100 + ]) {
101 + expect(platformUrls).toContain(url);
102 + }
103 + expect(platformUrls).not.toContain('/docs/agent-plugins');
104 +
105 + for (const sharedUrl of ['/docs', '/docs/security/overview', '/docs/security/data-retention']) {
106 + expect(forYouUrls).toContain(sharedUrl);
107 + expect(platformUrls).toContain(sharedUrl);
108 + }
109 + });
110 +
111 + test('keeps accessibility-critical switcher semantics and visible focus styles', async () => {
112 + const switcherSource = await Bun.file(
113 + new URL('../../components/product-switcher.tsx', import.meta.url),
114 + ).text();
115 + const sharedLayoutSource = await Bun.file(
116 + new URL('../../lib/layout.shared.tsx', import.meta.url),
117 + ).text();
118 +
119 + expect(switcherSource).toContain('aria-label={`Switch Composio product. Current product:');
120 + expect(switcherSource).toContain('role="radiogroup"');
121 + expect(switcherSource).toContain('role="radio"');
122 + expect(switcherSource).toContain('aria-checked={isCurrent}');
123 + expect(switcherSource).toContain("aria-current={isCurrent ? 'page' : undefined}");
124 + expect(switcherSource).toContain('focus-visible:outline-2');
125 + expect(sharedLayoutSource).toContain('slots: { navTitle: ProductNavTitle }');
126 + });
127 +});