mirror of
https://github.com/vercel/workflow.git
synced 2026-09-14 19:59:43 +08:00
8a146a5bb1
* docs: revamp World documentation pages with new structure and design
- Add dedicated world detail pages at /worlds/[id] with MDX-driven content
- Create WorldDetailHero, WorldDetailToc, WorldTestingPerformance components
- Add benchmark history charts and test summary links
- Rewrite local-world, postgres-world, and vercel-world MDX with cleaner structure
- Use h3 headings for configuration options instead of tables/accordions
- Add WorldDataProvider context for passing world data to MDX components
- Add example field to worlds-manifest for linking to example repos
- Update worlds index page design
* fix: update worlds page meta title and description
* feat(docs): improve globe backdrop responsiveness and positioning
- Globe now scales with container width up to 1200px max
- Increased opacity from 20% to 30% for better visibility
- Positioned globe 30% down to show north pole behind header
- Globe component now auto-sizes based on container width
* fix(docs): add light mode support for globe backdrop
* feat: improve world page metadata and add dynamic OG images
- Update title format to '{Name} World | Workflow DevKit'
- Update worlds index page title to 'Worlds | Workflow DevKit'
- Improve world descriptions in worlds-manifest.json for better SEO
- Add dynamic OG image generation at /worlds/[id]/og
- Add openGraph and twitter metadata to world detail pages
* fix: use opengraph-image.tsx file convention for dynamic OG images
- Replace route-based og/route.tsx with opengraph-image.tsx file convention
- Remove runtime = 'edge' to allow generateStaticParams for static generation
- Simplify page.tsx metadata (Next.js auto-detects opengraph-image.tsx)
* docs: improve worlds page UI and restructure deploying section
- Fix globe visibility in light/dark mode
- Fix tooltip positioning on mobile breakpoints
- Remove redundant Documentation button for community worlds
- Add missing pages to Foundations index (streaming, serialization, idempotency)
- Restructure deploying section with new index and building-a-world guide
- Restore original MDX content for official worlds (local, vercel, postgres)
- Auto-expand sidebar folders when child page is active
* docs: simplify worlds page footer sections
* docs: move last updated section under worlds grid
* fix(docs): fix broken links and skip typecheck for interface definitions
- Fix /docs/deploying/world link to /docs/deploying/building-a-world
- Fix /docs/deploying#what-are-worlds invalid anchor to /docs/deploying
- Add @skip-typecheck markers to interface definition code blocks
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* fix(docs): address PR review feedback
- benchmark-history/route.ts: Add error handling for JSON parsing,
distinguish 404s from actual errors
- Globe.tsx: Fix hydration mismatch by deferring theme-dependent
rendering until component is mounted
- sidebar.tsx: Improve path check robustness for active child detection
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
190 lines
5.5 KiB
TypeScript
190 lines
5.5 KiB
TypeScript
'use client';
|
|
|
|
import { useMemo } from 'react';
|
|
import {
|
|
Table,
|
|
TableBody,
|
|
TableCell,
|
|
TableHead,
|
|
TableHeader,
|
|
TableRow,
|
|
} from '@/components/ui/table';
|
|
import { cn } from '@/lib/utils';
|
|
import { formatTime, type WorldsStatus } from './types';
|
|
|
|
interface BenchmarkChartProps {
|
|
data: WorldsStatus;
|
|
benchmarkName?: string;
|
|
}
|
|
|
|
export function BenchmarkChart({ data, benchmarkName }: BenchmarkChartProps) {
|
|
const { worlds, benchmarks, fastest } = useMemo(() => {
|
|
const worldEntries = Object.entries(data.worlds).filter(
|
|
([, w]) => w.benchmark?.metrics
|
|
);
|
|
|
|
// Get all unique benchmark names
|
|
const allBenchmarks = new Set<string>();
|
|
for (const [, world] of worldEntries) {
|
|
if (world.benchmark?.metrics) {
|
|
for (const name of Object.keys(world.benchmark.metrics)) {
|
|
allBenchmarks.add(name);
|
|
}
|
|
}
|
|
}
|
|
|
|
// Filter to specific benchmark if provided
|
|
const benchmarkList = benchmarkName
|
|
? [benchmarkName]
|
|
: Array.from(allBenchmarks).sort();
|
|
|
|
// Find fastest for each benchmark
|
|
const fastestByBench: Record<string, { worldId: string; time: number }> =
|
|
{};
|
|
for (const bench of benchmarkList) {
|
|
let fastest: { worldId: string; time: number } | null = null;
|
|
for (const [worldId, world] of worldEntries) {
|
|
const metric = world.benchmark?.metrics?.[bench];
|
|
if (metric && (!fastest || metric.mean < fastest.time)) {
|
|
fastest = { worldId, time: metric.mean };
|
|
}
|
|
}
|
|
if (fastest) {
|
|
fastestByBench[bench] = fastest;
|
|
}
|
|
}
|
|
|
|
return {
|
|
worlds: worldEntries,
|
|
benchmarks: benchmarkList,
|
|
fastest: fastestByBench,
|
|
};
|
|
}, [data, benchmarkName]);
|
|
|
|
if (worlds.length === 0) {
|
|
return (
|
|
<p className="text-muted-foreground text-sm">
|
|
No benchmark data available.
|
|
</p>
|
|
);
|
|
}
|
|
|
|
return (
|
|
<div className="overflow-x-auto">
|
|
<Table>
|
|
<TableHeader>
|
|
<TableRow>
|
|
<TableHead className="w-[200px]">Benchmark</TableHead>
|
|
{worlds.map(([id, world]) => (
|
|
<TableHead key={id} className="text-right">
|
|
{world.type === 'community' && '🌐 '}
|
|
{world.name}
|
|
</TableHead>
|
|
))}
|
|
</TableRow>
|
|
</TableHeader>
|
|
<TableBody>
|
|
{benchmarks.map((bench) => (
|
|
<TableRow key={bench}>
|
|
<TableCell className="font-medium text-sm">{bench}</TableCell>
|
|
{worlds.map(([worldId, world]) => {
|
|
const metric = world.benchmark?.metrics?.[bench];
|
|
const isFastest = fastest[bench]?.worldId === worldId;
|
|
const fastestTime = fastest[bench]?.time || 1;
|
|
const factor = metric ? metric.mean / fastestTime : null;
|
|
|
|
return (
|
|
<TableCell
|
|
key={worldId}
|
|
className={cn(
|
|
'text-right font-mono text-sm',
|
|
isFastest && 'text-green-600 font-semibold'
|
|
)}
|
|
>
|
|
{metric ? (
|
|
<span>
|
|
{isFastest && '🥇 '}
|
|
{formatTime(metric.mean)}
|
|
{!isFastest && factor && (
|
|
<span className="text-muted-foreground text-xs ml-1">
|
|
({factor.toFixed(1)}x)
|
|
</span>
|
|
)}
|
|
</span>
|
|
) : (
|
|
<span className="text-muted-foreground">—</span>
|
|
)}
|
|
</TableCell>
|
|
);
|
|
})}
|
|
</TableRow>
|
|
))}
|
|
</TableBody>
|
|
</Table>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
// Simple bar visualization for a single benchmark across worlds
|
|
export function BenchmarkBar({
|
|
data,
|
|
benchmarkName,
|
|
}: {
|
|
data: WorldsStatus;
|
|
benchmarkName: string;
|
|
}) {
|
|
const { worlds, maxTime, minTime } = useMemo(() => {
|
|
const worldEntries = Object.entries(data.worlds)
|
|
.filter(([, w]) => w.benchmark?.metrics?.[benchmarkName])
|
|
.map(([id, w]) => ({
|
|
id,
|
|
name: w.name,
|
|
type: w.type,
|
|
time: w.benchmark!.metrics[benchmarkName].mean,
|
|
}))
|
|
.sort((a, b) => a.time - b.time);
|
|
|
|
const times = worldEntries.map((w) => w.time);
|
|
return {
|
|
worlds: worldEntries,
|
|
maxTime: Math.max(...times, 1),
|
|
minTime: Math.min(...times, 0),
|
|
};
|
|
}, [data, benchmarkName]);
|
|
|
|
if (worlds.length === 0) {
|
|
return null;
|
|
}
|
|
|
|
return (
|
|
<div className="space-y-2">
|
|
{worlds.map((world, index) => {
|
|
const width = (world.time / maxTime) * 100;
|
|
const isFastest = index === 0;
|
|
|
|
return (
|
|
<div key={world.id} className="flex items-center gap-3">
|
|
<div className="w-24 text-sm truncate">
|
|
{world.type === 'community' && '🌐 '}
|
|
{world.name}
|
|
</div>
|
|
<div className="flex-1 h-6 bg-muted rounded overflow-hidden">
|
|
<div
|
|
className={cn(
|
|
'h-full rounded transition-all',
|
|
isFastest ? 'bg-green-500' : 'bg-primary/60'
|
|
)}
|
|
style={{ width: `${width}%` }}
|
|
/>
|
|
</div>
|
|
<div className="w-20 text-right font-mono text-sm">
|
|
{isFastest && '🥇 '}
|
|
{formatTime(world.time)}
|
|
</div>
|
|
</div>
|
|
);
|
|
})}
|
|
</div>
|
|
);
|
|
}
|