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: responsive City HUD + migrate City settings to shared Drawer (#2591)
Adam Eivybd6bb7f093f9
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.mdindex 6bdbb8ad3f..25979322df 100644--- a/.changelog/NEXT.md+++ b/.changelog/NEXT.md@@ -7,6 +7,8 @@## Changed+- **[issue-2591] Responsive City HUD + City settings on the shared Drawer.** The CyberCity HUD now adapts to the viewport instead of stacking every desktop panel on top of the 3D scene at phone width. A new `useCityViewport` hook brackets the window into desktop (≥1024, unchanged cockpit), compact (640–1023) and phone (<640); below desktop the HUD collapses to a small clock/health chip, a status chip and a bottom dock of 44×44 launchers, keeping ≥70% of the scene unobscured on load. Secondary surfaces (vitals, attention, timeline, activity, map, filter, legend) open as ONE mutually-exclusive disclosure sheet driven by a `cityPane` URL param, so only one shows at a time and the open one is deep-linkable, reload-safe and restored by browser back/forward (the desktop Intel pane's active tab reads the same param). City settings moved off the bespoke bottom-right scroller onto the shared tabbed `Drawer` (`size="sm"`, Performance/Audio/Visual/Explore, active tab deep-linked via `useDrawerTab`'s `cityTab` param, `TabPills` mobile dropdown), preserving the `/city/settings` route.+- **[issue-2530] Decompose `cos.js` `dequeueNextTask` and split `cosAgents.js` into focused modules.** The ~370-line `dequeueNextTask` scheduler is now a thin orchestrator that threads a shared `ctx` through five `spawnDequeuePriorityN(ctx)` tier helpers (mirroring `evaluateTasks`), with the pure per-cycle capacity tracker (`createDequeueCapacity`) and mission/idle tier-eligibility predicates extracted to a new `server/services/cosDequeue.js` — so the scheduler and its unit tests exercise the *same* guards instead of a local replica. The ~1090-line `cosAgents.js` is split into focused siblings — `cosAgentIndex.js` (date-bucket index / migration / prune / archive layout), `cosAgentLifecycle.js` (register / complete / output / terminate / pause / kill / BTW / zombie cleanup), `cosAgentFeedback.js` (feedback capture + classifier), `cosAgentArchive.js` (state-eviction sweeps) — with `cosAgents.js` kept as a thin barrel so every existing import path is unchanged. Pure mechanical refactor: no behavior change.- **[issue-2533] Thin the apps-list route and split the imageGen setup routes into their own module.** The `GET /api/apps` handler's ~80 lines of inline PM2 enrichment (one read per `pm2Home`, absent-vs-empty status classification, ecosystem-config process backfill, port derivation) moved into a new `server/services/appListEnrichment.js` (`enrichAppsWithPm2Status(apps)`), so the route just fetches the raw records and responds; the pure port/status helpers (`deriveUiPort`/`deriveAppPorts`/`computeOverallStatus`) live there too and are re-exported from `routes/apps/shared.js` so the detail/lifecycle routes keep one shared implementation. The `/api/image-gen/setup/*` handlers (python probe/venv bootstrap, FLUX.2 install/status, HuggingFace-token store, pip installer) split out of the large `routes/imageGen.js` render router into `routes/imageGenSetup.js`, with the setup-check cache and pip allowlist relocated to `services/imageGen/setup.js`. Pure mechanical refactor — no behavior change.- **[issue-2531] Split the pipeline `issues.js` and `visualStages.js` monoliths along CRUD/stage/sync seams.** The ~1470-line `server/services/pipeline/issues.js` is now a thin barrel over `issuesShared.js` (store facade + per-series write queue + record sanitizers + `renumberInline`), `issueCrud.js` (create/read/list/update/delete + numbering/reassign), `issueStages.js` (per-stage merge/history/restore), and `issueSync.js` (peer-sync LWW merge + tombstone GC). The ~1760-line `visualStages.js` is now a thin barrel over `visualStageHelpers.js` (shared style/prompt composers + image-gen enqueue plumbing), `covers.js` (comic + volume front/back covers), `comicPages.js` (comic page renders + panel prompt refine), and `storyboards.js` (scene/shot renders + scene refine). Pure mechanical refactor — no behavior change; the single-tail-per-series write serialization (`queueSeriesIssuesWrite`) and the store's `queueTypeIndexWrite` merge snapshot are preserved, and every existing `from './issues.js'` / `from './visualStages.js'` import path still resolves through the barrels.diff --git a/client/src/components/city/CityHud.jsx b/client/src/components/city/CityHud.jsxindex 56aade99b3..65d22bb63b 100644--- a/client/src/components/city/CityHud.jsx+++ b/client/src/components/city/CityHud.jsx@@ -5,7 +5,10 @@ import CityAgentBar from './CityAgentBar';import CityFilterBar from './CityFilterBar';import CityXpBadge from './CityXpBadge';import CityMiniMap from './CityMiniMap';-import { formatDurationMs } from '../../utils/formatters';+import CityVitalsList from './CityVitalsList';+import CityHudCompact from './CityHudCompact';+import { HudCorner, HealthBar, getHealthSentinel } from './cityHudBits';+import useCityViewport from '../../hooks/useCityViewport';// WASD controls hint shown briefly on first exploration entryfunction ControlsHint({ visible }) {@@ -50,68 +53,16 @@ function ControlsHint({ visible }) {);}-const getHealthSentinel = (systemHealth, onlineRatio) => {- if (systemHealth?.overallHealth === 'critical') return { dot: 'bg-port-error', text: 'text-port-error', label: 'CRITICAL' };- if (systemHealth?.overallHealth === 'warning') return { dot: 'bg-port-warning', text: 'text-port-warning', label: 'WARN' };- if (systemHealth?.overallHealth === 'healthy') return { dot: 'bg-port-success', text: 'text-port-success', label: 'OK' };- if (onlineRatio >= 0.8) return { dot: 'bg-cyan-400', text: 'text-cyan-400', label: 'OK' };- if (onlineRatio >= 0.5) return { dot: 'bg-port-warning', text: 'text-port-warning', label: 'WARN' };- return { dot: 'bg-port-error', text: 'text-port-error', label: 'CRIT' };-};--const metricColor = (pct) => {- if (pct == null) return 'text-gray-500';- if (pct >= 90) return 'text-port-error';- if (pct >= 75) return 'text-port-warning';- return 'text-cyan-400';-};--// Animated corner decoration for HUD panels-function HudCorner({ position = 'tl', color = 'cyan' }) {- const corners = {- tl: 'top-0 left-0 border-t border-l',- tr: 'top-0 right-0 border-t border-r',- bl: 'bottom-0 left-0 border-b border-l',- br: 'bottom-0 right-0 border-b border-r',- };-- return (- <div- className={`absolute w-2 h-2 ${corners[position]} border-${color}-400/60`}- style={{ borderWidth: '1px' }}- />- );-}--function StatButton({ label, valueClass, value, onClick, title, prefix = null }) {+function Crosshair() {return (- <button- type="button"- onClick={onClick}- title={title}- className="w-full flex items-center justify-between gap-6 -mx-1 px-1 py-0.5 rounded hover:bg-cyan-500/5 transition-colors"- >- <span className="font-pixel text-[10px] text-gray-400 tracking-wide">{label}</span>- <span className={`font-pixel text-[11px] ${valueClass || 'text-cyan-400'}`}>- {prefix}- {value}- </span>- </button>- );-}--function HealthBar({ value, max, color }) {- const pct = max > 0 ? (value / max) * 100 : 0;- return (- <div className="w-full h-1 bg-gray-800/60 rounded-full overflow-hidden">- <div- className="h-full rounded-full transition-all duration-1000"- style={{- width: `${pct}%`,- backgroundColor: color,- boxShadow: `0 0 4px ${color}`,- }}- />+ <div className="absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 pointer-events-none">+ <div className="relative w-6 h-6">+ <div className="absolute top-0 left-1/2 -translate-x-1/2 w-px h-2 bg-cyan-400/60" />+ <div className="absolute bottom-0 left-1/2 -translate-x-1/2 w-px h-2 bg-cyan-400/60" />+ <div className="absolute left-0 top-1/2 -translate-y-1/2 w-2 h-px bg-cyan-400/60" />+ <div className="absolute right-0 top-1/2 -translate-y-1/2 w-2 h-px bg-cyan-400/60" />+ <div className="absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-1 h-1 rounded-full bg-cyan-400/40" />+ </div></div>);}@@ -119,6 +70,7 @@ function HealthBar({ value, max, color }) {export default function CityHud({ cosStatus, cosAgents, agentMap, eventLogs, connected, apps, reviewCounts, instances, productivityData, systemHealth, notificationCounts, character, filter, onFilterChange, onJumpToFirst, matchCount, onToggleExploration, explorationMode, onSelectApp, onEnterPhotoMode, onEnterPlayback }) {const navigate = useNavigate();const location = useLocation();+ const { isDesktop } = useCityViewport();const [time, setTime] = useState(new Date());const [uptimeSeconds, setUptimeSeconds] = useState(0);useEffect(() => {@@ -158,333 +110,252 @@ export default function CityHud({ cosStatus, cosAgents, agentMap, eventLogs, cona.status === 'running' || a.state === 'coding' || a.state === 'thinking' || a.state === 'investigating').length;+ // The shared vitals payload — backs both the desktop cockpit's vitals panel and+ // the compact/phone `vitals` disclosure surface (via <CityVitalsList>).+ const vitals = {+ uptimeSeconds,+ sentinel,+ cpuPct,+ memPct,+ diskPct,+ warnings: systemHealth?.warnings,+ activeAgentCount,+ stoppedApps,+ archivedApps,+ pendingReview,+ alertCount,+ onlinePeers,+ totalNodes,+ notificationCounts,+ productivityData,+ activeApps,+ totalApps,+ };+return (// z-20 keeps the HUD above the CityScanlines CRT overlay (z-10) so the vignette// + scanline-multiply + chromatic-aberration glow stay on the 3D scene and don't// haze the (now theme-colored) HUD panels.<div className="absolute inset-0 pointer-events-none overflow-hidden z-20">- {/* Top-left: Clock + system status + vitals */}- <div className="absolute top-3 left-3 pointer-events-auto">- <div className="relative bg-black/85 backdrop-blur-sm border border-cyan-500/40 rounded-lg px-4 py-3 overflow-hidden">- <HudCorner position="tl" />- <HudCorner position="tr" />- <HudCorner position="bl" />- <HudCorner position="br" />-- <div className="font-pixel text-cyan-400 text-xl tracking-wider" style={{ textShadow: '0 0 10px rgba(6,182,212,0.6)' }}>- {time.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit', second: '2-digit' })}- </div>- <div className="font-pixel text-[11px] text-cyan-500 tracking-wide mt-0.5">- {activeApps}/{totalApps} SYSTEMS ONLINE- </div>-- {/* System health bar */}- <div className="mt-2">- <HealthBar value={activeApps} max={totalApps} color="#06b6d4" />- </div>- </div>-- {/* System Vitals panel */}- <div className="relative mt-2 bg-black/85 backdrop-blur-sm border border-cyan-500/30 rounded-lg px-3 py-2.5 space-y-1.5 overflow-hidden">- <HudCorner position="tl" />- <HudCorner position="tr" />- <HudCorner position="bl" />- <HudCorner position="br" />-- {/* Animated scan line (CSS-only, no React re-renders) */}- <div- className="absolute left-0 right-0 h-px bg-cyan-400/15 pointer-events-none animate-scanline"- />+ {isDesktop ? (+ <>+ {/* Top-left: Clock + system status + vitals */}+ <div className="absolute top-3 left-3 pointer-events-auto">+ <div className="relative bg-black/85 backdrop-blur-sm border border-cyan-500/40 rounded-lg px-4 py-3 overflow-hidden">+ <HudCorner position="tl" />+ <HudCorner position="tr" />+ <HudCorner position="bl" />+ <HudCorner position="br" />++ <div className="font-pixel text-cyan-400 text-xl tracking-wider" style={{ textShadow: '0 0 10px rgba(6,182,212,0.6)' }}>+ {time.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit', second: '2-digit' })}+ </div>+ <div className="font-pixel text-[11px] text-cyan-500 tracking-wide mt-0.5">+ {activeApps}/{totalApps} SYSTEMS ONLINE+ </div>++ {/* System health bar */}+ <div className="mt-2">+ <HealthBar value={activeApps} max={totalApps} color="#06b6d4" />+ </div>+ </div>- <div className="font-pixel text-[10px] text-cyan-500/70 tracking-wider mb-1">- SYSTEM VITALS- </div>+ {/* System Vitals panel */}+ <div className="relative mt-2 bg-black/85 backdrop-blur-sm border border-cyan-500/30 rounded-lg px-3 py-2.5 overflow-hidden">+ <HudCorner position="tl" />+ <HudCorner position="tr" />+ <HudCorner position="bl" />+ <HudCorner position="br" />- {/* Uptime */}- <div className="flex items-center justify-between gap-6">- <span className="font-pixel text-[10px] text-gray-400 tracking-wide">UPTIME</span>- <span className="font-pixel text-[11px] text-cyan-400" style={{ textShadow: '0 0 6px rgba(6,182,212,0.4)' }}>- {formatDurationMs(uptimeSeconds * 1000)}- </span>- </div>+ {/* Animated scan line (CSS-only, no React re-renders) */}+ <div className="absolute left-0 right-0 h-px bg-cyan-400/15 pointer-events-none animate-scanline" />- <button- type="button"- onClick={() => navigate('/')}- className="w-full flex items-center justify-between gap-3 -mx-1 px-1 py-1 rounded hover:bg-cyan-500/5 transition-colors"- title={systemHealth?.warnings?.length ? systemHealth.warnings.map(w => w.message).join(' · ') : 'System health — click to open dashboard'}- >- <span className="font-pixel text-[10px] text-gray-400 tracking-wide flex items-center gap-1.5">- <span className={`w-1.5 h-1.5 rounded-full ${sentinel.dot} shadow-[0_0_4px_currentColor]`} />- HEALTH- </span>- <span className="font-pixel text-[10px] tracking-wide flex items-center gap-2">- <span className={metricColor(cpuPct)}>{cpuPct != null ? `${cpuPct}%` : '—'}</span>- <span className="text-gray-600">/</span>- <span className={metricColor(memPct)}>{memPct != null ? `${memPct}%` : '—'}</span>- <span className="text-gray-600">/</span>- <span className={metricColor(diskPct)}>{diskPct != null ? `${diskPct}%` : '—'}</span>- </span>- </button>- <div className="flex items-center justify-between gap-6 -mt-0.5">- <span className="font-pixel text-[8px] text-gray-600 tracking-wider pl-3.5">CPU · MEM · DISK</span>- <span className={`font-pixel text-[8px] ${sentinel.text} tracking-wider`}>{sentinel.label}</span>+ <CityVitalsList {...vitals} />+ </div></div>- <StatButton- label="AGENTS"- valueClass={activeAgentCount > 0 ? 'text-emerald-400' : 'text-gray-600'}- value={`${activeAgentCount} ACTIVE`}- prefix={activeAgentCount > 0 ? <span className="inline-block w-1.5 h-1.5 rounded-full bg-emerald-400 mr-1 animate-pulse" /> : null}- onClick={() => navigate('/cos')}- title="Open Chief of Staff"- />-- {stoppedApps > 0 && (- <StatButton- label="STOPPED"- valueClass="text-red-400"- value={stoppedApps}- onClick={() => navigate('/apps')}- title="View apps"- />- )}-- {archivedApps > 0 && (- <StatButton- label="ARCHIVED"- valueClass="text-gray-500"- value={archivedApps}- onClick={() => navigate('/apps')}- title="View apps"- />- )}-- {(pendingReview > 0 || alertCount > 0) && (- <StatButton- label="REVIEW"- valueClass={alertCount > 0 ? 'text-orange-400' : 'text-cyan-400'}- value={`${pendingReview} PENDING${alertCount > 0 ? ` · ${alertCount} ALERT${alertCount === 1 ? '' : 'S'}` : ''}`}- onClick={() => navigate('/review')}- title="Open Review Hub"- />- )}-- <StatButton- label="NODES"- valueClass={onlinePeers > 0 ? 'text-violet-400' : 'text-gray-500'}- value={`${onlinePeers}/${totalNodes} LINKED`}- onClick={() => navigate('/instances')}- title="Open Federation / Instances"- />-- {notificationCounts?.unread > 0 && (- <StatButton- label="NOTIFS"- valueClass="text-cyan-400"- value={`${notificationCounts.unread} UNREAD`}- onClick={() => navigate('/')}- title="Open dashboard alerts"- />- )}-- {productivityData?.todaySucceeded > 0 && (- <StatButton- label="TASKS"- valueClass="text-purple-400"- value={`${productivityData.todaySucceeded} TODAY`}- onClick={() => navigate('/cos')}- title="Open Chief of Staff"- />- )}-- {productivityData?.currentDailyStreak > 0 && (- <StatButton- label="STREAK"- valueClass={productivityData.currentDailyStreak >= 3 ? 'text-orange-400' : 'text-gray-400'}- value={`${productivityData.currentDailyStreak}d`}- onClick={() => navigate('/cos')}- title="Open Chief of Staff"- />+ {filter && onFilterChange && (+ <div className="absolute top-3 left-1/2 -translate-x-1/2">+ <CityFilterBar+ filter={filter}+ onChange={onFilterChange}+ onJumpToFirst={onJumpToFirst}+ matchCount={matchCount}+ />+ </div>)}- {/* Divider */}- <div className="border-t border-cyan-500/15 mt-1.5 pt-1.5">- <div className="flex items-center justify-between">- <span className="font-pixel text-[9px] text-cyan-500/40 tracking-widest">SYS.OK</span>- <span className="font-pixel text-[9px] text-cyan-500/40 tracking-widest">- {new Date().toLocaleDateString('en-US', { month: 'short', day: 'numeric' }).toUpperCase()}- </span>+ {/* Top-right: Connection + CoS status */}+ <div className="absolute top-3 right-3 pointer-events-auto">+ <div className="relative bg-black/85 backdrop-blur-sm border border-cyan-500/40 rounded-lg px-4 py-2.5 flex items-center gap-4">+ <HudCorner position="tl" />+ <HudCorner position="tr" />+ <HudCorner position="bl" />+ <HudCorner position="br" />++ <div className="flex items-center gap-2">+ <span className={`w-2.5 h-2.5 rounded-full ${connected ? 'bg-port-success shadow-[0_0_8px_rgba(34,197,94,0.6)]' : 'bg-port-error shadow-[0_0_8px_rgba(239,68,68,0.6)] animate-pulse'}`} />+ <span className={`font-pixel text-[11px] tracking-wide ${connected ? 'text-gray-300' : 'text-port-error'}`}>+ {connected ? 'LINK' : 'OFFLINE'}+ </span>+ </div>+ <div className="w-px h-5 bg-cyan-500/25" />+ <div className="flex items-center gap-2">+ <span className={`w-2.5 h-2.5 rounded-full ${cosStatus?.running ? 'bg-cyan-400 animate-pulse shadow-[0_0_8px_rgba(6,182,212,0.6)]' : 'bg-gray-600'}`} />+ <span className={`font-pixel text-[11px] tracking-wide ${cosStatus?.running ? 'text-cyan-400' : 'text-gray-500'}`}>+ CoS {cosStatus?.running ? 'RUN' : 'IDLE'}+ </span>+ </div></div></div>- </div>- </div>- {filter && onFilterChange && (- <div className="absolute top-3 left-1/2 -translate-x-1/2">- <CityFilterBar- filter={filter}- onChange={onFilterChange}- onJumpToFirst={onJumpToFirst}- matchCount={matchCount}+ {/* Right side: Intel pane (Attention + Activity tabs) */}+ <CityIntelPane+ apps={apps}+ cosAgents={cosAgents}+ reviewCounts={reviewCounts}+ instances={instances}+ systemHealth={systemHealth}+ notificationCounts={notificationCounts}+ eventLogs={eventLogs}/>- </div>- )}- {/* Top-right: Connection + CoS status */}- <div className="absolute top-3 right-3 pointer-events-auto">- <div className="relative bg-black/85 backdrop-blur-sm border border-cyan-500/40 rounded-lg px-4 py-2.5 flex items-center gap-4">- <HudCorner position="tl" />- <HudCorner position="tr" />- <HudCorner position="bl" />- <HudCorner position="br" />-- <div className="flex items-center gap-2">- <span className={`w-2.5 h-2.5 rounded-full ${connected ? 'bg-port-success shadow-[0_0_8px_rgba(34,197,94,0.6)]' : 'bg-port-error shadow-[0_0_8px_rgba(239,68,68,0.6)] animate-pulse'}`} />- <span className={`font-pixel text-[11px] tracking-wide ${connected ? 'text-gray-300' : 'text-port-error'}`}>- {connected ? 'LINK' : 'OFFLINE'}- </span>- </div>- <div className="w-px h-5 bg-cyan-500/25" />- <div className="flex items-center gap-2">- <span className={`w-2.5 h-2.5 rounded-full ${cosStatus?.running ? 'bg-cyan-400 animate-pulse shadow-[0_0_8px_rgba(6,182,212,0.6)]' : 'bg-gray-600'}`} />- <span className={`font-pixel text-[11px] tracking-wide ${cosStatus?.running ? 'text-cyan-400' : 'text-gray-500'}`}>- CoS {cosStatus?.running ? 'RUN' : 'IDLE'}- </span>- </div>- </div>- </div>-- {/* Right side: Intel pane (Attention + Activity tabs) */}- <CityIntelPane- apps={apps}- cosAgents={cosAgents}- reviewCounts={reviewCounts}- instances={instances}- systemHealth={systemHealth}- notificationCounts={notificationCounts}- eventLogs={eventLogs}- />-- {/* Bottom: Agent status bar */}- <CityAgentBar cosAgents={cosAgents} agentMap={agentMap} />-- {/* Bottom-right: character level / XP HUD badge (roadmap 2.11) */}- <CityXpBadge character={character} />+ {/* Bottom: Agent status bar */}+ <CityAgentBar cosAgents={cosAgents} agentMap={agentMap} />++ {/* Bottom-right: character level / XP HUD badge (roadmap 2.11) */}+ <CityXpBadge character={character} />++ {/* Bottom-left: mini-map + Settings gear + legend + corner decoration */}+ <div className="absolute bottom-16 left-3">+ {/* Top-down mini-map of every building (roadmap 2.8) */}+ <CityMiniMap apps={apps} onSelectApp={onSelectApp} />++ {/* Status legend */}+ <div className="pointer-events-none mb-2 bg-black/70 backdrop-blur-sm border border-cyan-500/15 rounded-lg px-2.5 py-2 space-y-1">+ <div className="font-pixel text-[8px] text-cyan-500/50 tracking-wider mb-1">LEGEND</div>+ <div className="flex items-center gap-1.5">+ <span className="w-2 h-2 rounded-xs bg-cyan-500" />+ <span className="font-pixel text-[8px] text-gray-400 tracking-wide">ONLINE</span>+ </div>+ <div className="flex items-center gap-1.5">+ <span className="w-2 h-2 rounded-xs bg-red-500" />+ <span className="font-pixel text-[8px] text-gray-400 tracking-wide">STOPPED</span>+ </div>+ <div className="flex items-center gap-1.5">+ <span className="w-2 h-2 rounded-xs bg-violet-500" />+ <span className="font-pixel text-[8px] text-gray-400 tracking-wide">NOT STARTED</span>+ </div>+ <div className="flex items-center gap-1.5">+ <span className="w-2 h-2 rounded-xs bg-slate-500" />+ <span className="font-pixel text-[8px] text-gray-400 tracking-wide">ARCHIVED</span>+ </div>+ </div>- {/* Center crosshair in exploration mode */}- {explorationMode && (- <div className="absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 pointer-events-none">- <div className="relative w-6 h-6">- <div className="absolute top-0 left-1/2 -translate-x-1/2 w-px h-2 bg-cyan-400/60" />- <div className="absolute bottom-0 left-1/2 -translate-x-1/2 w-px h-2 bg-cyan-400/60" />- <div className="absolute left-0 top-1/2 -translate-y-1/2 w-2 h-px bg-cyan-400/60" />- <div className="absolute right-0 top-1/2 -translate-y-1/2 w-2 h-px bg-cyan-400/60" />- <div className="absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-1 h-1 rounded-full bg-cyan-400/40" />+ {/* Drop In / Fly Out button */}+ <button+ onClick={onToggleExploration}+ className={`pointer-events-auto mb-2 relative bg-black/85 backdrop-blur-sm border rounded-lg px-3 py-2 hover:bg-cyan-500/10 transition-all group ${+ explorationMode+ ? 'border-cyan-400/60 shadow-[0_0_8px_rgba(6,182,212,0.3)]'+ : 'border-cyan-500/30 hover:border-cyan-400/60'+ }`}+ title={explorationMode ? 'Return to orbital view (Tab)' : 'Enter street-level exploration (Tab)'}+ >+ <HudCorner position="tl" />+ <HudCorner position="br" />+ <div className="font-pixel text-[10px] text-cyan-400 tracking-wider" style={{ textShadow: '0 0 6px rgba(6,182,212,0.4)' }}>+ {explorationMode ? '[ FLY OUT ]' : '[ DROP IN ]'}+ </div>+ <div className="font-pixel text-[7px] text-cyan-500/40 tracking-wide mt-0.5 text-center">(Tab)</div>+ </button>++ {/* Photo mode — cinematic camera + postcard capture */}+ {onEnterPhotoMode && (+ <button+ onClick={onEnterPhotoMode}+ className="pointer-events-auto mb-2 relative bg-black/85 backdrop-blur-sm border border-cyan-500/30 rounded-lg w-10 h-10 flex items-center justify-center hover:border-cyan-400/60 hover:bg-cyan-500/10 transition-all group"+ title="Photo mode — cinematic camera & screenshots"+ >+ <HudCorner position="tl" />+ <HudCorner position="br" />+ <svg className="w-4.5 h-4.5 text-cyan-500/70 group-hover:text-cyan-400 transition-colors" style={{ filter: 'drop-shadow(0 0 6px rgba(6,182,212,0.4))' }} fill="none" viewBox="0 0 24 24" stroke="currentColor" strokeWidth={2}>+ <path strokeLinecap="round" strokeLinejoin="round" d="M3 9a2 2 0 012-2h.93a2 2 0 001.664-.89l.812-1.22A2 2 0 0110.07 4h3.86a2 2 0 011.664.89l.812 1.22A2 2 0 0018.07 7H19a2 2 0 012 2v9a2 2 0 01-2 2H5a2 2 0 01-2-2V9z" />+ <path strokeLinecap="round" strokeLinejoin="round" d="M15 13a3 3 0 11-6 0 3 3 0 016 0z" />+ </svg>+ </button>+ )}++ {/* History / playback mode — scrub recorded city-state snapshots */}+ {onEnterPlayback && (+ <button+ onClick={onEnterPlayback}+ className="pointer-events-auto mb-2 relative bg-black/85 backdrop-blur-sm border border-cyan-500/30 rounded-lg w-10 h-10 flex items-center justify-center hover:border-cyan-400/60 hover:bg-cyan-500/10 transition-all group"+ title="History — scrub back through past city states"+ >+ <HudCorner position="tl" />+ <HudCorner position="br" />+ <svg className="w-4.5 h-4.5 text-cyan-500/70 group-hover:text-cyan-400 transition-colors" style={{ filter: 'drop-shadow(0 0 6px rgba(6,182,212,0.4))' }} fill="none" viewBox="0 0 24 24" stroke="currentColor" strokeWidth={2}>+ <path strokeLinecap="round" strokeLinejoin="round" d="M3 3v5h5" />+ <path strokeLinecap="round" strokeLinejoin="round" d="M3.05 13A9 9 0 106 5.3L3 8" />+ <path strokeLinecap="round" strokeLinejoin="round" d="M12 7v5l3 2" />+ </svg>+ </button>+ )}++ <button+ onClick={() => navigate(location.pathname === '/city/settings' ? `/city${location.search}` : `/city/settings${location.search}`)}+ className="pointer-events-auto mb-2 relative bg-black/85 backdrop-blur-sm border border-cyan-500/30 rounded-lg w-10 h-10 flex items-center justify-center hover:border-cyan-400/60 hover:bg-cyan-500/10 transition-all group"+ title="Settings"+ aria-label="City settings"+ >+ <HudCorner position="tl" />+ <HudCorner position="br" />+ <svg className="w-4.5 h-4.5 text-cyan-500/70 group-hover:text-cyan-400 transition-colors" style={{ filter: 'drop-shadow(0 0 6px rgba(6,182,212,0.4))' }} fill="none" viewBox="0 0 24 24" stroke="currentColor" strokeWidth={2}>+ <path strokeLinecap="round" strokeLinejoin="round" d="M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.066 2.573c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.573 1.066c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.066-2.573c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z" />+ <path strokeLinecap="round" strokeLinejoin="round" d="M15 12a3 3 0 11-6 0 3 3 0 016 0z" />+ </svg>+ </button>+ <div className="pointer-events-none">+ <div className="font-pixel text-[8px] text-cyan-500/20 tracking-widest leading-tight">+ {'>'} SYS.INIT<br/>+ {'>'} NET.LINK<br/>+ {'>'} HUD.READY+ </div>+ </div></div>- </div>+ </>+ ) : (+ <CityHudCompact+ time={time}+ vitals={vitals}+ connected={connected}+ cosStatus={cosStatus}+ character={character}+ filter={filter}+ onFilterChange={onFilterChange}+ onJumpToFirst={onJumpToFirst}+ matchCount={matchCount}+ apps={apps}+ cosAgents={cosAgents}+ reviewCounts={reviewCounts}+ instances={instances}+ systemHealth={systemHealth}+ notificationCounts={notificationCounts}+ eventLogs={eventLogs}+ onToggleExploration={onToggleExploration}+ explorationMode={explorationMode}+ onSelectApp={onSelectApp}+ onEnterPhotoMode={onEnterPhotoMode}+ onEnterPlayback={onEnterPlayback}+ />)}- {/* Controls hint overlay */}- <ControlsHint visible={explorationMode} />-- {/* Bottom-left: mini-map + Settings gear + legend + corner decoration */}- <div className="absolute bottom-16 left-3">- {/* Top-down mini-map of every building (roadmap 2.8) */}- <CityMiniMap apps={apps} onSelectApp={onSelectApp} />-- {/* Status legend */}- <div className="pointer-events-none mb-2 bg-black/70 backdrop-blur-sm border border-cyan-500/15 rounded-lg px-2.5 py-2 space-y-1">- <div className="font-pixel text-[8px] text-cyan-500/50 tracking-wider mb-1">LEGEND</div>- <div className="flex items-center gap-1.5">- <span className="w-2 h-2 rounded-xs bg-cyan-500" />- <span className="font-pixel text-[8px] text-gray-400 tracking-wide">ONLINE</span>- </div>- <div className="flex items-center gap-1.5">- <span className="w-2 h-2 rounded-xs bg-red-500" />- <span className="font-pixel text-[8px] text-gray-400 tracking-wide">STOPPED</span>- </div>- <div className="flex items-center gap-1.5">- <span className="w-2 h-2 rounded-xs bg-violet-500" />- <span className="font-pixel text-[8px] text-gray-400 tracking-wide">NOT STARTED</span>- </div>- <div className="flex items-center gap-1.5">- <span className="w-2 h-2 rounded-xs bg-slate-500" />- <span className="font-pixel text-[8px] text-gray-400 tracking-wide">ARCHIVED</span>- </div>- </div>-- {/* Drop In / Fly Out button */}- <button- onClick={onToggleExploration}- className={`pointer-events-auto mb-2 relative bg-black/85 backdrop-blur-sm border rounded-lg px-3 py-2 hover:bg-cyan-500/10 transition-all group ${- explorationMode- ? 'border-cyan-400/60 shadow-[0_0_8px_rgba(6,182,212,0.3)]'- : 'border-cyan-500/30 hover:border-cyan-400/60'- }`}- title={explorationMode ? 'Return to orbital view (Tab)' : 'Enter street-level exploration (Tab)'}- >- <HudCorner position="tl" />- <HudCorner position="br" />- <div className="font-pixel text-[10px] text-cyan-400 tracking-wider" style={{ textShadow: '0 0 6px rgba(6,182,212,0.4)' }}>- {explorationMode ? '[ FLY OUT ]' : '[ DROP IN ]'}- </div>- <div className="font-pixel text-[7px] text-cyan-500/40 tracking-wide mt-0.5 text-center">(Tab)</div>- </button>-- {/* Photo mode — cinematic camera + postcard capture */}- {onEnterPhotoMode && (- <button- onClick={onEnterPhotoMode}- className="pointer-events-auto mb-2 relative bg-black/85 backdrop-blur-sm border border-cyan-500/30 rounded-lg w-10 h-10 flex items-center justify-center hover:border-cyan-400/60 hover:bg-cyan-500/10 transition-all group"- title="Photo mode — cinematic camera & screenshots"- >- <HudCorner position="tl" />- <HudCorner position="br" />- <svg className="w-4.5 h-4.5 text-cyan-500/70 group-hover:text-cyan-400 transition-colors" style={{ filter: 'drop-shadow(0 0 6px rgba(6,182,212,0.4))' }} fill="none" viewBox="0 0 24 24" stroke="currentColor" strokeWidth={2}>- <path strokeLinecap="round" strokeLinejoin="round" d="M3 9a2 2 0 012-2h.93a2 2 0 001.664-.89l.812-1.22A2 2 0 0110.07 4h3.86a2 2 0 011.664.89l.812 1.22A2 2 0 0018.07 7H19a2 2 0 012 2v9a2 2 0 01-2 2H5a2 2 0 01-2-2V9z" />- <path strokeLinecap="round" strokeLinejoin="round" d="M15 13a3 3 0 11-6 0 3 3 0 016 0z" />- </svg>- </button>- )}-- {/* History / playback mode — scrub recorded city-state snapshots */}- {onEnterPlayback && (- <button- onClick={onEnterPlayback}- className="pointer-events-auto mb-2 relative bg-black/85 backdrop-blur-sm border border-cyan-500/30 rounded-lg w-10 h-10 flex items-center justify-center hover:border-cyan-400/60 hover:bg-cyan-500/10 transition-all group"- title="History — scrub back through past city states"- >- <HudCorner position="tl" />- <HudCorner position="br" />- <svg className="w-4.5 h-4.5 text-cyan-500/70 group-hover:text-cyan-400 transition-colors" style={{ filter: 'drop-shadow(0 0 6px rgba(6,182,212,0.4))' }} fill="none" viewBox="0 0 24 24" stroke="currentColor" strokeWidth={2}>- <path strokeLinecap="round" strokeLinejoin="round" d="M3 3v5h5" />- <path strokeLinecap="round" strokeLinejoin="round" d="M3.05 13A9 9 0 106 5.3L3 8" />- <path strokeLinecap="round" strokeLinejoin="round" d="M12 7v5l3 2" />- </svg>- </button>- )}+ {/* Center crosshair in exploration mode (shared by both layouts) */}+ {explorationMode && <Crosshair />}- <button- onClick={() => navigate(location.pathname === '/city/settings' ? '/city' : '/city/settings')}- className="pointer-events-auto mb-2 relative bg-black/85 backdrop-blur-sm border border-cyan-500/30 rounded-lg w-10 h-10 flex items-center justify-center hover:border-cyan-400/60 hover:bg-cyan-500/10 transition-all group"- title="Settings"- >- <HudCorner position="tl" />- <HudCorner position="br" />- <svg className="w-4.5 h-4.5 text-cyan-500/70 group-hover:text-cyan-400 transition-colors" style={{ filter: 'drop-shadow(0 0 6px rgba(6,182,212,0.4))' }} fill="none" viewBox="0 0 24 24" stroke="currentColor" strokeWidth={2}>- <path strokeLinecap="round" strokeLinejoin="round" d="M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.066 2.573c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.573 1.066c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.066-2.573c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z" />- <path strokeLinecap="round" strokeLinejoin="round" d="M15 12a3 3 0 11-6 0 3 3 0 016 0z" />- </svg>- </button>- <div className="pointer-events-none">- <div className="font-pixel text-[8px] text-cyan-500/20 tracking-widest leading-tight">- {'>'} SYS.INIT<br/>- {'>'} NET.LINK<br/>- {'>'} HUD.READY- </div>- </div>- </div>+ {/* Controls hint overlay (shared) */}+ <ControlsHint visible={explorationMode} /></div>);}diff --git a/client/src/components/city/CityHudCompact.jsx b/client/src/components/city/CityHudCompact.jsxnew file mode 100644index 0000000000..07742821a2--- /dev/null+++ b/client/src/components/city/CityHudCompact.jsx@@ -0,0 +1,231 @@+import { useMemo } from 'react';+import { useNavigate, useLocation } from 'react-router-dom';+import { Gauge, Bell, Clock, Activity, Map as MapIcon, Filter, Palette, Compass, Camera, History, Settings, X } from 'lucide-react';+import useDrawerTab from '../../hooks/useDrawerTab';+import { buildAttentionItems, CityIntelContent } from './CityIntelPane';+import CityVitalsList from './CityVitalsList';+import CityMiniMap from './CityMiniMap';+import CityFilterBar from './CityFilterBar';+import { CITY_PANE_IDS, CITY_INTEL_PANE_IDS, CITY_PANE_LABELS } from './cityPanes';++// A 44×44 dock control. `active`/`aria-pressed` mark a toggled disclosure launcher;+// omit `active` for one-shot actions (photo, history) that just fire a callback.+function DockButton({ icon: Icon, label, active, badge = 0, badgeCritical = false, onClick }) {+ return (+ <button+ type="button"+ onClick={onClick}+ title={label}+ aria-label={label}+ aria-pressed={active === undefined ? undefined : active}+ className={`relative shrink-0 w-11 h-11 flex items-center justify-center rounded-md border transition-colors ${+ active+ ? 'border-cyan-400/70 bg-cyan-500/15 text-cyan-300 shadow-[0_0_6px_rgba(6,182,212,0.3)]'+ : 'border-cyan-500/25 text-cyan-500/70 hover:text-cyan-300 hover:border-cyan-400/50'+ }`}+ >+ <Icon size={18} aria-hidden="true" />+ {badge > 0 && (+ <span+ className={`absolute -top-1 -right-1 min-w-[16px] h-4 px-1 rounded-full font-pixel text-[8px] flex items-center justify-center ${+ badgeCritical ? 'bg-port-error text-white' : 'bg-cyan-500 text-black'+ }`}+ >+ {badge}+ </span>+ )}+ </button>+ );+}++function StatusDot({ on, label, onClass, offClass = 'bg-gray-600' }) {+ return (+ <span className="flex items-center gap-1" title={label} aria-label={label}>+ <span className={`w-2.5 h-2.5 rounded-full ${on ? onClass : offClass}`} />+ </span>+ );+}++const LEGEND_ROWS = [+ { color: 'bg-cyan-500', label: 'ONLINE' },+ { color: 'bg-red-500', label: 'STOPPED' },+ { color: 'bg-violet-500', label: 'NOT STARTED' },+ { color: 'bg-slate-500', label: 'ARCHIVED' },+];++// Compact / phone HUD. Keeps the 3D scene the focus: by default only a small clock+// chip, a status chip and a bottom dock are shown (well under 30% coverage). Every+// secondary surface (vitals, attention, timeline, activity, map, filter, legend) is+// a single mutually-exclusive disclosure sheet driven by the `cityPane` URL param —+// so only one can be open, the open one is deep-linkable, and clearing it returns to+// the unobstructed scene.+export default function CityHudCompact({+ time,+ vitals,+ connected,+ cosStatus,+ character,+ filter,+ onFilterChange,+ onJumpToFirst,+ matchCount,+ apps,+ cosAgents,+ reviewCounts,+ instances,+ systemHealth,+ notificationCounts,+ eventLogs,+ onToggleExploration,+ explorationMode,+ onSelectApp,+ onEnterPhotoMode,+ onEnterPlayback,+}) {+ const navigate = useNavigate();+ const location = useLocation();+ const [activePane, setActivePane] = useDrawerTab('cityPane', null, CITY_PANE_IDS);+ const togglePane = (id) => setActivePane(activePane === id ? null : id);++ const items = useMemo(+ () => buildAttentionItems({ apps, cosAgents, reviewCounts, instances, systemHealth, notificationCounts }),+ [apps, cosAgents, reviewCounts, instances, systemHealth, notificationCounts],+ );+ const criticalCount = items.filter(i => i.severity === 'critical').length;+ const hasApps = (apps || []).length > 0;++ const onSettings = location.pathname === '/city/settings';+ const goSettings = () => navigate(onSettings ? `/city${location.search}` : `/city/settings${location.search}`);++ const renderPaneBody = () => {+ if (CITY_INTEL_PANE_IDS.includes(activePane)) {+ return <CityIntelContent tab={activePane} items={items} eventLogs={eventLogs} />;+ }+ if (activePane === 'vitals') {+ return <div className="p-3"><CityVitalsList {...vitals} /></div>;+ }+ if (activePane === 'map') {+ return <div className="p-3 flex justify-center"><CityMiniMap apps={apps} onSelectApp={onSelectApp} alwaysShow /></div>;+ }+ if (activePane === 'filter') {+ return (+ <div className="p-3">+ <CityFilterBar filter={filter} onChange={onFilterChange} onJumpToFirst={onJumpToFirst} matchCount={matchCount} />+ </div>+ );+ }+ if (activePane === 'legend') {+ return (+ <div className="p-3 grid grid-cols-2 gap-2">+ {LEGEND_ROWS.map(row => (+ <div key={row.label} className="flex items-center gap-1.5">+ <span className={`w-2.5 h-2.5 rounded-xs ${row.color}`} />+ <span className="font-pixel text-[9px] text-gray-300 tracking-wide">{row.label}</span>+ </div>+ ))}+ </div>+ );+ }+ return null;+ };++ return (+ <>+ {/* Top-left: compact clock + health → opens vitals */}+ <div className="absolute top-2 left-2 pointer-events-auto">+ <button+ type="button"+ onClick={() => togglePane('vitals')}+ aria-label="Time and system vitals"+ aria-pressed={activePane === 'vitals'}+ className={`relative bg-black/85 backdrop-blur-sm border rounded-lg px-3 min-h-[44px] flex items-center gap-2 transition-colors ${+ activePane === 'vitals' ? 'border-cyan-400/70' : 'border-cyan-500/40'+ }`}+ >+ <span className={`w-2 h-2 rounded-full ${vitals.sentinel.dot} shadow-[0_0_4px_currentColor]`} />+ <span className="font-pixel text-cyan-400 text-sm tracking-wider" style={{ textShadow: '0 0 8px rgba(6,182,212,0.5)' }}>+ {time.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' })}+ </span>+ <span className="font-pixel text-[9px] text-cyan-500 tracking-wide">{vitals.activeApps}/{vitals.totalApps}</span>+ </button>+ </div>++ {/* Top-right: connection + CoS + level */}+ <div className="absolute top-2 right-2 pointer-events-auto flex items-center gap-1.5">+ <div+ className="bg-black/85 backdrop-blur-sm border border-cyan-500/40 rounded-lg px-2.5 min-h-[44px] flex items-center gap-2"+ role="status"+ aria-label={`Link ${connected ? 'online' : 'offline'}, Chief of Staff ${cosStatus?.running ? 'running' : 'idle'}`}+ >+ <StatusDot on={connected} label={connected ? 'Link online' : 'Link offline'} onClass="bg-port-success shadow-[0_0_8px_rgba(34,197,94,0.6)]" offClass="bg-port-error" />+ <StatusDot on={cosStatus?.running} label={cosStatus?.running ? 'CoS running' : 'CoS idle'} onClass="bg-cyan-400 animate-pulse shadow-[0_0_8px_rgba(6,182,212,0.6)]" />+ </div>+ {character?.level != null && (+ <button+ type="button"+ onClick={() => navigate('/character')}+ aria-label={`Character sheet — level ${character.level}`}+ title="Open character sheet"+ className="bg-black/85 backdrop-blur-sm border border-cyan-500/40 rounded-lg px-2.5 min-h-[44px] flex items-center font-pixel text-[11px] text-cyan-300 tracking-wider"+ >+ LV {character.level}+ </button>+ )}+ </div>++ {/* Disclosure sheet — one surface at a time, above the dock */}+ {activePane && (+ <div className="absolute inset-x-2 bottom-16 pointer-events-auto">+ <div className="bg-black/90 backdrop-blur-md border border-cyan-500/35 rounded-lg flex flex-col max-h-[55vh] overflow-hidden">+ <div className="flex items-center justify-between pl-3 pr-1 py-1.5 border-b border-cyan-500/20 shrink-0">+ <span className="font-pixel text-[11px] text-cyan-400 tracking-widest" style={{ textShadow: '0 0 8px rgba(6,182,212,0.4)' }}>+ {(CITY_PANE_LABELS[activePane] || '').toUpperCase()}+ </span>+ <button+ type="button"+ onClick={() => setActivePane(null)}+ aria-label="Close panel"+ title="Close"+ className="w-11 h-11 flex items-center justify-center text-gray-400 hover:text-cyan-400 transition-colors"+ >+ <X size={18} aria-hidden="true" />+ </button>+ </div>+ <div className="flex-1 flex flex-col min-h-0 overflow-y-auto">+ {renderPaneBody()}+ </div>+ </div>+ </div>+ )}++ {/* Bottom dock — every HUD function within two taps */}+ <div className="absolute bottom-2 left-2 right-2 pointer-events-auto">+ <div+ className="flex items-center gap-1.5 bg-black/85 backdrop-blur-sm border border-cyan-500/30 rounded-lg px-1.5 py-1.5 overflow-x-auto scrollbar-hide touch-pan-x"+ role="toolbar"+ aria-label="City controls"+ >+ <DockButton icon={Gauge} label="System vitals" active={activePane === 'vitals'} onClick={() => togglePane('vitals')} />+ <DockButton icon={Bell} label="Attention" active={activePane === 'attention'} badge={items.length} badgeCritical={criticalCount > 0} onClick={() => togglePane('attention')} />+ <DockButton icon={Clock} label="Timeline" active={activePane === 'timeline'} onClick={() => togglePane('timeline')} />+ <DockButton icon={Activity} label="Activity log" active={activePane === 'activity'} onClick={() => togglePane('activity')} />+ {hasApps && <DockButton icon={MapIcon} label="Map" active={activePane === 'map'} onClick={() => togglePane('map')} />}+ <DockButton icon={Filter} label="Filter apps" active={activePane === 'filter'} onClick={() => togglePane('filter')} />+ <DockButton icon={Palette} label="Legend" active={activePane === 'legend'} onClick={() => togglePane('legend')} />++ <div className="w-px h-6 bg-cyan-500/20 shrink-0" />++ <DockButton+ icon={Compass}+ label={explorationMode ? 'Fly out to orbital view' : 'Drop in to street level'}+ active={explorationMode}+ onClick={onToggleExploration}+ />+ {onEnterPhotoMode && <DockButton icon={Camera} label="Photo mode" onClick={onEnterPhotoMode} />}+ {onEnterPlayback && <DockButton icon={History} label="History playback" onClick={onEnterPlayback} />}+ <DockButton icon={Settings} label="City settings" active={onSettings} onClick={goSettings} />+ </div>+ </div>+ </>+ );+}diff --git a/client/src/components/city/CityHudCompact.test.jsx b/client/src/components/city/CityHudCompact.test.jsxnew file mode 100644index 0000000000..847d2313ac--- /dev/null+++ b/client/src/components/city/CityHudCompact.test.jsx@@ -0,0 +1,111 @@+import { describe, it, expect } from 'vitest';+import { render, screen, fireEvent } from '@testing-library/react';+import { MemoryRouter, useLocation } from 'react-router-dom';+import CityHudCompact from './CityHudCompact';++function Loc() {+ const l = useLocation();+ return <div data-testid="loc">{l.search}</div>;+}++const baseVitals = {+ uptimeSeconds: 0,+ sentinel: { dot: 'bg-cyan-400', text: 'text-cyan-400', label: 'OK' },+ cpuPct: 10,+ memPct: 20,+ diskPct: 30,+ warnings: [],+ activeAgentCount: 0,+ stoppedApps: 0,+ archivedApps: 0,+ pendingReview: 0,+ alertCount: 0,+ onlinePeers: 0,+ totalNodes: 0,+ notificationCounts: { unread: 0 },+ productivityData: {},+ activeApps: 1,+ totalApps: 2,+};++const baseProps = {+ time: new Date('2026-07-14T12:00:00'),+ vitals: baseVitals,+ connected: true,+ cosStatus: { running: false },+ character: { level: 5 },+ filter: { status: 'all', search: '' },+ onFilterChange: () => {},+ onJumpToFirst: () => {},+ matchCount: 0,+ apps: [{ id: 'a1', name: 'App One', overallStatus: 'online' }],+ cosAgents: [],+ reviewCounts: { total: 0, alert: 0 },+ instances: { peers: [] },+ systemHealth: {},+ notificationCounts: { unread: 0 },+ eventLogs: [],+ onToggleExploration: () => {},+ explorationMode: false,+ onSelectApp: () => {},+ onEnterPhotoMode: () => {},+ onEnterPlayback: () => {},+};++const renderCompact = (search = '', props = {}) =>+ render(+ <MemoryRouter initialEntries={[`/city${search}`]}>+ <CityHudCompact {...baseProps} {...props} />+ <Loc />+ </MemoryRouter>,+ );++describe('CityHudCompact', () => {+ it('shows no secondary surface by default (scene stays unobscured)', () => {+ renderCompact();+ // Dock controls present…+ expect(screen.getByLabelText('System vitals')).toBeInTheDocument();+ expect(screen.getByLabelText('Attention')).toBeInTheDocument();+ // …but no disclosure sheet is open.+ expect(screen.queryByText('SYSTEM VITALS')).not.toBeInTheDocument();+ expect(screen.queryByRole('button', { name: 'Close panel' })).not.toBeInTheDocument();+ });++ it('opens a pane from the dock and reflects it in the URL', () => {+ renderCompact();+ fireEvent.click(screen.getByLabelText('Attention'));+ expect(screen.getByTestId('loc').textContent).toContain('cityPane=attention');+ // The sheet header for the opened pane appears.+ expect(screen.getByText('ATTENTION')).toBeInTheDocument();+ });++ it('restores the open pane from the URL on load', () => {+ renderCompact('?cityPane=vitals');+ expect(screen.getByText('SYSTEM VITALS')).toBeInTheDocument();+ });++ it('keeps only one surface open at a time (mutual exclusivity)', () => {+ renderCompact('?cityPane=vitals');+ expect(screen.getByText('SYSTEM VITALS')).toBeInTheDocument();+ fireEvent.click(screen.getByLabelText('Attention'));+ // Switching panes closes the previous one.+ expect(screen.queryByText('SYSTEM VITALS')).not.toBeInTheDocument();+ expect(screen.getByText('ATTENTION')).toBeInTheDocument();+ expect(screen.getByTestId('loc').textContent).toContain('cityPane=attention');+ });++ it('toggling the active dock launcher closes the pane', () => {+ renderCompact('?cityPane=vitals');+ fireEvent.click(screen.getByLabelText('System vitals'));+ expect(screen.queryByText('SYSTEM VITALS')).not.toBeInTheDocument();+ expect(screen.getByTestId('loc').textContent).toBe('');+ });++ it('the close button clears the surface and the URL param', () => {+ renderCompact('?cityPane=attention');+ expect(screen.getByText('ATTENTION')).toBeInTheDocument();+ fireEvent.click(screen.getByRole('button', { name: 'Close panel' }));+ expect(screen.queryByText('ATTENTION')).not.toBeInTheDocument();+ expect(screen.getByTestId('loc').textContent).toBe('');+ });+});diff --git a/client/src/components/city/CityIntelPane.jsx b/client/src/components/city/CityIntelPane.jsxindex 05b5c38993..f7077cf726 100644--- a/client/src/components/city/CityIntelPane.jsx+++ b/client/src/components/city/CityIntelPane.jsx@@ -2,6 +2,8 @@ import { useMemo, useRef, useEffect, useState } from 'react';import { useNavigate } from 'react-router-dom';import { formatClockTime } from '../../utils/formatters';import { computeActivityDensity, buildTimelineBuckets } from '../../utils/cityTimeline';+import useDrawerTab from '../../hooks/useDrawerTab';+import { CITY_PANE_IDS, CITY_INTEL_PANE_IDS } from './cityPanes';const SEVERITY_RANK = { critical: 0, warning: 1, info: 2 };const SEVERITY_COLORS = {@@ -10,7 +12,7 @@ const SEVERITY_COLORS = {info: { dot: 'bg-cyan-400', text: 'text-cyan-300', border: 'border-cyan-500/25' },};-function buildAttentionItems({ apps, cosAgents, reviewCounts, instances, systemHealth, notificationCounts }) {+export function buildAttentionItems({ apps, cosAgents, reviewCounts, instances, systemHealth, notificationCounts }) {const items = [];(apps || []).forEach(app => {@@ -333,8 +335,31 @@ function TimelineView({ logs }) {);}+// Intel-pane tabs. `attention`/`timeline`/`activity` line up with the same-named+// `cityPane` values so the desktop tab and the compact disclosure sheet address the+// same surface through one URL param.+export const CITY_INTEL_TABS = [+ { id: 'attention', label: 'ATTENTION' },+ { id: 'timeline', label: 'TIMELINE' },+ { id: 'activity', label: 'ACTIVITY' },+];++// Renders just the body for a given intel tab — reused by the desktop cockpit pane+// and the compact/phone disclosure sheet so both show identical content. The parent+// must be a bounded `flex flex-col` container (the lists are `flex-1`).+export function CityIntelContent({ tab, items, eventLogs }) {+ if (tab === 'timeline') return <TimelineView logs={eventLogs} />;+ if (tab === 'activity') return <ActivityLogList logs={eventLogs} />;+ return <AttentionList items={items} />;+}+export default function CityIntelPane({ apps, cosAgents, reviewCounts, instances, systemHealth, notificationCounts, eventLogs }) {- const [tab, setTab] = useState('attention');+ // The active tab is URL-addressable via `cityPane` (shared with the compact+ // layout), so a reload / back-forward restores it and a deep link opens it.+ // `vitals`/`map`/etc. aren't intel tabs, so anything outside the intel subset+ // falls back to `attention`.+ const [activePane, setActivePane] = useDrawerTab('cityPane', null, CITY_PANE_IDS);+ const tab = CITY_INTEL_PANE_IDS.includes(activePane) ? activePane : 'attention';const [collapsed, setCollapsed] = useState(false);const items = useMemo(@@ -343,14 +368,17 @@ export default function CityIntelPane({ apps, cosAgents, reviewCounts, instances);const criticalCount = items.filter(i => i.severity === 'critical').length;+ const selectTab = (id) => { setActivePane(id); setCollapsed(false); };return (<div className={`absolute top-16 right-3 ${collapsed ? '' : 'bottom-20'} w-72 pointer-events-auto`}><div className={`${collapsed ? '' : 'h-full'} bg-black/85 backdrop-blur-sm border border-cyan-500/30 rounded-lg overflow-hidden flex flex-col`}>- <div className="flex items-stretch border-b border-cyan-500/20">+ <div className="flex items-stretch border-b border-cyan-500/20" role="tablist" aria-label="Intel"><buttontype="button"- onClick={() => { setTab('attention'); setCollapsed(false); }}+ role="tab"+ aria-selected={tab === 'attention' && !collapsed}+ onClick={() => selectTab('attention')}className={`flex-1 flex items-center justify-center gap-1.5 px-2 py-2 transition-colors ${tab === 'attention' && !collapsed? 'bg-cyan-500/10 text-cyan-400'@@ -369,7 +397,9 @@ export default function CityIntelPane({ apps, cosAgents, reviewCounts, instances</button><buttontype="button"- onClick={() => { setTab('timeline'); setCollapsed(false); }}+ role="tab"+ aria-selected={tab === 'timeline' && !collapsed}+ onClick={() => selectTab('timeline')}className={`flex-1 flex items-center justify-center gap-1.5 px-2 py-2 border-l border-cyan-500/20 transition-colors ${tab === 'timeline' && !collapsed? 'bg-cyan-500/10 text-cyan-400'@@ -381,7 +411,9 @@ export default function CityIntelPane({ apps, cosAgents, reviewCounts, instances</button><buttontype="button"- onClick={() => { setTab('activity'); setCollapsed(false); }}+ role="tab"+ aria-selected={tab === 'activity' && !collapsed}+ onClick={() => selectTab('activity')}className={`flex-1 flex items-center justify-center gap-1.5 px-2 py-2 border-l border-cyan-500/20 transition-colors ${tab === 'activity' && !collapsed? 'bg-cyan-500/10 text-cyan-400'@@ -399,17 +431,12 @@ export default function CityIntelPane({ apps, cosAgents, reviewCounts, instancesonClick={() => setCollapsed(c => !c)}className="px-2 py-2 border-l border-cyan-500/20 text-cyan-500/50 hover:bg-cyan-500/5 hover:text-cyan-400 transition-colors"title={collapsed ? 'Expand' : 'Collapse'}+ aria-label={collapsed ? 'Expand intel pane' : 'Collapse intel pane'}><span className="font-pixel text-[11px]">{collapsed ? '[+]' : '[-]'}</span></button></div>- {!collapsed && (- tab === 'attention'- ? <AttentionList items={items} />- : tab === 'timeline'- ? <TimelineView logs={eventLogs} />- : <ActivityLogList logs={eventLogs} />- )}+ {!collapsed && <CityIntelContent tab={tab} items={items} eventLogs={eventLogs} />}</div></div>);diff --git a/client/src/components/city/CityMiniMap.jsx b/client/src/components/city/CityMiniMap.jsxindex dc4f156cd6..0ae0ec077f 100644--- a/client/src/components/city/CityMiniMap.jsx+++ b/client/src/components/city/CityMiniMap.jsx@@ -20,7 +20,7 @@ import { computeMiniMap } from '../../utils/cityMiniMap';// Map box size in px. Fixed so the projection has a stable target on desktop.const MAP_SIZE = 132;-export default function CityMiniMap({ apps, onSelectApp }) {+export default function CityMiniMap({ apps, onSelectApp, alwaysShow = false }) {// Status colors track the theme accent for 'online' (the rest stay semantic), so a// dot matches its building exactly. Read from the palette the city page provides.const { getBuildingColor } = useCityPalette();@@ -32,7 +32,7 @@ export default function CityMiniMap({ apps, onSelectApp }) {if (view.empty) return null;return (- <div className="hidden md:block mb-2 pointer-events-auto">+ <div className={`${alwaysShow ? 'block' : 'hidden md:block'} mb-2 pointer-events-auto`}><div className="relative bg-black/85 backdrop-blur-sm border border-cyan-500/30 rounded-lg p-2"><div className="flex items-center justify-between mb-1.5 px-0.5"><span className="font-pixel text-[8px] text-cyan-500/60 tracking-wider">MAP</span>diff --git a/client/src/components/city/CitySettingsPanel.jsx b/client/src/components/city/CitySettingsDrawer.jsxsimilarity index 57%rename from client/src/components/city/CitySettingsPanel.jsxrename to client/src/components/city/CitySettingsDrawer.jsxindex df735a1d76..47967cf54b 100644--- a/client/src/components/city/CitySettingsPanel.jsx+++ b/client/src/components/city/CitySettingsDrawer.jsx@@ -1,58 +1,56 @@-import { useNavigate } from 'react-router-dom';+import Drawer from '../Drawer';+import useDrawerTab from '../../hooks/useDrawerTab';import { useCitySettingsContext } from './CitySettingsContext';import { QUALITY_PRESETS } from '../../hooks/useCitySettings';-function HudCorner({ position = 'tl', color = 'cyan' }) {- const corners = {- tl: 'top-0 left-0 border-t border-l',- tr: 'top-0 right-0 border-t border-r',- bl: 'bottom-0 left-0 border-b border-l',- br: 'bottom-0 right-0 border-b border-r',- };- return (- <div- className={`absolute w-2 h-2 ${corners[position]} border-${color}-400/60`}- style={{ borderWidth: '1px' }}- />- );-}+// City settings migrated onto the shared tabbed <Drawer> (issue #2591) — replaces+// the old bespoke bottom-right 19rem page-length scroller. Grouped into+// Performance / Audio / Visual / Explore so no single tab is a long scroll, with the+// active tab deep-linked through the `cityTab` URL param (useDrawerTab). All mutable+// state lives in CitySettingsContext ABOVE this remounting body, so switching tabs+// (which remounts the body) never drops an edit.-function SettingToggle({ label, value, onChange, description }) {+function SettingToggle({ id, label, value, onChange, description }) {return (- <div className="flex items-center justify-between py-1.5 group" title={description}>- <span className="font-pixel text-[10px] text-gray-400 tracking-wide group-hover:text-gray-300 transition-colors">+ <div className="flex items-center justify-between py-2 group" title={description}>+ <label htmlFor={id} className="font-pixel text-[11px] text-gray-300 tracking-wide cursor-pointer">{label}- </span>+ </label><button+ id={id}+ type="button"+ role="switch"+ aria-checked={value}+ aria-label={label}onClick={() => onChange(!value)}- className={`w-9 h-5 rounded-full relative transition-colors ${value ? 'bg-cyan-500/40 border-cyan-500/60' : 'bg-gray-700/40 border-gray-600/40'} border`}+ className={`w-11 h-6 rounded-full relative transition-colors border ${value ? 'bg-cyan-500/40 border-cyan-500/60' : 'bg-gray-700/40 border-gray-600/40'}`}>- <div- className={`absolute top-0.5 w-3 h-3 rounded-full transition-all ${value ? 'left-[16px] bg-cyan-400 shadow-[0_0_6px_rgba(6,182,212,0.5)]' : 'left-[2px] bg-gray-500'}`}+ <span+ className={`absolute top-0.5 w-4 h-4 rounded-full transition-all ${value ? 'left-[22px] bg-cyan-400 shadow-[0_0_6px_rgba(6,182,212,0.5)]' : 'left-[2px] bg-gray-500'}`}/></button></div>);}-function SettingSlider({ label, value, onChange, min = 0, max = 1, step = 0.05, format, description }) {- const displayValue = format- ? format(value)- : `${Math.round(value * 100)}%`;+function SettingSlider({ id, label, value, onChange, min = 0, max = 1, step = 0.05, format, description }) {+ const displayValue = format ? format(value) : `${Math.round(value * 100)}%`;return (- <div className="py-1.5" title={description}>- <div className="flex items-center justify-between mb-1">- <span className="font-pixel text-[10px] text-gray-400 tracking-wide">{label}</span>+ <div className="py-2" title={description}>+ <div className="flex items-center justify-between mb-1.5">+ <label htmlFor={id} className="font-pixel text-[11px] text-gray-300 tracking-wide">{label}</label><span className="font-pixel text-[10px] text-cyan-400/70">{displayValue}</span></div><input+ id={id}type="range"min={min}max={max}step={step}value={value}onChange={(e) => onChange(parseFloat(e.target.value))}- className="w-full h-1.5 bg-gray-700 rounded-full appearance-none cursor-pointer accent-cyan-500"+ aria-label={label}+ className="w-full h-2 bg-gray-700 rounded-full appearance-none cursor-pointer accent-cyan-500"style={{background: `linear-gradient(to right, #06b6d4 0%, #06b6d4 ${(value - min) / (max - min) * 100}%, #374151 ${(value - min) / (max - min) * 100}%, #374151 100%)`,}}@@ -61,29 +59,31 @@ function SettingSlider({ label, value, onChange, min = 0, max = 1, step = 0.05,);}-// Segmented enum picker — one glowing button per option, with an optional hint line.-// `isActive` defaults to strict equality; pass a predicate for legacy-value mapping.+// Segmented enum picker. `isActive` defaults to strict equality; pass a predicate+// for legacy-value mapping.function SettingSegment({ label, options, value, onChange, hint, isActive }) {const activeFor = isActive ?? ((key) => value === key);return (- <div className="py-1.5">- {label && <div className="font-pixel text-[10px] text-gray-400 tracking-wide mb-2">{label}</div>}- <div className={`grid gap-1.5 ${options.length === 2 ? 'grid-cols-2' : 'grid-cols-3'}`}>+ <div className="py-2">+ {label && <div className="font-pixel text-[11px] text-gray-300 tracking-wide mb-2">{label}</div>}+ <div className={`grid gap-1.5 ${options.length === 2 ? 'grid-cols-2' : 'grid-cols-3'}`} role="group" aria-label={label}>{options.map(({ key, label: optionLabel }) => (<buttonkey={key}+ type="button"+ aria-pressed={activeFor(key)}onClick={() => onChange(key)}- className={`font-pixel text-[9px] py-2 rounded border transition-all tracking-wide ${+ className={`font-pixel text-[10px] min-h-[44px] rounded border transition-all tracking-wide ${activeFor(key)? 'bg-cyan-500/20 border-cyan-500/50 text-cyan-400 shadow-[0_0_8px_rgba(6,182,212,0.2)]'- : 'bg-gray-800/40 border-gray-700/40 text-gray-500 hover:border-gray-600 hover:text-gray-400'+ : 'bg-gray-800/40 border-gray-700/40 text-gray-400 hover:border-gray-600 hover:text-gray-300'}`}>{optionLabel}</button>))}</div>- {hint && <div className="font-pixel text-[8px] text-gray-600 tracking-wide mt-1.5">{hint}</div>}+ {hint && <div className="font-pixel text-[8px] text-gray-500 tracking-wide mt-1.5">{hint}</div>}</div>);}@@ -92,56 +92,51 @@ function SectionHeader({ title, subtitle }) {return (<div className="mb-2"><div className="font-pixel text-[10px] text-cyan-500/70 tracking-wider">{title}</div>- {subtitle && (- <div className="font-pixel text-[8px] text-gray-600 tracking-wide mt-0.5">{subtitle}</div>- )}+ {subtitle && <div className="font-pixel text-[8px] text-gray-500 tracking-wide mt-0.5">{subtitle}</div>}</div>);}-export default function CitySettingsPanel() {- const navigate = useNavigate();+export const CITY_SETTINGS_TABS = [+ { id: 'performance', label: 'Performance' },+ { id: 'audio', label: 'Audio' },+ { id: 'visual', label: 'Visual' },+ { id: 'explore', label: 'Explore' },+];+const TAB_IDS = CITY_SETTINGS_TABS.map(t => t.id);++export default function CitySettingsDrawer({ open, onClose }) {const { settings, updateSetting, resetSettings } = useCitySettingsContext();+ const [activeTab, setActiveTab] = useDrawerTab('cityTab', 'performance', TAB_IDS);- if (!settings) return null;+ if (!open || !settings) return null;return (- <div className="absolute bottom-4 right-4 z-50 pointer-events-auto animate-in slide-in-from-bottom-4 duration-300">- <div- className="relative bg-black/92 backdrop-blur-md border border-cyan-500/35 rounded-lg w-76 max-h-[80vh] overflow-y-auto"- style={{ scrollbarWidth: 'thin', scrollbarColor: 'rgba(6,182,212,0.2) transparent', width: '19rem' }}- >- <HudCorner position="tl" />- <HudCorner position="tr" />- <HudCorner position="bl" />- <HudCorner position="br" />-- {/* Header */}- <div className="sticky top-0 z-10 bg-black/95 flex items-center justify-between px-4 py-3 border-b border-cyan-500/25">- <span className="font-pixel text-[12px] text-cyan-400 tracking-widest" style={{ textShadow: '0 0 8px rgba(6,182,212,0.4)' }}>- SETTINGS- </span>- <button- onClick={() => navigate('/city')}- className="font-pixel text-[11px] text-gray-500 hover:text-cyan-400 transition-colors tracking-wide w-8 h-8 flex items-center justify-center rounded hover:bg-cyan-500/10"- >- [X]- </button>- </div>-- <div className="px-4 py-3 space-y-5">- {/* Quality Preset */}+ <Drawer+ open={open}+ onClose={onClose}+ title="City Settings"+ size="sm"+ tabs={CITY_SETTINGS_TABS}+ activeTab={activeTab}+ onTabChange={setActiveTab}+ closeLabel="Close city settings"+ >+ {activeTab === 'performance' && (+ <div className="space-y-5"><div><SectionHeader title="QUALITY PRESET" subtitle="Controls overall visual fidelity" />- <div className="grid grid-cols-4 gap-1.5">+ <div className="grid grid-cols-4 gap-1.5" role="group" aria-label="Quality preset">{Object.keys(QUALITY_PRESETS).map(preset => (<buttonkey={preset}+ type="button"+ aria-pressed={settings.qualityPreset === preset}onClick={() => updateSetting('qualityPreset', preset)}- className={`font-pixel text-[9px] py-2 rounded border transition-all tracking-wide ${+ className={`font-pixel text-[10px] min-h-[44px] rounded border transition-all tracking-wide ${settings.qualityPreset === preset? 'bg-cyan-500/20 border-cyan-500/50 text-cyan-400 shadow-[0_0_8px_rgba(6,182,212,0.2)]'- : 'bg-gray-800/40 border-gray-700/40 text-gray-500 hover:border-gray-600 hover:text-gray-400'+ : 'bg-gray-800/40 border-gray-700/40 text-gray-400 hover:border-gray-600 hover:text-gray-300'}`}>{preset.toUpperCase()}@@ -149,13 +144,25 @@ export default function CitySettingsPanel() {))}</div></div>+ <SettingSlider+ id="city-particle-density"+ label="PARTICLE DENSITY"+ value={settings.particleDensity}+ onChange={(v) => updateSetting('particleDensity', v)}+ min={0.25}+ max={2}+ step={0.25}+ description="Amount of floating particles in the scene"+ />+ </div>+ )}- <div className="border-t border-cyan-500/10" />-- {/* Music */}+ {activeTab === 'audio' && (+ <div className="space-y-5"><div><SectionHeader title="MUSIC" subtitle="Procedural synthwave background" /><SettingToggle+ id="city-music-enabled"label="SYNTHWAVE"value={settings.musicEnabled}onChange={(v) => updateSetting('musicEnabled', v)}@@ -163,6 +170,7 @@ export default function CitySettingsPanel() {/>{settings.musicEnabled && (<SettingSlider+ id="city-music-volume"label="VOLUME"value={settings.musicVolume}onChange={(v) => updateSetting('musicVolume', v)}@@ -170,11 +178,10 @@ export default function CitySettingsPanel() {/>)}</div>-- {/* Sound Effects */}<div><SectionHeader title="SOUND FX" subtitle="UI and environment sounds" /><SettingToggle+ id="city-sfx-enabled"label="ENABLED"value={settings.sfxEnabled}onChange={(v) => updateSetting('sfxEnabled', v)}@@ -182,6 +189,7 @@ export default function CitySettingsPanel() {/>{settings.sfxEnabled && (<SettingSlider+ id="city-sfx-volume"label="VOLUME"value={settings.sfxVolume}onChange={(v) => updateSetting('sfxVolume', v)}@@ -189,41 +197,32 @@ export default function CitySettingsPanel() {/>)}</div>+ </div>+ )}- <div className="border-t border-cyan-500/10" />-- {/* Visual Effects */}+ {activeTab === 'visual' && (+ <div className="space-y-5"><div><SectionHeader title="VISUAL FX" subtitle="Reflections and atmosphere" /><SettingToggle+ id="city-reflections"label="REFLECTIONS"value={settings.reflectionsEnabled}onChange={(v) => updateSetting('reflectionsEnabled', v)}description="Wet street reflections and puddles"/><SettingToggle+ id="city-scanlines"label="SCANLINES"value={settings.scanlineOverlay}onChange={(v) => updateSetting('scanlineOverlay', v)}description="CRT monitor scanline overlay"/>- <SettingSlider- label="PARTICLE DENSITY"- value={settings.particleDensity}- onChange={(v) => updateSetting('particleDensity', v)}- min={0.25}- max={2}- step={0.25}- description="Amount of floating particles in the scene"- /></div>-- <div className="border-t border-cyan-500/10" />-- {/* Scene Lighting */}<div><SectionHeader title="SCENE LIGHTING" subtitle="Brightness and time of day" /><SettingSlider+ id="city-ambient-brightness"label="AMBIENT BRIGHTNESS"value={settings.ambientBrightness}onChange={(v) => updateSetting('ambientBrightness', v)}@@ -234,6 +233,7 @@ export default function CitySettingsPanel() {description="Overall scene ambient light level"/><SettingSlider+ id="city-neon-brightness"label="NEON BRIGHTNESS"value={settings.neonBrightness}onChange={(v) => updateSetting('neonBrightness', v)}@@ -253,19 +253,20 @@ export default function CitySettingsPanel() {value={settings.timeOfDay}onChange={(key) => updateSetting('timeOfDay', key)}hint="AUTO FOLLOWS YOUR THEME (DAY / NIGHT)"- // Legacy presets (sunrise/noon/sunset/midnight) read as Auto now.isActive={(key) => (settings.timeOfDay === 'day' || settings.timeOfDay === 'night')? settings.timeOfDay === key: key === 'auto'}/></div>+ </div>+ )}- <div className="border-t border-cyan-500/10" />-- {/* Exploration */}+ {activeTab === 'explore' && (+ <div className="space-y-5"><div><SectionHeader title="EXPLORATION" subtitle="Street-level character mode" /><SettingToggle+ id="city-exploration-mode"label="DROP IN MODE"value={settings.explorationMode}onChange={(v) => updateSetting('explorationMode', v)}@@ -281,18 +282,15 @@ export default function CitySettingsPanel() {hint="CAMERA WHILE EXPLORING (V SWAPS IN-WORLD)"/></div>-- <div className="border-t border-cyan-500/10" />-- {/* Reset */}<button+ type="button"onClick={resetSettings}- className="w-full font-pixel text-[10px] py-2 rounded border border-port-error/30 text-port-error/60 hover:bg-port-error/10 hover:text-port-error transition-all tracking-wider"+ className="w-full font-pixel text-[10px] min-h-[44px] rounded border border-port-error/30 text-port-error/70 hover:bg-port-error/10 hover:text-port-error transition-all tracking-wider">RESET DEFAULTS</button></div>- </div>- </div>+ )}+ </Drawer>);}diff --git a/client/src/components/city/CitySettingsDrawer.test.jsx b/client/src/components/city/CitySettingsDrawer.test.jsxnew file mode 100644index 0000000000..ba06feb943--- /dev/null+++ b/client/src/components/city/CitySettingsDrawer.test.jsx@@ -0,0 +1,64 @@+import { describe, it, expect, vi } from 'vitest';+import { render, screen, fireEvent } from '@testing-library/react';+import { MemoryRouter, useLocation } from 'react-router-dom';+import CitySettingsDrawer from './CitySettingsDrawer';+import { CitySettingsProvider } from './CitySettingsContext';++function Loc() {+ const l = useLocation();+ return <div data-testid="loc">{l.search}</div>;+}++const renderDrawer = (search = '', onClose = () => {}) =>+ render(+ <MemoryRouter initialEntries={[`/city/settings${search}`]}>+ <CitySettingsProvider>+ <CitySettingsDrawer open onClose={onClose} />+ </CitySettingsProvider>+ <Loc />+ </MemoryRouter>,+ );++describe('CitySettingsDrawer', () => {+ it('renders the shared Drawer with the four grouped tabs', () => {+ renderDrawer();+ expect(screen.getByRole('dialog', { name: 'City Settings' })).toBeInTheDocument();+ ['Performance', 'Audio', 'Visual', 'Explore'].forEach(label => {+ expect(screen.getByRole('tab', { name: label })).toBeInTheDocument();+ });+ // Default tab content.+ expect(screen.getByText('QUALITY PRESET')).toBeInTheDocument();+ });++ it('switches tabs and persists the active tab in the URL', () => {+ renderDrawer();+ fireEvent.click(screen.getByRole('tab', { name: 'Audio' }));+ expect(screen.getByText('MUSIC')).toBeInTheDocument();+ expect(screen.queryByText('QUALITY PRESET')).not.toBeInTheDocument();+ expect(screen.getByTestId('loc').textContent).toContain('cityTab=audio');+ });++ it('deep-links the active tab from the URL param', () => {+ renderDrawer('?cityTab=visual');+ expect(screen.getByText('VISUAL FX')).toBeInTheDocument();+ expect(screen.getByRole('tab', { name: 'Visual', selected: true })).toBeInTheDocument();+ });++ it('invokes onClose from the Drawer close control', () => {+ const onClose = vi.fn();+ renderDrawer('', onClose);+ fireEvent.click(screen.getByRole('button', { name: 'Close city settings' }));+ expect(onClose).toHaveBeenCalledTimes(1);+ });++ it('renders nothing when closed', () => {+ const { container } = render(+ <MemoryRouter initialEntries={['/city']}>+ <CitySettingsProvider>+ <CitySettingsDrawer open={false} onClose={() => {}} />+ </CitySettingsProvider>+ </MemoryRouter>,+ );+ expect(container.querySelector('[role="dialog"]')).toBeNull();+ });+});diff --git a/client/src/components/city/CityVitalsList.jsx b/client/src/components/city/CityVitalsList.jsxnew file mode 100644index 0000000000..ec4eef9ae2--- /dev/null+++ b/client/src/components/city/CityVitalsList.jsx@@ -0,0 +1,130 @@+import { useNavigate } from 'react-router-dom';+import { formatDurationMs } from '../../utils/formatters';+import { StatButton, metricColor } from './cityHudBits';++// The System Vitals rows (uptime, health CPU/MEM/DISK, agents, stopped, archived,+// review, nodes, notifs, tasks, streak + the SYS.OK footer). Extracted from the+// desktop clock-rail so the SAME rows back both the desktop cockpit's vitals panel+// AND the compact/phone `vitals` disclosure surface — no divergent copies.+export default function CityVitalsList({+ uptimeSeconds,+ sentinel,+ cpuPct,+ memPct,+ diskPct,+ warnings,+ activeAgentCount,+ stoppedApps,+ archivedApps,+ pendingReview,+ alertCount,+ onlinePeers,+ totalNodes,+ notificationCounts,+ productivityData,+}) {+ const navigate = useNavigate();++ return (+ <div className="space-y-1.5">+ <div className="font-pixel text-[10px] text-cyan-500/70 tracking-wider mb-1">+ SYSTEM VITALS+ </div>++ {/* Uptime */}+ <div className="flex items-center justify-between gap-6">+ <span className="font-pixel text-[10px] text-gray-400 tracking-wide">UPTIME</span>+ <span className="font-pixel text-[11px] text-cyan-400" style={{ textShadow: '0 0 6px rgba(6,182,212,0.4)' }}>+ {formatDurationMs(uptimeSeconds * 1000)}+ </span>+ </div>++ <button+ type="button"+ onClick={() => navigate('/')}+ className="w-full flex items-center justify-between gap-3 -mx-1 px-1 py-1 min-h-[44px] sm:min-h-0 rounded hover:bg-cyan-500/5 transition-colors"+ title={warnings?.length ? warnings.map(w => w.message).join(' · ') : 'System health — click to open dashboard'}+ aria-label="System health — open dashboard"+ >+ <span className="font-pixel text-[10px] text-gray-400 tracking-wide flex items-center gap-1.5">+ <span className={`w-1.5 h-1.5 rounded-full ${sentinel.dot} shadow-[0_0_4px_currentColor]`} />+ HEALTH+ </span>+ <span className="font-pixel text-[10px] tracking-wide flex items-center gap-2">+ <span className={metricColor(cpuPct)}>{cpuPct != null ? `${cpuPct}%` : '—'}</span>+ <span className="text-gray-600">/</span>+ <span className={metricColor(memPct)}>{memPct != null ? `${memPct}%` : '—'}</span>+ <span className="text-gray-600">/</span>+ <span className={metricColor(diskPct)}>{diskPct != null ? `${diskPct}%` : '—'}</span>+ </span>+ </button>+ <div className="flex items-center justify-between gap-6 -mt-0.5">+ <span className="font-pixel text-[8px] text-gray-600 tracking-wider pl-3.5">CPU · MEM · DISK</span>+ <span className={`font-pixel text-[8px] ${sentinel.text} tracking-wider`}>{sentinel.label}</span>+ </div>++ <StatButton+ label="AGENTS"+ valueClass={activeAgentCount > 0 ? 'text-emerald-400' : 'text-gray-600'}+ value={`${activeAgentCount} ACTIVE`}+ prefix={activeAgentCount > 0 ? <span className="inline-block w-1.5 h-1.5 rounded-full bg-emerald-400 mr-1 animate-pulse" /> : null}+ onClick={() => navigate('/cos')}+ title="Open Chief of Staff"+ />++ {stoppedApps > 0 && (+ <StatButton label="STOPPED" valueClass="text-red-400" value={stoppedApps} onClick={() => navigate('/apps')} title="View apps" />+ )}++ {archivedApps > 0 && (+ <StatButton label="ARCHIVED" valueClass="text-gray-500" value={archivedApps} onClick={() => navigate('/apps')} title="View apps" />+ )}++ {(pendingReview > 0 || alertCount > 0) && (+ <StatButton+ label="REVIEW"+ valueClass={alertCount > 0 ? 'text-orange-400' : 'text-cyan-400'}+ value={`${pendingReview} PENDING${alertCount > 0 ? ` · ${alertCount} ALERT${alertCount === 1 ? '' : 'S'}` : ''}`}+ onClick={() => navigate('/review')}+ title="Open Review Hub"+ />+ )}++ <StatButton+ label="NODES"+ valueClass={onlinePeers > 0 ? 'text-violet-400' : 'text-gray-500'}+ value={`${onlinePeers}/${totalNodes} LINKED`}+ onClick={() => navigate('/instances')}+ title="Open Federation / Instances"+ />++ {notificationCounts?.unread > 0 && (+ <StatButton label="NOTIFS" valueClass="text-cyan-400" value={`${notificationCounts.unread} UNREAD`} onClick={() => navigate('/')} title="Open dashboard alerts" />+ )}++ {productivityData?.todaySucceeded > 0 && (+ <StatButton label="TASKS" valueClass="text-purple-400" value={`${productivityData.todaySucceeded} TODAY`} onClick={() => navigate('/cos')} title="Open Chief of Staff" />+ )}++ {productivityData?.currentDailyStreak > 0 && (+ <StatButton+ label="STREAK"+ valueClass={productivityData.currentDailyStreak >= 3 ? 'text-orange-400' : 'text-gray-400'}+ value={`${productivityData.currentDailyStreak}d`}+ onClick={() => navigate('/cos')}+ title="Open Chief of Staff"+ />+ )}++ {/* Divider */}+ <div className="border-t border-cyan-500/15 mt-1.5 pt-1.5">+ <div className="flex items-center justify-between">+ <span className="font-pixel text-[9px] text-cyan-500/40 tracking-widest">SYS.OK</span>+ <span className="font-pixel text-[9px] text-cyan-500/40 tracking-widest">+ {new Date().toLocaleDateString('en-US', { month: 'short', day: 'numeric' }).toUpperCase()}+ </span>+ </div>+ </div>+ </div>+ );+}diff --git a/client/src/components/city/cityHudBits.jsx b/client/src/components/city/cityHudBits.jsxnew file mode 100644index 0000000000..ecb2065bd1--- /dev/null+++ b/client/src/components/city/cityHudBits.jsx@@ -0,0 +1,68 @@+// Small presentational bits shared by the City HUD panels (desktop cockpit ++// compact/phone disclosure surfaces). Extracted so the vitals rows, health+// sentinel and corner chrome render identically in both layouts instead of being+// copy-pasted per host.++// Animated corner decoration for HUD panels.+export function HudCorner({ position = 'tl', color = 'cyan' }) {+ const corners = {+ tl: 'top-0 left-0 border-t border-l',+ tr: 'top-0 right-0 border-t border-r',+ bl: 'bottom-0 left-0 border-b border-l',+ br: 'bottom-0 right-0 border-b border-r',+ };+ return (+ <div+ className={`absolute w-2 h-2 ${corners[position]} border-${color}-400/60`}+ style={{ borderWidth: '1px' }}+ />+ );+}++export function HealthBar({ value, max, color }) {+ const pct = max > 0 ? (value / max) * 100 : 0;+ return (+ <div className="w-full h-1 bg-gray-800/60 rounded-full overflow-hidden">+ <div+ className="h-full rounded-full transition-all duration-1000"+ style={{ width: `${pct}%`, backgroundColor: color, boxShadow: `0 0 4px ${color}` }}+ />+ </div>+ );+}++// A tappable vitals row (label + value). 44px min height keeps it a valid touch+// target on phone where these rows become the primary controls.+export function StatButton({ label, valueClass, value, onClick, title, prefix = null }) {+ return (+ <button+ type="button"+ onClick={onClick}+ title={title}+ aria-label={title || label}+ className="w-full flex items-center justify-between gap-6 -mx-1 px-1 py-0.5 min-h-[44px] sm:min-h-0 rounded hover:bg-cyan-500/5 transition-colors"+ >+ <span className="font-pixel text-[10px] text-gray-400 tracking-wide">{label}</span>+ <span className={`font-pixel text-[11px] ${valueClass || 'text-cyan-400'}`}>+ {prefix}+ {value}+ </span>+ </button>+ );+}++export const getHealthSentinel = (systemHealth, onlineRatio) => {+ if (systemHealth?.overallHealth === 'critical') return { dot: 'bg-port-error', text: 'text-port-error', label: 'CRITICAL' };+ if (systemHealth?.overallHealth === 'warning') return { dot: 'bg-port-warning', text: 'text-port-warning', label: 'WARN' };+ if (systemHealth?.overallHealth === 'healthy') return { dot: 'bg-port-success', text: 'text-port-success', label: 'OK' };+ if (onlineRatio >= 0.8) return { dot: 'bg-cyan-400', text: 'text-cyan-400', label: 'OK' };+ if (onlineRatio >= 0.5) return { dot: 'bg-port-warning', text: 'text-port-warning', label: 'WARN' };+ return { dot: 'bg-port-error', text: 'text-port-error', label: 'CRIT' };+};++export const metricColor = (pct) => {+ if (pct == null) return 'text-gray-500';+ if (pct >= 90) return 'text-port-error';+ if (pct >= 75) return 'text-port-warning';+ return 'text-cyan-400';+};diff --git a/client/src/components/city/cityPanes.js b/client/src/components/city/cityPanes.jsnew file mode 100644index 0000000000..82d3852405--- /dev/null+++ b/client/src/components/city/cityPanes.js@@ -0,0 +1,32 @@+// Secondary-HUD disclosure surfaces, driven by the `cityPane` URL search param so+// the open surface is deep-linkable, reload-safe, and restored by browser+// back/forward — the same "URL is the source of truth for what's open" convention+// the rest of the app follows. A single param means only ONE surface can be open at+// a time (mutual exclusivity is structural, not enforced by hand). Clearing the+// param returns to the unobstructed 3D scene.+//+// `attention` / `timeline` / `activity` double as the desktop Intel pane's active+// tab, so the same param addresses the Intel tab on the cockpit and the disclosure+// sheet on phone/compact.+export const CITY_PANE_IDS = [+ 'vitals',+ 'attention',+ 'timeline',+ 'activity',+ 'map',+ 'filter',+ 'legend',+];++// The subset that maps to the Intel pane's tabs (shared with the desktop cockpit).+export const CITY_INTEL_PANE_IDS = ['attention', 'timeline', 'activity'];++export const CITY_PANE_LABELS = {+ vitals: 'Vitals',+ attention: 'Attention',+ timeline: 'Timeline',+ activity: 'Activity',+ map: 'Map',+ filter: 'Filter',+ legend: 'Legend',+};diff --git a/client/src/hooks/README.md b/client/src/hooks/README.mdindex 3dc73a2f83..cd0b19edc4 100644--- a/client/src/hooks/README.md+++ b/client/src/hooks/README.md@@ -134,6 +134,7 @@ grep -i "what you want to do" client/src/hooks/README.md| `useCityAudio` | CyberCity ambient audio. | CyberCity only. || `useCityData` | CyberCity environment data + physics. | CyberCity only. || `useCityPlayback` | Timeline-scrubber transport: loads the snapshot series, steps a frame index, play/pause/speed. | CyberCity playback (history) mode only. |+| `useCityViewport` | Classifies the window width into `phone` / `compact` / `desktop` brackets (mirrors Tailwind `sm`/`lg`) so the City HUD can branch between the desktop cockpit and the compact/phone disclosure layout in JS (only one tree mounts). Returns `{ mode, isPhone, isCompact, isDesktop, isCondensed }`. | CyberCity HUD responsive layout only. || `useCitySettings` | CyberCity quality presets + persistence. | CyberCity only. || `useColorMatch` | Drives a song color-match run: counts the singer in with the metronome, walks the notated score in tempo, grades each note against the live mic pitch (#1022 tracker + colorMatch lib), and exposes `{ running, countingIn, noteColors, summary, activeIndex, start, stop }` for the `<ScoreSheet>` + an accuracy readout. Taps the passed recording stream (no second mic); tears down on stop/unmount. | The Song editor's color-match panel. Don't re-wire the metronome + tracker + grading loop by hand. || `useCodeReviewDefaults` | Global Code Review Defaults (Review Loop reviewer chain + per-backend local-LLM model) via a small Provider/hook pair. | TaskAddForm, ScheduleTab, anywhere a default reviewer picker is shown. |diff --git a/client/src/hooks/index.js b/client/src/hooks/index.jsindex ee7eaa1502..ab38a1fb75 100644--- a/client/src/hooks/index.js+++ b/client/src/hooks/index.js@@ -131,6 +131,8 @@ export * from './useAppOverrideActions.js';export * from './useCanonPatch.js';export * from './useCityData.js';export * from './useCityPlayback.js';+export { default as useCityViewport } from './useCityViewport.js';+export * from './useCityViewport.js';export * from './useDeathClock.js';export * from './useGoalDetail.js';export * from './usePostSession.js';diff --git a/client/src/hooks/useCityViewport.js b/client/src/hooks/useCityViewport.jsnew file mode 100644index 0000000000..a4ce861a98--- /dev/null+++ b/client/src/hooks/useCityViewport.js@@ -0,0 +1,43 @@+import { useEffect, useState } from 'react';++// Coordinated responsive breakpoints for the CyberCity HUD. The HUD is a fixed+// overlay on top of a full-bleed 3D scene, so it can't rely on the page's normal+// flow/scroll to reflow — it needs to KNOW the viewport bracket to swap between the+// desktop cockpit and the compact/phone disclosure layout (rendering both trees at+// once would double the always-live timers and stack the panels). We branch in JS+// (not just CSS `lg:hidden`) so only one layout mounts and the branch is testable.+//+// Brackets mirror Tailwind's `sm` (640) and `lg` (1024):+// phone : < 640 essential status + a single disclosure surface+// compact : 640 – 1023 condensed rail + collapsed launchers+// desktop : >= 1024 the full multi-panel cockpit (unchanged)+export const CITY_PHONE_MAX = 639;+export const CITY_COMPACT_MAX = 1023;++export function classifyCityViewport(width) {+ if (width <= CITY_PHONE_MAX) return 'phone';+ if (width <= CITY_COMPACT_MAX) return 'compact';+ return 'desktop';+}++export default function useCityViewport() {+ const [mode, setMode] = useState(() =>+ typeof window === 'undefined' ? 'desktop' : classifyCityViewport(window.innerWidth),+ );++ useEffect(() => {+ const onResize = () => setMode(classifyCityViewport(window.innerWidth));+ onResize(); // sync once in case width changed before the listener attached+ window.addEventListener('resize', onResize);+ return () => window.removeEventListener('resize', onResize);+ }, []);++ return {+ mode,+ isPhone: mode === 'phone',+ isCompact: mode === 'compact',+ isDesktop: mode === 'desktop',+ // convenience: everything that is NOT the desktop cockpit+ isCondensed: mode !== 'desktop',+ };+}diff --git a/client/src/hooks/useCityViewport.test.jsx b/client/src/hooks/useCityViewport.test.jsxnew file mode 100644index 0000000000..3cbd254a06--- /dev/null+++ b/client/src/hooks/useCityViewport.test.jsx@@ -0,0 +1,42 @@+import { describe, it, expect, afterEach } from 'vitest';+import { renderHook, act } from '@testing-library/react';+import useCityViewport, { classifyCityViewport } from './useCityViewport.js';++const setWidth = (w) => { window.innerWidth = w; };++afterEach(() => setWidth(1024));++describe('classifyCityViewport', () => {+ it('classifies phone / compact / desktop at the sm+lg breakpoints', () => {+ expect(classifyCityViewport(390)).toBe('phone');+ expect(classifyCityViewport(639)).toBe('phone');+ expect(classifyCityViewport(640)).toBe('compact');+ expect(classifyCityViewport(1023)).toBe('compact');+ expect(classifyCityViewport(1024)).toBe('desktop');+ expect(classifyCityViewport(1440)).toBe('desktop');+ });+});++describe('useCityViewport', () => {+ it('reports the initial bracket from the current width', () => {+ setWidth(390);+ const { result } = renderHook(() => useCityViewport());+ expect(result.current.mode).toBe('phone');+ expect(result.current.isPhone).toBe(true);+ expect(result.current.isCondensed).toBe(true);+ expect(result.current.isDesktop).toBe(false);+ });++ it('updates on resize across brackets', () => {+ setWidth(1440);+ const { result } = renderHook(() => useCityViewport());+ expect(result.current.isDesktop).toBe(true);++ act(() => { setWidth(800); window.dispatchEvent(new Event('resize')); });+ expect(result.current.isCompact).toBe(true);+ expect(result.current.isCondensed).toBe(true);++ act(() => { setWidth(375); window.dispatchEvent(new Event('resize')); });+ expect(result.current.isPhone).toBe(true);+ });+});diff --git a/client/src/pages/CyberCity.jsx b/client/src/pages/CyberCity.jsxindex fdc40e42c2..e4cc6eecc3 100644--- a/client/src/pages/CyberCity.jsx+++ b/client/src/pages/CyberCity.jsx@@ -13,7 +13,7 @@ import CityScanlines from '../components/city/CityScanlines';import CityPhotoOverlay from '../components/city/CityPhotoOverlay';import CityPlaybackOverlay from '../components/city/CityPlaybackOverlay';import { CitySettingsProvider, useCitySettingsContext } from '../components/city/CitySettingsContext';-import CitySettingsPanel from '../components/city/CitySettingsPanel';+import CitySettingsDrawer from '../components/city/CitySettingsDrawer';import { computeFilterResult } from '../utils/cityFilter';import { DEFAULT_PRESET_ID, cyclePreset } from '../utils/cityPhotoMode';import { computeSoundscape } from '../utils/citySoundscape';@@ -435,7 +435,9 @@ function CyberCityInner() {onExit={playback.exit}/><CityScanlines settings={settings} crt={cityPalette.crt} />- {showSettings && <CitySettingsPanel />}+ {/* Settings on the shared Drawer (issue #2591). Closing preserves other query+ params (e.g. an open cityPane) so the disclosure state survives. */}+ <CitySettingsDrawer open={showSettings} onClose={() => navigate(`/city${location.search}`)} /></div></CityPaletteProvider>);