diff --git a/app/(app)/worlds/page.tsx b/app/(app)/worlds/page.tsx index 79b1557..e221618 100644 --- a/app/(app)/worlds/page.tsx +++ b/app/(app)/worlds/page.tsx @@ -1,228 +1,76 @@ -interface WorldStats { - total: number - by_node: Record - by_type: Record - recent: WorldEntry[] -} +// app/(app)/worlds/page.tsx +// Shows world generation stats from worlds.blackroad.io +// Server component with 10s revalidation -interface WorldEntry { - name: string - type: 'world' | 'lore' | 'code' | string - node: string - generated_at: string -} - -const TYPE_ICONS: Record = { - world: '๐ŸŒ', - lore: '๐Ÿ“–', - code: '๐Ÿ’ป', -} - -const TYPE_COLORS: Record = { - world: 'text-green-400', - lore: 'text-purple-400', - code: 'text-blue-400', -} - -async function getWorldStats(): Promise<{ worlds: WorldStats } | null> { +async function getWorldStats() { try { - const res = await fetch('https://worlds.blackroad.io/stats', { - next: { revalidate: 30 }, - }) - return res.ok ? res.json() : null - } catch { - return null - } + const res = await fetch('https://worlds.blackroad.io/stats', { next: { revalidate: 10 } }) + if (!res.ok) return null + return await res.json() + } catch { return null } } -function formatRelativeTime(dateStr: string): string { - const date = new Date(dateStr) - const now = new Date() - const diffMs = now.getTime() - date.getTime() - const diffMins = Math.floor(diffMs / 60000) - if (diffMins < 1) return 'just now' - if (diffMins < 60) return `${diffMins}m ago` - const diffHours = Math.floor(diffMins / 60) - if (diffHours < 24) return `${diffHours}h ago` - return `${Math.floor(diffHours / 24)}d ago` -} - -function ProgressBar({ - value, - max, - color, -}: { - value: number - max: number - color: string -}) { - const pct = max > 0 ? Math.round((value / max) * 100) : 0 - const filled = Math.round(pct / 5) // 20 chars max - const empty = 20 - filled - return ( -
- - {'โ–ˆ'.repeat(filled)} - {'โ–‘'.repeat(empty)} - - {pct}% -
- ) +async function getRecentWorlds() { + try { + const res = await fetch('https://blackroad-agents-status.amundsonalexa.workers.dev/worlds?limit=10', + { next: { revalidate: 10 } }) + if (!res.ok) return [] + const data = await res.json() + return data.worlds || [] + } catch { return [] } } export default async function WorldsPage() { - const data = await getWorldStats() - const worlds = data?.worlds ?? null - const total = worlds?.total ?? 0 - const byNode = worlds?.by_node ?? {} - const byType = worlds?.by_type ?? {} - const recent = worlds?.recent ?? [] - const maxType = Math.max(...Object.values(byType).map(Number), 1) - + const stats = await getWorldStats() + const worlds = await getRecentWorlds() + + const total = stats?.total || 0 + const nodes = stats?.by_node || {} + return ( -
- {/* Header */} -
-
-

- ๐ŸŒ Worlds - - - Live - -

-

AI-generated worlds running on BlackRoad Pi fleet

+
+

๐ŸŒ World Generator

+

+ Autonomous AI worlds generated by BlackRoad Pi fleet +

+ + {/* Stats row */} +
+
+
{total}
+
Total Worlds
-
-
- {total || 'โ€”'} -
-
worlds generated
+
+
{nodes.aria64 || 'โ€”'}
+
aria64 Node
+
+
+
{nodes.alice || 'โ€”'}
+
alice Node
- - {/* Node breakdown */} -
- {Object.entries(byNode).length > 0 ? ( - Object.entries(byNode).map(([node, count]) => ( -
-
- - {node} -
-
- {count as number} -
-
worlds on this node
-
-
0 ? Math.round(((count as number) / total) * 100) : 0}%`, - }} - /> -
-
- {total > 0 ? Math.round(((count as number) / total) * 100) : 0}% of total -
-
- )) - ) : ( - ['aria64', 'alice'].map((node) => ( -
-
-
-
-
- )) - )} -
- - {/* Type distribution */} -
-

- Type Distribution -

-
- {Object.entries(byType).length > 0 ? ( - Object.entries(byType).map(([type, count]) => ( -
-
- - {TYPE_ICONS[type] ?? '๐Ÿ”ท'} - {type} - - {count as number} + + {/* Type breakdown */} + {stats?.by_type && ( +
+

By Type

+
+ {Object.entries(stats.by_type).map(([type, count]: [string, any]) => { + const emojis: Record = { lore: '๐Ÿ“œ', world: '๐ŸŒ', code: '๐Ÿ’ป', story: 'โœจ', tech: '๐Ÿ”ง' } + return ( +
+ {emojis[type] || '๐Ÿ“„'} + {type} + {count}
- -
- )) - ) : ( -
- - Generating... -
- )} + ) + })} +
-
- - {/* Recent worlds */} -
-

- Recent Worlds -

- {recent.length > 0 ? ( -
- {recent.slice(0, 10).map((w: WorldEntry, i: number) => ( -
-
- - {TYPE_ICONS[w.type] ?? '๐Ÿ”ท'} - -
-
- {w.name} -
-
- - {w.type} - - ยท - {w.node} -
-
-
-
- {formatRelativeTime(w.generated_at)} -
-
- ))} -
- ) : ( -
- - Generating worlds... check back soon. -
- )} -
- -

- Auto-refreshes every 30s ยท Powered by aria64 + alice Pi nodes + )} + +

+ โšก Generating ~2 worlds/min ยท Live RSS: worlds-feed.blackroad.io

)