Skip to content

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

fix(docs): render live toolkits on snapshot miss

jkomyno7545287e21ea
diff --git a/docs/app/(home)/toolkits/[[...slug]]/page.tsx b/docs/app/(home)/toolkits/[[...slug]]/page.tsx
index c5dced96a..7a397f3a2 100644
--- a/docs/app/(home)/toolkits/[[...slug]]/page.tsx
+++ b/docs/app/(home)/toolkits/[[...slug]]/page.tsx
@@ -8,7 +8,8 @@ import { PageActions } from '@/components/page-actions';
import { EditOnGitHub } from '@/components/edit-on-github';
import { readFile } from 'fs/promises';
import { join } from 'path';
-import { getAllToolkits, getToolkitBySlug } from '@/lib/toolkit-data';
+import { getAllToolkits } from '@/lib/toolkit-data';
+import { resolveToolkit } from '@/lib/toolkit-resolution';
import { unified } from 'unified';
import remarkParse from 'remark-parse';
import remarkRehype from 'remark-rehype';
@@ -21,6 +22,9 @@ import { apiToolListSchema, apiTriggerListSchema } from '@/lib/toolkit-schema';
const API_BASE = process.env.COMPOSIO_API_BASE || 'https://backend.composio.dev/api/v3';
const API_KEY = process.env.COMPOSIO_API_KEY;
+// Snapshot misses are resolved from production on demand.
+export const dynamicParams = true;
+
// Fetch detailed tool info from Composio API (server-side only)
// Returns null on failure, empty array if toolkit has no tools
async function fetchDetailedTools(
@@ -177,7 +181,7 @@ export async function generateMetadata({
// Check JSON toolkit
if (slug.length === 1) {
- const toolkit = await getToolkitBySlug(slug[0]);
+ const toolkit = await resolveToolkit(slug[0]);
if (toolkit) {
const title = `${toolkit.name?.trim() || toolkit.slug} - Composio Toolkit`;
const description = `Build an AI agent that connects to ${toolkit.name?.trim() || toolkit.slug} using Composio. ${toolkit.description}`;
@@ -230,7 +234,7 @@ export default async function ToolkitsPage({ params }: { params: Promise<{ slug?
// Check JSON toolkit
if (slug.length === 1) {
const toolkitSlug = slug[0];
- const toolkit = await getToolkitBySlug(toolkitSlug);
+ const toolkit = await resolveToolkit(toolkitSlug);
if (toolkit) {
// Fetch detailed tool/trigger info and FAQ content in parallel
diff --git a/docs/lib/toolkit-resolution.ts b/docs/lib/toolkit-resolution.ts
new file mode 100644
index 000000000..9f6a14cbf
--- /dev/null
+++ b/docs/lib/toolkit-resolution.ts
@@ -0,0 +1,10 @@
+import { fetchToolkitFromProduction } from '@/lib/toolkit-api';
+import { getToolkitBySlug } from '@/lib/toolkit-data';
+import type { Toolkit } from '@/types/toolkit';
+
+export async function resolveToolkit(slug: string): Promise<Toolkit | null> {
+ const snapshotToolkit = await getToolkitBySlug(slug);
+ if (snapshotToolkit) return snapshotToolkit;
+
+ return fetchToolkitFromProduction(slug);
+}
diff --git a/docs/tests/integration/toolkit-fallback.test.ts b/docs/tests/integration/toolkit-fallback.test.ts
new file mode 100644
index 000000000..6101ff2bd
--- /dev/null
+++ b/docs/tests/integration/toolkit-fallback.test.ts
@@ -0,0 +1,36 @@
+import { describe, expect, test } from 'bun:test';
+import { fetchPage } from './helpers';
+
+const LIVE_ONLY_TOOLKIT_SLUG = '7shifts';
+
+describe('toolkit snapshot fallback', () => {
+ test('renders a toolkit from the committed snapshot', async () => {
+ const response = await fetchPage('/toolkits/github');
+ const html = await response.text();
+
+ expect(response.status).toBe(200);
+ expect(response.headers.get('content-type')).toContain('text/html');
+ expect(html.toLowerCase()).toContain('github');
+ });
+
+ test('returns 404 for a nonsense toolkit slug', async () => {
+ const response = await fetchPage('/toolkits/__definitely-not-a-toolkit__');
+
+ expect(response.status).toBe(404);
+ });
+
+ if (process.env.COMPOSIO_API_KEY) {
+ test('renders fallback content and metadata for a production-only toolkit', async () => {
+ const response = await fetchPage(`/toolkits/${LIVE_ONLY_TOOLKIT_SLUG}`);
+ const html = await response.text();
+
+ expect(response.status).toBe(200);
+ expect(html.toLowerCase()).toContain('7shifts');
+ expect(html).toMatch(/<title>[^<]*7shifts[^<]*Composio Toolkit[^<]*<\/title>/i);
+ expect(html).toContain(`<link rel="canonical" href="/toolkits/${LIVE_ONLY_TOOLKIT_SLUG}"`);
+ expect(html).not.toContain('<title>Toolkit Not Found');
+ });
+ } else {
+ test.skip('production-only fallback requires COMPOSIO_API_KEY', () => {});
+ }
+});
diff --git a/docs/tests/static/toolkit-fallback.test.ts b/docs/tests/static/toolkit-fallback.test.ts
new file mode 100644
index 000000000..337b97443
--- /dev/null
+++ b/docs/tests/static/toolkit-fallback.test.ts
@@ -0,0 +1,69 @@
+import { beforeAll, beforeEach, describe, expect, mock, test } from 'bun:test';
+import type { Toolkit } from '../../types/toolkit';
+
+const snapshotToolkit: Toolkit = {
+ slug: 'github',
+ name: 'GitHub',
+ logo: 'https://logos.composio.dev/api/github',
+ description: 'GitHub snapshot description',
+ category: 'developer tools',
+ authSchemes: ['OAUTH2'],
+ composioManagedAuthSchemes: ['OAUTH2'],
+ toolCount: 10,
+ triggerCount: 2,
+ version: '20260817_00',
+ tools: [],
+ triggers: [],
+};
+
+const liveToolkit: Toolkit = {
+ ...snapshotToolkit,
+ slug: 'live-only',
+ name: 'Live Only',
+ description: 'Production fallback description',
+ version: null,
+};
+
+const getToolkitBySlug = mock(async (_slug: string): Promise<Toolkit | null> => null);
+const fetchToolkitFromProduction = mock(
+ async (_slug: string): Promise<Toolkit | null> => null
+);
+
+mock.module('@/lib/toolkit-data', () => ({ getToolkitBySlug }));
+mock.module('@/lib/toolkit-api', () => ({ fetchToolkitFromProduction }));
+
+let resolveToolkit: typeof import('../../lib/toolkit-resolution').resolveToolkit;
+
+beforeAll(async () => {
+ ({ resolveToolkit } = await import('../../lib/toolkit-resolution'));
+});
+
+beforeEach(() => {
+ getToolkitBySlug.mockReset();
+ fetchToolkitFromProduction.mockReset();
+});
+
+describe('resolveToolkit', () => {
+ test('returns a snapshot hit without calling production', async () => {
+ getToolkitBySlug.mockResolvedValue(snapshotToolkit);
+
+ expect(await resolveToolkit('github')).toEqual(snapshotToolkit);
+ expect(getToolkitBySlug).toHaveBeenCalledWith('github');
+ expect(fetchToolkitFromProduction).not.toHaveBeenCalled();
+ });
+
+ test('returns a production toolkit after a snapshot miss', async () => {
+ getToolkitBySlug.mockResolvedValue(null);
+ fetchToolkitFromProduction.mockResolvedValue(liveToolkit);
+
+ expect(await resolveToolkit('live-only')).toEqual(liveToolkit);
+ expect(fetchToolkitFromProduction).toHaveBeenCalledWith('live-only');
+ });
+
+ test('returns null when both snapshot and production miss', async () => {
+ getToolkitBySlug.mockResolvedValue(null);
+ fetchToolkitFromProduction.mockResolvedValue(null);
+
+ expect(await resolveToolkit('__definitely-not-a-toolkit__')).toBeNull();
+ });
+});