Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
feat(city): add CyberCity 3D dashboard with immersive cyberpunk cityscape
Adam Eivy5cd21f306794
diff --git a/.changelog/v0.12.x.md b/.changelog/v0.12.x.mdindex 62dbe680a4..085a9638fe 100644--- a/.changelog/v0.12.x.md+++ b/.changelog/v0.12.x.md@@ -137,6 +137,35 @@ This release adds branch management and automated release workflow capabilities- **Sorted to bottom**: Archived apps are sorted after active apps in the grid so they don't intermix with actively managed services- **Excluded from stats**: The Quick Stats cards (Total, Online, Stopped, Not Started) now count only active apps; the header shows an "(N archived)" count when archived apps exist+### CyberCity 3D Dashboard+- **Immersive 3D city visualization**: Navigate an interactive cyberpunk cityscape where each managed app is a neon-lit building, providing a spatial overview of your entire infrastructure+- **Status-driven buildings**: Building height and neon edge color reflect app status — tall cyan for online, amber for stopped, dim indigo for not started, and muted slate in the warehouse district for archived apps+- **Live AI agent entities**: Active CoS agents appear as floating, rotating diamond wireframes above the building they're working on, with sparkle trails and state-based coloring+- **Tron-style ground grid**: Infinite cyan grid with fog depth fade creates cyberpunk atmosphere+- **Real-time HUD overlay**: Clock, connection status, CoS activity indicator, scrolling activity log from `cos:log` events, and an agent status bar at the bottom+- **Full orbit controls**: Mouse drag to rotate, scroll to zoom, right-click to pan around the city+- **Lazy-loaded**: CyberCity bundle only loads when navigating to `/city`, keeping the main bundle lean+- **Real-time updates**: Buildings update live via WebSocket when apps start/stop, agents appear/complete via CoS socket events++**Client changes**:+- `client/src/pages/CyberCity.jsx` — Page component with data hook integration and HUD overlay+- `client/src/hooks/useCityData.js` — Data hook fetching apps, agents, CoS status with socket subscriptions+- `client/src/components/city/CityScene.jsx` — React Three Fiber Canvas with orbit controls+- `client/src/components/city/CityGround.jsx` — drei Grid with Tron-style cyan lines+- `client/src/components/city/CityLights.jsx` — Ambient, point lights, and fog for atmosphere+- `client/src/components/city/Building.jsx` — App building mesh with neon wireframe edges and hover glow+- `client/src/components/city/BuildingCluster.jsx` — Positions all buildings via layout algorithm with archive district+- `client/src/components/city/AgentEntity.jsx` — Floating octahedron agent with bob animation and sparkles+- `client/src/components/city/HolographicPanel.jsx` — drei Html floating status label per building+- `client/src/components/city/CityParticles.jsx` — Ambient sparkle particles across the scene+- `client/src/components/city/CityHud.jsx` — HTML overlay with clock, status, activity log, agent bar+- `client/src/components/city/CityActivityLog.jsx` — Scrolling cos:log event feed+- `client/src/components/city/CityAgentBar.jsx` — Bottom bar showing active agent pills+- `client/src/components/city/cityLayout.js` — Pure layout function: downtown grid + warehouse district+- `client/src/components/city/cityConstants.js` — Colors, dimensions, district parameters+- `client/src/App.jsx` — Added lazy-loaded `/city` route+- `client/src/components/Layout.jsx` — Added CyberCity nav item and full-bleed layout support+## Fixes### Managed App Port Conflict — ENV Leak & Detectiondiff --git a/client/src/App.jsx b/client/src/App.jsxindex 2e4930d11b..39b927c11b 100644--- a/client/src/App.jsx+++ b/client/src/App.jsx@@ -25,6 +25,7 @@ const GitPage = lazy(() => import('./pages/DevTools').then(m => ({ default: m.Giconst UsagePage = lazy(() => import('./pages/DevTools').then(m => ({ default: m.UsagePage })));const ProcessesPage = lazy(() => import('./pages/DevTools').then(m => ({ default: m.ProcessesPage })));const AgentsPage = lazy(() => import('./pages/DevTools').then(m => ({ default: m.AgentsPage })));+const CyberCity = lazy(() => import('./pages/CyberCity'));// Loading fallback for lazy-loaded pagesconst PageLoader = () => (@@ -62,6 +63,7 @@ export default function App() {<Route path="uploads" element={<Uploads />} /><Route path="shell" element={<Shell />} /><Route path="browser" element={<BrowserPage />} />+ <Route path="city" element={<CyberCity />} /><Route path="agents" element={<Agents />} /><Route path="agents/:agentId" element={<Agents />} /><Route path="agents/:agentId/:tab" element={<Agents />} />diff --git a/client/src/components/Layout.jsx b/client/src/components/Layout.jsxindex 9e055c659b..45192e2c71 100644--- a/client/src/components/Layout.jsx+++ b/client/src/components/Layout.jsx@@ -32,7 +32,8 @@ import {Upload,SquareTerminal,Globe,- Newspaper+ Newspaper,+ Building2} from 'lucide-react';import packageJson from '../../package.json';import Logo from './Logo';@@ -42,6 +43,7 @@ import NotificationDropdown from './NotificationDropdown';const navItems = [{ to: '/', label: 'Dashboard', icon: Home, single: true },+ { to: '/city', label: 'CyberCity', icon: Building2, single: true },{ separator: true },{ to: '/agents', label: 'Agents', icon: Users, single: true },{@@ -449,8 +451,8 @@ export default function Layout() {</header>{/* Main content */}- <main id="main-content" className={`flex-1 overflow-auto ${location.pathname.startsWith('/cos') || location.pathname.startsWith('/brain') || location.pathname.startsWith('/digital-twin') || location.pathname.startsWith('/agents') || location.pathname === '/shell' ? '' : 'p-4 md:p-6'}`}>- {location.pathname.startsWith('/cos') || location.pathname.startsWith('/brain') || location.pathname.startsWith('/digital-twin') || location.pathname.startsWith('/agents') || location.pathname === '/shell' ? (+ <main id="main-content" className={`flex-1 overflow-auto ${location.pathname.startsWith('/cos') || location.pathname.startsWith('/brain') || location.pathname.startsWith('/digital-twin') || location.pathname.startsWith('/agents') || location.pathname === '/shell' || location.pathname === '/city' ? '' : 'p-4 md:p-6'}`}>+ {location.pathname.startsWith('/cos') || location.pathname.startsWith('/brain') || location.pathname.startsWith('/digital-twin') || location.pathname.startsWith('/agents') || location.pathname === '/shell' || location.pathname === '/city' ? (<Outlet />) : (<div className="max-w-7xl mx-auto">diff --git a/client/src/components/city/AgentEntity.jsx b/client/src/components/city/AgentEntity.jsxnew file mode 100644index 0000000000..9fcce6fbca--- /dev/null+++ b/client/src/components/city/AgentEntity.jsx@@ -0,0 +1,56 @@+import { useRef } from 'react';+import { useFrame } from '@react-three/fiber';+import { Sparkles } from '@react-three/drei';+import { AGENT_STATES } from '../cos/constants';++const DEFAULT_COLOR = '#06b6d4';++export default function AgentEntity({ agent, position, index = 0 }) {+ const meshRef = useRef();++ const state = agent.state || agent.status || 'coding';+ const color = AGENT_STATES[state]?.color || DEFAULT_COLOR;++ const offsetX = index * 1.0 - (index > 0 ? 0.5 : 0);+ const yBase = position[1];++ useFrame(({ clock }) => {+ if (!meshRef.current) return;+ const t = clock.getElapsedTime();++ // Vertical bob+ meshRef.current.position.y = yBase + Math.sin(t * 1.5 + index) * 0.3;++ // Y rotation+ meshRef.current.rotation.y = t * 0.8 + index * Math.PI * 0.5;++ // Emissive pulse+ meshRef.current.children[0]?.material && (+ meshRef.current.children[0].material.emissiveIntensity = 0.5 + Math.sin(t * 3) * 0.3+ );+ });++ return (+ <group ref={meshRef} position={[position[0] + offsetX, yBase, position[2]]}>+ <mesh>+ <octahedronGeometry args={[0.3, 0]} />+ <meshStandardMaterial+ color={color}+ emissive={color}+ emissiveIntensity={0.5}+ wireframe+ transparent+ opacity={0.8}+ />+ </mesh>+ <Sparkles+ count={15}+ scale={0.8}+ size={1}+ speed={0.5}+ color={color}+ opacity={0.6}+ />+ </group>+ );+}diff --git a/client/src/components/city/Building.jsx b/client/src/components/city/Building.jsxnew file mode 100644index 0000000000..f8aaaf7419--- /dev/null+++ b/client/src/components/city/Building.jsx@@ -0,0 +1,90 @@+import { useRef, useState, useMemo } from 'react';+import { useFrame } from '@react-three/fiber';+import * as THREE from 'three';+import { getBuildingColor, getBuildingHeight, CITY_COLORS } from './cityConstants';+import HolographicPanel from './HolographicPanel';++export default function Building({ app, position, agentCount, onClick }) {+ const meshRef = useRef();+ const edgesRef = useRef();+ const glowRef = useRef();+ const [hovered, setHovered] = useState(false);++ const height = getBuildingHeight(app);+ const edgeColor = getBuildingColor(app.overallStatus, app.archived);+ const isOnline = app.overallStatus === 'online' && !app.archived;++ const boxGeom = useMemo(() => new THREE.BoxGeometry(1.5, height, 1.5), [height]);+ const edgesGeom = useMemo(() => new THREE.EdgesGeometry(boxGeom), [boxGeom]);++ useFrame(({ clock }) => {+ if (!meshRef.current) return;+ const t = clock.getElapsedTime();++ // Emissive pulse on hover or when online+ const baseIntensity = isOnline ? 0.15 : 0.05;+ const pulse = isOnline ? Math.sin(t * 2) * 0.05 : 0;+ const hoverBoost = hovered ? 0.2 : 0;+ meshRef.current.material.emissiveIntensity = baseIntensity + pulse + hoverBoost;++ // Ground glow pulse+ if (glowRef.current) {+ glowRef.current.material.opacity = 0.15 + (isOnline ? Math.sin(t * 1.5) * 0.05 : 0) + (hovered ? 0.1 : 0);+ }+ });++ return (+ <group position={[position.x, 0, position.z]}>+ {/* Building body */}+ <mesh+ ref={meshRef}+ position={[0, height / 2, 0]}+ onClick={onClick}+ onPointerEnter={() => setHovered(true)}+ onPointerLeave={() => setHovered(false)}+ >+ <boxGeometry args={[1.5, height, 1.5]} />+ <meshStandardMaterial+ color={CITY_COLORS.buildingBody}+ emissive={edgeColor}+ emissiveIntensity={0.1}+ transparent+ opacity={app.archived ? 0.6 : 0.9}+ />+ </mesh>++ {/* Neon wireframe edges */}+ <lineSegments+ ref={edgesRef}+ position={[0, height / 2, 0]}+ geometry={edgesGeom}+ >+ <lineBasicMaterial+ color={edgeColor}+ transparent+ opacity={app.archived ? 0.3 : 0.8}+ />+ </lineSegments>++ {/* Base glow circle */}+ <mesh ref={glowRef} rotation={[-Math.PI / 2, 0, 0]} position={[0, 0.01, 0]}>+ <circleGeometry args={[1.2, 32]} />+ <meshBasicMaterial+ color={edgeColor}+ transparent+ opacity={0.15}+ side={THREE.DoubleSide}+ />+ </mesh>++ {/* Holographic label - show on hover or always for online */}+ {(hovered || isOnline) && (+ <HolographicPanel+ app={app}+ agentCount={agentCount}+ position={[0, height + 0.8, 0]}+ />+ )}+ </group>+ );+}diff --git a/client/src/components/city/BuildingCluster.jsx b/client/src/components/city/BuildingCluster.jsxnew file mode 100644index 0000000000..c3a647796a--- /dev/null+++ b/client/src/components/city/BuildingCluster.jsx@@ -0,0 +1,67 @@+import { useMemo } from 'react';+import { Text } from '@react-three/drei';+import { computeCityLayout } from './cityLayout';+import { getBuildingHeight, DISTRICT_PARAMS } from './cityConstants';+import Building from './Building';+import AgentEntity from './AgentEntity';++export default function BuildingCluster({ apps, agentMap, onBuildingClick }) {+ const positions = useMemo(() => computeCityLayout(apps), [apps]);++ const hasArchived = apps.some(a => a.archived);++ // Find warehouse district start Z for label placement+ const warehouseMinZ = useMemo(() => {+ let minZ = Infinity;+ positions.forEach((pos) => {+ if (pos.district === 'warehouse' && pos.z < minZ) minZ = pos.z;+ });+ return minZ === Infinity ? DISTRICT_PARAMS.warehouseOffset : minZ;+ }, [positions]);++ return (+ <group>+ {apps.map(app => {+ const pos = positions.get(app.id);+ if (!pos) return null;++ const agentData = agentMap.get(app.id);+ const agents = agentData?.agents || [];+ const height = getBuildingHeight(app);++ return (+ <group key={app.id}>+ <Building+ app={app}+ position={pos}+ agentCount={agents.length}+ onClick={() => onBuildingClick?.(app)}+ />+ {agents.map((agent, i) => (+ <AgentEntity+ key={agent.agentId || i}+ agent={agent}+ position={[pos.x, height + 1.5 + i * 1.0, pos.z]}+ index={i}+ />+ ))}+ </group>+ );+ })}++ {/* Warehouse district label */}+ {hasArchived && (+ <Text+ position={[0, 0.5, warehouseMinZ - 1.5]}+ fontSize={0.6}+ color="#334155"+ anchorX="center"+ anchorY="middle"+ font={undefined}+ >+ ARCHIVE+ </Text>+ )}+ </group>+ );+}diff --git a/client/src/components/city/CityActivityLog.jsx b/client/src/components/city/CityActivityLog.jsxnew file mode 100644index 0000000000..f59dcbea93--- /dev/null+++ b/client/src/components/city/CityActivityLog.jsx@@ -0,0 +1,47 @@+import { useRef, useEffect } from 'react';++const LEVEL_COLORS = {+ info: 'text-cyan-400',+ warn: 'text-amber-400',+ error: 'text-red-400',+ success: 'text-emerald-400',+ debug: 'text-gray-500',+};++export default function CityActivityLog({ logs }) {+ const scrollRef = useRef(null);++ useEffect(() => {+ if (scrollRef.current) {+ scrollRef.current.scrollTop = scrollRef.current.scrollHeight;+ }+ }, [logs]);++ if (logs.length === 0) return null;++ return (+ <div className="absolute top-16 right-3 bottom-20 w-72 pointer-events-auto">+ <div className="h-full bg-black/60 backdrop-blur-sm border border-cyan-500/20 rounded-lg overflow-hidden flex flex-col">+ <div className="px-3 py-2 border-b border-cyan-500/20 text-cyan-400 text-xs font-mono font-bold">+ ACTIVITY LOG+ </div>+ <div ref={scrollRef} className="flex-1 overflow-y-auto px-3 py-1 space-y-0.5">+ {logs.slice(-30).map((log, i) => {+ const level = log.level || 'info';+ const colorClass = LEVEL_COLORS[level] || LEVEL_COLORS.info;+ const time = log.timestamp+ ? new Date(log.timestamp).toLocaleTimeString([], { hour: '2-digit', minute: '2-digit', second: '2-digit' })+ : '';++ return (+ <div key={i} className="font-mono text-[10px] leading-tight flex gap-1.5">+ <span className="text-gray-600 shrink-0">{time}</span>+ <span className={colorClass}>{log.message || log.event || JSON.stringify(log)}</span>+ </div>+ );+ })}+ </div>+ </div>+ </div>+ );+}diff --git a/client/src/components/city/CityAgentBar.jsx b/client/src/components/city/CityAgentBar.jsxnew file mode 100644index 0000000000..28cd27dc0e--- /dev/null+++ b/client/src/components/city/CityAgentBar.jsx@@ -0,0 +1,54 @@+import { AGENT_STATES } from '../cos/constants';++export default function CityAgentBar({ cosAgents, agentMap }) {+ // Only show active/running agents+ const activeAgents = (cosAgents || []).filter(a =>+ a.status === 'running' || a.state === 'coding' || a.state === 'thinking' || a.state === 'investigating'+ );++ if (activeAgents.length === 0) return null;++ // Find which app each agent is working on+ const getAppName = (agent) => {+ for (const [, data] of agentMap) {+ if (data.agents.some(a => a.agentId === agent.agentId)) {+ return data.app.name;+ }+ }+ return null;+ };++ return (+ <div className="absolute bottom-3 left-3 right-3 pointer-events-auto">+ <div className="bg-black/60 backdrop-blur-sm border border-cyan-500/20 rounded-lg px-3 py-2">+ <div className="flex items-center gap-3 overflow-x-auto">+ <span className="text-cyan-400 text-[10px] font-mono font-bold shrink-0">AGENTS</span>+ {activeAgents.map((agent, i) => {+ const state = agent.state || 'coding';+ const stateConfig = AGENT_STATES[state];+ const appName = getAppName(agent);++ return (+ <div+ key={agent.agentId || i}+ className="flex items-center gap-1.5 px-2 py-1 bg-black/40 border border-white/10 rounded text-[10px] font-mono shrink-0"+ >+ <span+ className="w-2 h-2 rounded-full shrink-0"+ style={{ backgroundColor: stateConfig?.color || '#06b6d4' }}+ />+ <span className="text-gray-300">{agent.type || 'agent'}</span>+ {appName && (+ <>+ <span className="text-gray-600">|</span>+ <span className="text-cyan-400/70 truncate max-w-[100px]">{appName}</span>+ </>+ )}+ </div>+ );+ })}+ </div>+ </div>+ </div>+ );+}diff --git a/client/src/components/city/CityGround.jsx b/client/src/components/city/CityGround.jsxnew file mode 100644index 0000000000..e09fb35abd--- /dev/null+++ b/client/src/components/city/CityGround.jsx@@ -0,0 +1,19 @@+import { Grid } from '@react-three/drei';+import { CITY_COLORS } from './cityConstants';++export default function CityGround() {+ return (+ <Grid+ infiniteGrid+ cellSize={1}+ sectionSize={4}+ cellColor={CITY_COLORS.ground}+ sectionColor={CITY_COLORS.ground}+ cellThickness={0.4}+ sectionThickness={1}+ fadeDistance={50}+ fadeStrength={1}+ position={[0, -0.01, 0]}+ />+ );+}diff --git a/client/src/components/city/CityHud.jsx b/client/src/components/city/CityHud.jsxnew file mode 100644index 0000000000..4c4c9f7250--- /dev/null+++ b/client/src/components/city/CityHud.jsx@@ -0,0 +1,55 @@+import { useState, useEffect } from 'react';+import CityActivityLog from './CityActivityLog';+import CityAgentBar from './CityAgentBar';++export default function CityHud({ cosStatus, cosAgents, agentMap, eventLogs, connected, apps }) {+ const [time, setTime] = useState(new Date());++ useEffect(() => {+ const interval = setInterval(() => setTime(new Date()), 1000);+ return () => clearInterval(interval);+ }, []);++ const activeApps = apps.filter(a => !a.archived && a.overallStatus === 'online').length;+ const totalApps = apps.filter(a => !a.archived).length;++ return (+ <div className="absolute inset-0 pointer-events-none overflow-hidden">+ {/* Top-left: Clock + system status */}+ <div className="absolute top-3 left-3 pointer-events-auto">+ <div className="bg-black/60 backdrop-blur-sm border border-cyan-500/20 rounded-lg px-3 py-2">+ <div className="font-mono text-cyan-400 text-sm font-bold">+ {time.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit', second: '2-digit' })}+ </div>+ <div className="font-mono text-[10px] text-gray-500">+ {activeApps}/{totalApps} apps online+ </div>+ </div>+ </div>++ {/* Top-right: Connection + CoS status */}+ <div className="absolute top-3 right-3 pointer-events-auto">+ <div className="bg-black/60 backdrop-blur-sm border border-cyan-500/20 rounded-lg px-3 py-2 flex items-center gap-3">+ <div className="flex items-center gap-1.5">+ <span className={`w-2 h-2 rounded-full ${connected ? 'bg-emerald-400' : 'bg-red-400'}`} />+ <span className="font-mono text-[10px] text-gray-400">+ {connected ? 'CONNECTED' : 'OFFLINE'}+ </span>+ </div>+ <div className="flex items-center gap-1.5">+ <span className={`w-2 h-2 rounded-full ${cosStatus?.running ? 'bg-cyan-400 animate-pulse' : 'bg-gray-600'}`} />+ <span className="font-mono text-[10px] text-gray-400">+ CoS {cosStatus?.running ? 'ACTIVE' : 'IDLE'}+ </span>+ </div>+ </div>+ </div>++ {/* Right side: Activity log */}+ <CityActivityLog logs={eventLogs} />++ {/* Bottom: Agent status bar */}+ <CityAgentBar cosAgents={cosAgents} agentMap={agentMap} />+ </div>+ );+}diff --git a/client/src/components/city/CityLights.jsx b/client/src/components/city/CityLights.jsxnew file mode 100644index 0000000000..f94d4fd12d--- /dev/null+++ b/client/src/components/city/CityLights.jsx@@ -0,0 +1,13 @@+import { CITY_COLORS } from './cityConstants';++export default function CityLights() {+ return (+ <>+ <ambientLight intensity={0.08} color={CITY_COLORS.ambient} />+ <pointLight position={[0, 20, 0]} intensity={0.6} color="#06b6d4" distance={60} />+ <pointLight position={[-15, 8, -10]} intensity={0.3} color="#ec4899" distance={40} />+ <pointLight position={[15, 8, 10]} intensity={0.3} color="#3b82f6" distance={40} />+ <fog attach="fog" args={[CITY_COLORS.fog, 20, 60]} />+ </>+ );+}diff --git a/client/src/components/city/CityParticles.jsx b/client/src/components/city/CityParticles.jsxnew file mode 100644index 0000000000..f872950f89--- /dev/null+++ b/client/src/components/city/CityParticles.jsx@@ -0,0 +1,15 @@+import { Sparkles } from '@react-three/drei';+import { CITY_COLORS } from './cityConstants';++export default function CityParticles() {+ return (+ <Sparkles+ count={100}+ scale={[40, 15, 40]}+ size={1.5}+ speed={0.3}+ opacity={0.3}+ color={CITY_COLORS.particles}+ />+ );+}diff --git a/client/src/components/city/CityScene.jsx b/client/src/components/city/CityScene.jsxnew file mode 100644index 0000000000..f7c94edcfa--- /dev/null+++ b/client/src/components/city/CityScene.jsx@@ -0,0 +1,34 @@+import { Canvas } from '@react-three/fiber';+import { OrbitControls } from '@react-three/drei';+import CityGround from './CityGround';+import CityLights from './CityLights';+import CityParticles from './CityParticles';+import BuildingCluster from './BuildingCluster';++export default function CityScene({ apps, agentMap, onBuildingClick }) {+ return (+ <Canvas+ camera={{ position: [0, 15, 25], fov: 50 }}+ dpr={[1, 1.5]}+ shadows={false}+ style={{ background: '#0a0a0f' }}+ gl={{ antialias: true }}+ >+ <CityLights />+ <CityGround />+ <BuildingCluster+ apps={apps}+ agentMap={agentMap}+ onBuildingClick={onBuildingClick}+ />+ <CityParticles />+ <OrbitControls+ maxPolarAngle={Math.PI / 2.2}+ minDistance={5}+ maxDistance={50}+ enableDamping+ dampingFactor={0.05}+ />+ </Canvas>+ );+}diff --git a/client/src/components/city/HolographicPanel.jsx b/client/src/components/city/HolographicPanel.jsxnew file mode 100644index 0000000000..c2e04fdeaa--- /dev/null+++ b/client/src/components/city/HolographicPanel.jsx@@ -0,0 +1,32 @@+import { Html } from '@react-three/drei';++export default function HolographicPanel({ app, agentCount, position }) {+ const statusColors = {+ online: 'border-cyan-500/50 text-cyan-400',+ stopped: 'border-amber-500/50 text-amber-400',+ not_started: 'border-indigo-500/50 text-indigo-400',+ not_found: 'border-indigo-500/50 text-indigo-400',+ };++ const colorClass = app.archived+ ? 'border-slate-500/50 text-slate-400'+ : statusColors[app.overallStatus] || statusColors.not_started;++ return (+ <Html+ position={position}+ center+ distanceFactor={15}+ occlude+ style={{ pointerEvents: 'none' }}+ >+ <div className={`bg-black/80 border ${colorClass} rounded px-2 py-1 font-mono text-xs whitespace-nowrap backdrop-blur-sm`}>+ <div className="font-bold text-[10px] truncate max-w-[120px]">{app.name}</div>+ <div className="flex items-center gap-1 text-[9px] opacity-75">+ <span>{app.archived ? 'archived' : app.overallStatus}</span>+ {agentCount > 0 && <span>| {agentCount} agent{agentCount > 1 ? 's' : ''}</span>}+ </div>+ </div>+ </Html>+ );+}diff --git a/client/src/components/city/cityConstants.js b/client/src/components/city/cityConstants.jsnew file mode 100644index 0000000000..298b597e8e--- /dev/null+++ b/client/src/components/city/cityConstants.js@@ -0,0 +1,45 @@+export const CITY_COLORS = {+ ground: '#06b6d4',+ fog: '#0a0a0f',+ ambient: '#1a1a3e',+ building: {+ online: '#06b6d4',+ stopped: '#f59e0b',+ not_started: '#6366f1',+ not_found: '#6366f1',+ archived: '#334155',+ },+ buildingBody: '#0a0a1e',+ particles: '#06b6d4',+};++export const BUILDING_PARAMS = {+ width: 1.5,+ depth: 1.5,+ spacing: 3.5,+ heights: {+ online: 4,+ stopped: 2,+ not_started: 1.2,+ not_found: 1.2,+ archived: 0.8,+ },+ processHeightBonus: 0.5,+};++export const DISTRICT_PARAMS = {+ warehouseOffset: 18,+ gap: 5,+};++export const getBuildingColor = (status, archived) => {+ if (archived) return CITY_COLORS.building.archived;+ return CITY_COLORS.building[status] || CITY_COLORS.building.not_started;+};++export const getBuildingHeight = (app) => {+ if (app.archived) return BUILDING_PARAMS.heights.archived;+ const base = BUILDING_PARAMS.heights[app.overallStatus] || BUILDING_PARAMS.heights.not_started;+ const processBonus = app.overallStatus === 'online' ? (app.processes?.length || 0) * BUILDING_PARAMS.processHeightBonus : 0;+ return base + processBonus;+};diff --git a/client/src/components/city/cityLayout.js b/client/src/components/city/cityLayout.jsnew file mode 100644index 0000000000..68e1b9a4e5--- /dev/null+++ b/client/src/components/city/cityLayout.js@@ -0,0 +1,58 @@+import { BUILDING_PARAMS, DISTRICT_PARAMS } from './cityConstants';++const STATUS_ORDER = { online: 0, stopped: 1, not_started: 2, not_found: 3 };++export const computeCityLayout = (apps) => {+ const active = [];+ const archived = [];++ apps.forEach(app => {+ if (app.archived) {+ archived.push(app);+ } else {+ active.push(app);+ }+ });++ // Sort active: online first, then stopped, then not_started+ active.sort((a, b) => (STATUS_ORDER[a.overallStatus] ?? 3) - (STATUS_ORDER[b.overallStatus] ?? 3));++ const positions = new Map();+ const { spacing } = BUILDING_PARAMS;++ // Downtown district (active apps) centered at origin+ const activeCols = Math.max(1, Math.ceil(Math.sqrt(active.length)));+ const activeRows = Math.ceil(active.length / activeCols);+ const activeOffsetX = ((activeCols - 1) * spacing) / 2;+ const activeOffsetZ = ((activeRows - 1) * spacing) / 2;++ active.forEach((app, i) => {+ const col = i % activeCols;+ const row = Math.floor(i / activeCols);+ positions.set(app.id, {+ x: col * spacing - activeOffsetX,+ z: row * spacing - activeOffsetZ,+ district: 'downtown',+ });+ });++ // Warehouse district (archived apps) offset along +Z+ if (archived.length > 0) {+ const archiveCols = Math.max(1, Math.ceil(Math.sqrt(archived.length)));+ const archiveRows = Math.ceil(archived.length / archiveCols);+ const archiveOffsetX = ((archiveCols - 1) * spacing) / 2;+ const warehouseZ = activeRows * spacing / 2 + DISTRICT_PARAMS.gap;++ archived.forEach((app, i) => {+ const col = i % archiveCols;+ const row = Math.floor(i / archiveCols);+ positions.set(app.id, {+ x: col * spacing - archiveOffsetX,+ z: warehouseZ + row * spacing,+ district: 'warehouse',+ });+ });+ }++ return positions;+};diff --git a/client/src/hooks/useCityData.js b/client/src/hooks/useCityData.jsnew file mode 100644index 0000000000..4ea3e174a4--- /dev/null+++ b/client/src/hooks/useCityData.js@@ -0,0 +1,119 @@+import { useState, useEffect, useCallback, useMemo, useRef } from 'react';+import * as api from '../services/api';+import socket from '../services/socket';++export const useCityData = () => {+ const [apps, setApps] = useState([]);+ const [cosAgents, setCosAgents] = useState([]);+ const [cosStatus, setCosStatus] = useState({ running: false });+ const [runningAgents, setRunningAgents] = useState([]);+ const [eventLogs, setEventLogs] = useState([]);+ const [loading, setLoading] = useState(true);+ const pollRef = useRef(null);++ const fetchApps = useCallback(async () => {+ const data = await api.getApps().catch(() => []);+ setApps(data);+ return data;+ }, []);++ const fetchAll = useCallback(async () => {+ const [appsData, agents, cosAgentsData, status] = await Promise.all([+ api.getApps().catch(() => []),+ api.getRunningAgents().catch(() => []),+ api.getCosAgents().catch(() => []),+ api.getCosStatus().catch(() => ({ running: false })),+ ]);+ setApps(appsData);+ setRunningAgents(agents);+ setCosAgents(cosAgentsData);+ setCosStatus(status);+ setLoading(false);+ }, []);++ // Build agent-to-app mapping+ const agentMap = useMemo(() => {+ const map = new Map();+ const allAgents = [...(cosAgents || [])];++ allAgents.forEach(agent => {+ if (!agent.workspacePath) return;+ const matchedApp = apps.find(app =>+ app.repoPath && agent.workspacePath.startsWith(app.repoPath)+ );+ if (matchedApp) {+ const existing = map.get(matchedApp.id) || { app: matchedApp, agents: [] };+ existing.agents.push(agent);+ map.set(matchedApp.id, existing);+ }+ });++ return map;+ }, [apps, cosAgents]);++ useEffect(() => {+ fetchAll();++ // Subscribe to CoS events+ const subscribe = () => socket.emit('cos:subscribe');+ if (socket.connected) subscribe();+ socket.on('connect', subscribe);++ // App changes+ const handleAppsChanged = () => fetchApps();+ socket.on('apps:changed', handleAppsChanged);++ // CoS agent events+ socket.on('cos:agent:spawned', (data) => {+ setCosAgents(prev => [...prev, data]);+ fetchAll();+ });++ socket.on('cos:agent:updated', (updatedAgent) => {+ setCosAgents(prev => prev.map(a => a.agentId === updatedAgent.agentId ? updatedAgent : a));+ });++ socket.on('cos:agent:completed', () => {+ fetchAll();+ });++ // CoS log events+ socket.on('cos:log', (data) => {+ setEventLogs(prev => [...prev, { ...data, timestamp: data.timestamp || Date.now() }].slice(-50));+ });++ // CoS status+ socket.on('cos:status', (data) => {+ setCosStatus(prev => ({ ...prev, running: data.running }));+ });++ // Poll running agents (no socket events for system agents)+ pollRef.current = setInterval(async () => {+ const agents = await api.getRunningAgents().catch(() => []);+ setRunningAgents(agents);+ }, 10000);++ return () => {+ socket.emit('cos:unsubscribe');+ socket.off('connect', subscribe);+ socket.off('apps:changed', handleAppsChanged);+ socket.off('cos:agent:spawned');+ socket.off('cos:agent:updated');+ socket.off('cos:agent:completed');+ socket.off('cos:log');+ socket.off('cos:status');+ clearInterval(pollRef.current);+ };+ }, [fetchAll, fetchApps]);++ return {+ apps,+ cosAgents,+ cosStatus,+ runningAgents,+ eventLogs,+ agentMap,+ loading,+ connected: socket.connected,+ };+};diff --git a/client/src/pages/CyberCity.jsx b/client/src/pages/CyberCity.jsxnew file mode 100644index 0000000000..554dcf05a0--- /dev/null+++ b/client/src/pages/CyberCity.jsx@@ -0,0 +1,39 @@+import { useNavigate } from 'react-router-dom';+import { useCityData } from '../hooks/useCityData';+import CityScene from '../components/city/CityScene';+import CityHud from '../components/city/CityHud';++export default function CyberCity() {+ const navigate = useNavigate();+ const { apps, cosAgents, cosStatus, eventLogs, agentMap, loading, connected } = useCityData();++ const handleBuildingClick = (app) => {+ navigate('/apps');+ };++ if (loading) {+ return (+ <div className="flex items-center justify-center h-full bg-[#0a0a0f]">+ <div className="font-mono text-cyan-400 animate-pulse">Initializing CyberCity...</div>+ </div>+ );+ }++ return (+ <div className="relative w-full h-full" style={{ background: '#0a0a0f' }}>+ <CityScene+ apps={apps}+ agentMap={agentMap}+ onBuildingClick={handleBuildingClick}+ />+ <CityHud+ cosStatus={cosStatus}+ cosAgents={cosAgents}+ agentMap={agentMap}+ eventLogs={eventLogs}+ connected={connected}+ apps={apps}+ />+ </div>+ );+}