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([issue-705]): add CoS task-queue silhouette to CyberCity (roadmap 2.2)
[._.]/ Adam Eivy8e5673712493
diff --git a/client/src/components/city/CityScene.jsx b/client/src/components/city/CityScene.jsxindex a0c79a211b..daefd05d3d 100644--- a/client/src/components/city/CityScene.jsx+++ b/client/src/components/city/CityScene.jsx@@ -16,6 +16,7 @@ import CityVolumetricLights from './CityVolumetricLights';import CitySkyline from './CitySkyline';import CityFederationHorizon from './CityFederationHorizon';import CityBackupVault from './CityBackupVault';+import CityTaskQueue from './CityTaskQueue';import CityDataRain from './CityDataRain';import CityNeonSigns from './CityNeonSigns';import CityEmbers from './CityEmbers';@@ -26,7 +27,7 @@ import CitySky from './CitySky';import PlayerController from './PlayerController';import CameraTransition from './CameraTransition';-export default function CityScene({ apps, agentMap, onBuildingClick, cosStatus, reviewCounts, instances, backupStatus, productivityData, settings, playSfx, keysRef, dimmedAppIds }) {+export default function CityScene({ apps, agentMap, onBuildingClick, cosStatus, reviewCounts, instances, backupStatus, cosTasks, productivityData, settings, playSfx, keysRef, dimmedAppIds }) {const [positions, setPositions] = useState(null);const [proximityApp, setProximityApp] = useState(null);const [transitioning, setTransitioning] = useState(false);@@ -76,6 +77,7 @@ export default function CityScene({ apps, agentMap, onBuildingClick, cosStatus,<CitySkyline /><CityFederationHorizon instances={instances} settings={settings} /><CityBackupVault backupStatus={backupStatus} settings={settings} />+ <CityTaskQueue cosTasks={cosTasks} settings={settings} /><CityGround settings={settings} /><BuildingClusterdiff --git a/client/src/components/city/CityTaskQueue.jsx b/client/src/components/city/CityTaskQueue.jsxnew file mode 100644index 0000000000..a259710c2c--- /dev/null+++ b/client/src/components/city/CityTaskQueue.jsx@@ -0,0 +1,99 @@+import { useMemo, useRef } from 'react';+import { useFrame } from '@react-three/fiber';+import { Text } from '@react-three/drei';+import { PIXEL_FONT_URL } from './cityConstants';+import { computeTaskQueue, TASK_QUEUE } from '../../utils/cityTaskQueue';++// CyberCity's CoS task-queue silhouette (roadmap 2.2): a warehouse east of downtown with+// a stack of crates whose height tracks the depth of the Chief-of-Staff task backlog.+// Crates pile up as tasks queue and clear as they complete; the warehouse roof light+// glows green while an agent is working a task and amber when a task is blocked. An+// overflow cap keeps a runaway backlog from scraping the sky — a marker crate signals+// "more waiting" instead.+function Crate({ y, size, color, topGlow }) {+ return (+ <mesh position={[0, y, 0]}>+ <boxGeometry args={[size, size, size]} />+ <meshStandardMaterial+ color="#13202e"+ emissive={color}+ emissiveIntensity={topGlow ? 0.5 : 0.18}+ metalness={0.3}+ roughness={0.7}+ />+ </mesh>+ );+}++export default function CityTaskQueue({ cosTasks, settings }) {+ const queue = useMemo(() => computeTaskQueue(cosTasks), [cosTasks]);+ const roofRef = useRef();++ // Honor the quality dial: drop the roof-light pulse on the lowest preset, but keep the+ // static glow so the queue state stays legible.+ const animate = (settings?.particleDensity ?? 1) >= 0.5;++ useFrame(({ clock }) => {+ if (!animate || !roofRef.current) return;+ // Blocked queues throb urgently; an active queue breathes; idle/queued sits calm.+ const speed = queue.hasBlocked ? 2.6 : queue.active ? 1.4 : 0.6;+ const base = queue.state === 'idle' ? 0.25 : 0.6;+ roofRef.current.material.emissiveIntensity = base + ((Math.sin(clock.getElapsedTime() * speed) + 1) / 2) * 0.6;+ });++ const { position, color, crates, overflow, pending, inProgress, blocked } = queue;+ const { crateSize, warehouseWidth, warehouseHeight } = TASK_QUEUE;+ // Where the overflow marker (and label) sits: just above the visible crate stack.+ const stackTop = crates.length ? crates[crates.length - 1].y + crateSize : crateSize;++ const sublabel = blocked > 0+ ? `${blocked} BLOCKED · ${pending} QUEUED`+ : inProgress > 0+ ? `${inProgress} ACTIVE · ${pending} QUEUED`+ : pending > 0+ ? `${pending} QUEUED`+ : 'IDLE';++ return (+ <group position={position}>+ {/* Warehouse base — a wide low dock the crates sit on */}+ <mesh position={[0, warehouseHeight / 2, 0]}>+ <boxGeometry args={[warehouseWidth, warehouseHeight, warehouseWidth * 0.9]} />+ <meshStandardMaterial color="#0c1620" emissive={color} emissiveIntensity={0.1} metalness={0.4} roughness={0.6} />+ </mesh>+ {/* Roof light bar — the live queue-state indicator */}+ <mesh ref={roofRef} position={[0, warehouseHeight + 0.2, 0]}>+ <boxGeometry args={[warehouseWidth * 1.05, 0.4, warehouseWidth * 0.95]} />+ <meshStandardMaterial color={color} emissive={color} emissiveIntensity={0.6} toneMapped={false} />+ </mesh>++ {/* Crate stack rises from the dock roof; height ∝ pending backlog */}+ <group position={[0, warehouseHeight + 0.4, 0]}>+ {crates.map((crate, i) => (+ <Crate+ key={crate.index}+ y={crate.y}+ size={crateSize}+ color={color}+ topGlow={i === crates.length - 1}+ />+ ))}+ {/* Overflow marker — a half-height capstone meaning "more waiting than shown" */}+ {overflow && (+ <mesh position={[0, stackTop + crateSize * 0.4, 0]}>+ <boxGeometry args={[crateSize * 0.6, crateSize * 0.5, crateSize * 0.6]} />+ <meshStandardMaterial color={color} emissive={color} emissiveIntensity={0.7} toneMapped={false} />+ </mesh>+ )}++ {/* Label + count sublabel above the stack */}+ <Text position={[0, stackTop + crateSize * (overflow ? 1.2 : 0.9), 0]} fontSize={1.1} color={color} anchorX="center" anchorY="middle" font={PIXEL_FONT_URL} maxWidth={20}>+ COS QUEUE+ </Text>+ <Text position={[0, stackTop + crateSize * (overflow ? 0.6 : 0.3), 0]} fontSize={0.8} color="#94a3b8" anchorX="center" anchorY="middle" font={PIXEL_FONT_URL} maxWidth={20}>+ {sublabel}+ </Text>+ </group>+ </group>+ );+}diff --git a/client/src/hooks/useCityData.js b/client/src/hooks/useCityData.jsindex 554185dda1..8b6b057d52 100644--- a/client/src/hooks/useCityData.js+++ b/client/src/hooks/useCityData.js@@ -19,6 +19,7 @@ export const useCityData = () => {const [systemHealth, setSystemHealth] = useState(null);const [notificationCounts, setNotificationCounts] = useState({ unread: 0 });const [backupStatus, setBackupStatus] = useState(null);+ const [cosTasks, setCosTasks] = useState([]);const [loading, setLoading] = useState(true);const logIdRef = useRef(0);@@ -32,7 +33,7 @@ export const useCityData = () => {// /notifications/count returns the lightweight { count } payload — the HUD// and Attention pane only need unread, and notifications:count socket// events keep it fresh after this initial fetch.- const [appsData, agents, cosAgentsData, status, reviewData, instanceData, health, notif, backup] = await Promise.all([+ const [appsData, agents, cosAgentsData, status, reviewData, instanceData, health, notif, backup, cosTasksData] = await Promise.all([api.getApps().catch(() => []),api.getRunningAgents().catch(() => []),api.getCosAgents().catch(() => []),@@ -42,6 +43,7 @@ export const useCityData = () => {api.getSystemHealth({ silent: true }).catch(() => null),api.getNotificationCount().catch(() => ({ count: 0 })),api.getBackupStatus({ silent: true }).catch(() => null),+ api.getCosTasks({ silent: true }).catch(() => ({ tasks: [] })),]);setApps(appsData);@@ -53,6 +55,7 @@ export const useCityData = () => {setSystemHealth(health);setNotificationCounts({ unread: notif?.count ?? 0 });setBackupStatus(backup);+ setCosTasks(Array.isArray(cosTasksData?.tasks) ? cosTasksData.tasks : []);setLoading(false);}, []);@@ -179,6 +182,12 @@ export const useCityData = () => {socket.on('backup:started', handleBackupStarted);socket.on('backup:completed', handleBackupCompleted);+ // CoS task-queue silhouette: the server broadcasts the full current task list as+ // `cos:tasks:cos:changed` on every add/modify/complete, so one handler keeps the+ // warehouse's crate stack in sync without per-event bookkeeping.+ const handleCosTasksChanged = (data) => setCosTasks(Array.isArray(data?.tasks) ? data.tasks : []);+ socket.on('cos:tasks:cos:changed', handleCosTasksChanged);+// Subscribe but do NOT unsubscribe on cleanup. The cos:* and notifications:*// namespaces are shared (useNotifications in Layout, useAgentFeedbackToast).// Server uses a per-socket Set, so unsubscribing here would yank the@@ -196,6 +205,7 @@ export const useCityData = () => {socket.off('notifications:cleared', handleNotifCleared);socket.off('backup:started', handleBackupStarted);socket.off('backup:completed', handleBackupCompleted);+ socket.off('cos:tasks:cos:changed', handleCosTasksChanged);};}, [fetchAll, fetchApps, fetchBackup]);@@ -211,6 +221,7 @@ export const useCityData = () => {systemHealth,notificationCounts,backupStatus,+ cosTasks,loading,connected: socket.connected,};diff --git a/client/src/pages/CyberCity.jsx b/client/src/pages/CyberCity.jsxindex 8276daba23..41885ca863 100644--- a/client/src/pages/CyberCity.jsx+++ b/client/src/pages/CyberCity.jsx@@ -13,7 +13,7 @@ import CitySettingsPanel from '../components/city/CitySettingsPanel';import { computeFilterResult } from '../utils/cityFilter';function CyberCityInner() {- const { apps, cosAgents, cosStatus, eventLogs, agentMap, reviewCounts, instances, systemHealth, notificationCounts, backupStatus, loading, connected } = useCityData();+ const { apps, cosAgents, cosStatus, eventLogs, agentMap, reviewCounts, instances, systemHealth, notificationCounts, backupStatus, cosTasks, loading, connected } = useCityData();const { settings, updateSetting } = useCitySettingsContext();const { playSfx } = useCityAudio(settings);const navigate = useNavigate();@@ -107,6 +107,7 @@ function CyberCityInner() {reviewCounts={reviewCounts}instances={instances}backupStatus={backupStatus}+ cosTasks={cosTasks}productivityData={productivityData}settings={settings}playSfx={playSfx}diff --git a/client/src/services/apiAgents.js b/client/src/services/apiAgents.jsindex 97c0ef3406..ff1b87de02 100644--- a/client/src/services/apiAgents.js+++ b/client/src/services/apiAgents.js@@ -49,7 +49,7 @@ export const updateCosConfig = (config) => request('/cos/config', {method: 'PUT',body: JSON.stringify(config)});-export const getCosTasks = () => request('/cos/tasks');+export const getCosTasks = (options) => request('/cos/tasks', options);export const addCosTask = (task) => request('/cos/tasks', {method: 'POST',body: JSON.stringify(task)diff --git a/client/src/utils/cityTaskQueue.js b/client/src/utils/cityTaskQueue.jsnew file mode 100644index 0000000000..671827f4bf--- /dev/null+++ b/client/src/utils/cityTaskQueue.js@@ -0,0 +1,84 @@+// Pure, deterministic helpers for CyberCity's CoS task-queue silhouette (roadmap 2.2):+// a warehouse east of downtown whose stacked crates track the depth of the Chief-of-+// Staff task queue. Crates accumulate as tasks queue up and clear as they complete; an+// in-progress task lights the warehouse, a blocked task tints it amber. No three.js /+// React imports so the topology is unit-testable (mirrors cityBackupVault.js).++export const TASK_QUEUE = {+ position: [34, 0, -10], // east of the building grid, mirroring the backup vault to the west+ maxCrates: 8, // visible-crate cap; beyond this the warehouse reads as "overflow"+ crateSize: 1.5,+ crateGap: 0.18,+ warehouseWidth: 6,+ warehouseHeight: 4,+};++// Warehouse lighting color per queue "mood". Reuses the PortOS Tailwind tokens so the+// silhouette speaks the same visual language as the rest of the UI.+const STATE_COLORS = {+ idle: '#475569', // slate — empty queue, nothing waiting+ queued: '#3b82f6', // port-accent — pending work piling up+ active: '#22c55e', // port-success — an agent is working a task+ blocked: '#f59e0b', // port-warning — a task needs attention+};++// Tally CoS tasks by status. Tolerates a missing/non-array input (returns all-zero) and+// buckets unrecognized statuses under `other` so the counts always sum to the input length.+export function countByStatus(tasks) {+ const counts = { pending: 0, in_progress: 0, blocked: 0, completed: 0, other: 0 };+ const list = Array.isArray(tasks) ? tasks : [];+ for (const t of list) {+ const s = t?.status;+ if (s === 'pending') counts.pending++;+ else if (s === 'in_progress') counts.in_progress++;+ else if (s === 'blocked') counts.blocked++;+ else if (s === 'completed') counts.completed++;+ else counts.other++;+ }+ return counts;+}++// Overall queue mood for the warehouse lighting, in priority order: a blocked task is the+// loudest signal, then active work, then a non-empty backlog, then idle.+export function queueState(counts) {+ if (counts?.blocked > 0) return 'blocked';+ if (counts?.in_progress > 0) return 'active';+ if (counts?.pending > 0) return 'queued';+ return 'idle';+}++export function queueColor(state) {+ return STATE_COLORS[state] || STATE_COLORS.idle;+}++// Full derived view-model for the component: counts + warehouse state/color + a crate+// layout. The crate stack height tracks pending (queued) work — the depth of the queue —+// capped at maxCrates with an `overflow` flag when more is waiting than crates shown.+export function computeTaskQueue(tasks, opts = {}) {+ const maxCrates = opts.maxCrates ?? TASK_QUEUE.maxCrates;+ const counts = countByStatus(tasks);+ const state = queueState(counts);+ const crateCount = Math.min(counts.pending, maxCrates);+ const crates = [];+ for (let i = 0; i < crateCount; i++) {+ crates.push({+ index: i,+ y: TASK_QUEUE.crateSize / 2 + i * (TASK_QUEUE.crateSize + TASK_QUEUE.crateGap),+ });+ }+ return {+ position: TASK_QUEUE.position,+ counts,+ pending: counts.pending,+ inProgress: counts.in_progress,+ blocked: counts.blocked,+ total: counts.pending + counts.in_progress + counts.blocked,+ state,+ color: queueColor(state),+ crateCount,+ crates,+ overflow: counts.pending > maxCrates,+ active: counts.in_progress > 0,+ hasBlocked: counts.blocked > 0,+ };+}diff --git a/client/src/utils/cityTaskQueue.test.js b/client/src/utils/cityTaskQueue.test.jsnew file mode 100644index 0000000000..37ddff2b30--- /dev/null+++ b/client/src/utils/cityTaskQueue.test.js@@ -0,0 +1,127 @@+import { describe, it, expect } from 'vitest';+import {+ TASK_QUEUE,+ countByStatus,+ queueState,+ queueColor,+ computeTaskQueue,+} from './cityTaskQueue';++const tasks = (...statuses) => statuses.map((status, i) => ({ id: `t${i}`, status }));++describe('countByStatus', () => {+ it('tallies each status and buckets unknowns under other', () => {+ const c = countByStatus(tasks('pending', 'pending', 'in_progress', 'blocked', 'completed', 'weird'));+ expect(c).toEqual({ pending: 2, in_progress: 1, blocked: 1, completed: 1, other: 1 });+ });++ it('returns all-zero for missing / non-array input', () => {+ const zero = { pending: 0, in_progress: 0, blocked: 0, completed: 0, other: 0 };+ expect(countByStatus(undefined)).toEqual(zero);+ expect(countByStatus(null)).toEqual(zero);+ expect(countByStatus('nope')).toEqual(zero);+ expect(countByStatus([])).toEqual(zero);+ });++ it('counts always sum to the input length', () => {+ const list = tasks('pending', 'in_progress', 'blocked', 'completed', 'other', 'pending');+ const c = countByStatus(list);+ const sum = c.pending + c.in_progress + c.blocked + c.completed + c.other;+ expect(sum).toBe(list.length);+ });+});++describe('queueState', () => {+ it('prioritizes blocked > active > queued > idle', () => {+ expect(queueState({ blocked: 1, in_progress: 3, pending: 5 })).toBe('blocked');+ expect(queueState({ blocked: 0, in_progress: 2, pending: 5 })).toBe('active');+ expect(queueState({ blocked: 0, in_progress: 0, pending: 5 })).toBe('queued');+ expect(queueState({ blocked: 0, in_progress: 0, pending: 0 })).toBe('idle');+ });++ it('treats missing counts as idle', () => {+ expect(queueState(undefined)).toBe('idle');+ expect(queueState({})).toBe('idle');+ });+});++describe('queueColor', () => {+ it('maps each state to a distinct token', () => {+ expect(queueColor('idle')).toBe('#475569');+ expect(queueColor('queued')).toBe('#3b82f6');+ expect(queueColor('active')).toBe('#22c55e');+ expect(queueColor('blocked')).toBe('#f59e0b');+ });++ it('falls back to idle for an unknown state', () => {+ expect(queueColor('bogus')).toBe(queueColor('idle'));+ });+});++describe('computeTaskQueue', () => {+ it('carries the fixed position through unchanged', () => {+ expect(computeTaskQueue([]).position).toEqual(TASK_QUEUE.position);+ });++ it('an empty queue is idle with no crates', () => {+ const vm = computeTaskQueue([]);+ expect(vm.state).toBe('idle');+ expect(vm.crateCount).toBe(0);+ expect(vm.crates).toEqual([]);+ expect(vm.overflow).toBe(false);+ expect(vm.total).toBe(0);+ });++ it('stacks one crate per pending task', () => {+ const vm = computeTaskQueue(tasks('pending', 'pending', 'pending'));+ expect(vm.pending).toBe(3);+ expect(vm.crateCount).toBe(3);+ expect(vm.crates).toHaveLength(3);+ expect(vm.state).toBe('queued');+ expect(vm.overflow).toBe(false);+ });++ it('stacks crates upward with increasing y', () => {+ const vm = computeTaskQueue(tasks('pending', 'pending'));+ expect(vm.crates[0].y).toBeLessThan(vm.crates[1].y);+ expect(vm.crates[0].y).toBeCloseTo(TASK_QUEUE.crateSize / 2);+ });++ it('caps crate count at maxCrates and flags overflow', () => {+ const many = tasks(...Array(TASK_QUEUE.maxCrates + 4).fill('pending'));+ const vm = computeTaskQueue(many);+ expect(vm.pending).toBe(TASK_QUEUE.maxCrates + 4);+ expect(vm.crateCount).toBe(TASK_QUEUE.maxCrates);+ expect(vm.overflow).toBe(true);+ });++ it('honors a custom maxCrates', () => {+ const vm = computeTaskQueue(tasks('pending', 'pending', 'pending'), { maxCrates: 2 });+ expect(vm.crateCount).toBe(2);+ expect(vm.overflow).toBe(true);+ });++ it('lights active when an agent is working, even with pending backlog', () => {+ const vm = computeTaskQueue(tasks('pending', 'pending', 'in_progress'));+ expect(vm.state).toBe('active');+ expect(vm.active).toBe(true);+ expect(vm.color).toBe('#22c55e');+ // crate stack still reflects the pending backlog, independent of the lighting+ expect(vm.crateCount).toBe(2);+ });++ it('tints blocked when any task needs attention, overriding active', () => {+ const vm = computeTaskQueue(tasks('pending', 'in_progress', 'blocked'));+ expect(vm.state).toBe('blocked');+ expect(vm.hasBlocked).toBe(true);+ expect(vm.color).toBe('#f59e0b');+ expect(vm.total).toBe(3);+ });++ it('ignores completed tasks for stacking and totals', () => {+ const vm = computeTaskQueue(tasks('completed', 'completed', 'pending'));+ expect(vm.crateCount).toBe(1);+ expect(vm.total).toBe(1);+ expect(vm.state).toBe('queued');+ });+});