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]): CyberCity photo mode — cinematic presets + postcard capture
[._.]/ Adam Eivye0976f6ac395
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.mdindex 32e0eda46c..7ba9d2afcd 100644--- a/.changelog/NEXT.md+++ b/.changelog/NEXT.md@@ -47,6 +47,7 @@- **[issue-824] CyberCity easter eggs** — rare hidden emblems now appear in a quiet corner of the city when you hit a special condition — a developer's date, reaching a "leet" or famously-answered level, a palindrome best-streak, or a clean sweep with every goal completed. They're meant to be discovered, not announced, and disappear again when the condition passes.- **[issue-705] CyberCity earned artifacts** — a "Hall of Achievements" now appears east of downtown as a cluster of trophies on glowing pedestals — but only for milestones you've actually earned: leveling up your adventurer, completing life goals (your 1st, 5th, 10th), and building your best task-completion streak (3, 7, 30 days). Each trophy reads bronze, silver, or gold for how big the milestone is, and the whole cluster shimmers; nothing shows until you've earned your first, so the hall fills in as you make progress.- **[issue-705] CyberCity memory district** — your long-term memory now crystallizes into a quiet quarter northwest of downtown: each memory category becomes a cluster of glowing crystals, taller and brighter the more (and more important) the memories it holds, and categories that link to each other arc together with light bridges — so the shape of how your knowledge connects is legible at a glance. A glowing well at the district's heart pulses with your Brain inbox backlog, brightening and beating faster the more captures are waiting to be sorted, and calming once the inbox is clear. The district stays hidden until you've recorded your first memory.+- **[issue-705] CyberCity photo mode** — a new camera button drops the city into a cinematic photo mode: the HUD clears, letterbox bars frame the view, and you can cycle through framing presets (establishing shot, downtown, skyline, overhead, horizon, low angle) with the on-screen arrows or ←/→ keys, each a smooth camera fly. Hit Capture to grab a "city postcard" — your screenshot with a CYBERCITY title and a snapshot of your headline stats (systems online, active agents, linked peers, level, streak) baked along the bottom — then preview it and save it as a PNG. Press Esc to fly back out.## Changeddiff --git a/client/src/components/city/CameraTransition.jsx b/client/src/components/city/CameraTransition.jsxindex caa658af41..89ab302671 100644--- a/client/src/components/city/CameraTransition.jsx+++ b/client/src/components/city/CameraTransition.jsx@@ -1,14 +1,12 @@import { useRef } from 'react';import { useThree, useFrame } from '@react-three/fiber';import * as THREE from 'three';+import { smoothstep } from '../../utils/easing';const ORBITAL_POS = new THREE.Vector3(0, 25, 45);const ORBITAL_TARGET = new THREE.Vector3(0, 0, 0);const DURATION = 0.8;-// Smoothstep easing-const smoothstep = (t) => t * t * (3 - 2 * t);-export default function CameraTransition({ active, targetPos, targetLookAt, onTransitionComplete }) {const { camera } = useThree();const progressRef = useRef(0);diff --git a/client/src/components/city/CityHud.jsx b/client/src/components/city/CityHud.jsxindex 698792fa02..e444eaaecf 100644--- a/client/src/components/city/CityHud.jsx+++ b/client/src/components/city/CityHud.jsx@@ -162,7 +162,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 }) {+export default function CityHud({ cosStatus, cosAgents, agentMap, eventLogs, connected, apps, reviewCounts, instances, productivityData, systemHealth, notificationCounts, character, filter, onFilterChange, onJumpToFirst, matchCount, onToggleExploration, explorationMode, onSelectApp, onEnterPhotoMode }) {const navigate = useNavigate();const location = useLocation();const [time, setTime] = useState(new Date());@@ -486,6 +486,22 @@ export default function CityHud({ cosStatus, cosAgents, agentMap, eventLogs, con<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>+ )}+<buttononClick={() => 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"diff --git a/client/src/components/city/CityPhotoCamera.jsx b/client/src/components/city/CityPhotoCamera.jsxnew file mode 100644index 0000000000..f9d6f0e1cd--- /dev/null+++ b/client/src/components/city/CityPhotoCamera.jsx@@ -0,0 +1,71 @@+import { useRef, useEffect } from 'react';+import { useThree, useFrame } from '@react-three/fiber';+import * as THREE from 'three';+import { getPreset } from '../../utils/cityPhotoMode';+import { smoothstep } from '../../utils/easing';++// Photo-mode camera driver (roadmap 3.3). When photo mode is active this flies the camera to+// the selected cinematic preset with a smooth ease, and registers a capture function with the+// page (via `onReady`) that grabs the current WebGL frame as a PNG data URL. It renders nothing+// itself — it only mutates the shared camera and forces an on-demand render before each capture+// so `preserveDrawingBuffer` has a fresh frame to read. Mirrors CameraTransition's ease/lerp.++const FLY_DURATION = 1.1; // seconds — slower than the exploration transition for a cinematic feel++export default function CityPhotoCamera({ active, presetId, onReady }) {+ const { camera, gl, scene } = useThree();+ const progressRef = useRef(1);+ const startPosRef = useRef(new THREE.Vector3());+ const startTargetRef = useRef(new THREE.Vector3());+ const lastPresetRef = useRef(null);+ const wasActiveRef = useRef(false);++ // Register the capture function with the page. Reading the canvas requires the renderer to+ // have been created with preserveDrawingBuffer:true (set on the Canvas gl prop). We force one+ // synchronous render of the current scene/camera first so the buffer matches what's on screen+ // even when the frameloop is paused ("demand") in photo mode.+ useEffect(() => {+ if (!onReady) return;+ const capture = () => {+ gl.render(scene, camera);+ return gl.domElement.toDataURL('image/png');+ };+ onReady(capture);+ return () => onReady(null);+ }, [onReady, gl, scene, camera]);++ // Begin a fly whenever photo mode turns on or the preset changes.+ const beginFly = () => {+ progressRef.current = 0;+ startPosRef.current.copy(camera.position);+ const dir = new THREE.Vector3(0, 0, -1).applyQuaternion(camera.quaternion);+ startTargetRef.current.copy(camera.position).add(dir.multiplyScalar(10));+ };++ useFrame((_, delta) => {+ if (!active) {+ wasActiveRef.current = false;+ lastPresetRef.current = null;+ return;+ }+ // Detect activation or preset change → start a new fly from the current pose.+ if (!wasActiveRef.current || lastPresetRef.current !== presetId) {+ wasActiveRef.current = true;+ lastPresetRef.current = presetId;+ beginFly();+ }+ if (progressRef.current >= 1) return; // settled — leave the camera where the fly left it++ progressRef.current = Math.min(1, progressRef.current + delta / FLY_DURATION);+ const t = smoothstep(progressRef.current);++ const preset = getPreset(presetId);+ const endPos = new THREE.Vector3(...preset.position);+ const endTarget = new THREE.Vector3(...preset.target);++ camera.position.lerpVectors(startPosRef.current, endPos, t);+ camera.lookAt(new THREE.Vector3().lerpVectors(startTargetRef.current, endTarget, t));+ });++ return null;+}diff --git a/client/src/components/city/CityPhotoOverlay.jsx b/client/src/components/city/CityPhotoOverlay.jsxnew file mode 100644index 0000000000..87a3756bac--- /dev/null+++ b/client/src/components/city/CityPhotoOverlay.jsx@@ -0,0 +1,171 @@+import { useState, useCallback } from 'react';+import { PHOTO_PRESETS, getPreset, cyclePreset, buildPostcardStats, screenshotFilename } from '../../utils/cityPhotoMode';++// Photo-mode HUD overlay (roadmap 3.3). When photo mode is active it dims the rest of the HUD,+// draws cinematic letterbox bars, and offers preset framing controls + a capture button. Capture+// composites the live WebGL frame (grabbed via the page's `captureFn`) onto a postcard with a+// stats caption baked in, then offers it as a PNG download and an in-overlay preview. All the+// non-visual logic (presets, caption lines, filename) lives in the pure cityPhotoMode helper.++// Composite the raw screenshot data URL onto a postcard: the city image with a subtle vignette,+// a CYBERCITY title, and the stats caption along the bottom. Returns a PNG data URL. Runs on a+// 2D canvas so it's independent of the WebGL renderer. Resolves null if the image fails to load.+function composePostcard(dataUrl, statLines) {+ return new Promise((resolve) => {+ const img = new Image();+ img.onload = () => {+ const canvas = document.createElement('canvas');+ canvas.width = img.width;+ canvas.height = img.height;+ const ctx = canvas.getContext('2d');+ if (!ctx) { resolve(null); return; }+ ctx.drawImage(img, 0, 0);++ // Bottom gradient scrim so the caption stays readable over a bright skyline.+ const scrimH = Math.max(110, img.height * 0.18);+ const grad = ctx.createLinearGradient(0, img.height - scrimH, 0, img.height);+ grad.addColorStop(0, 'rgba(0,0,0,0)');+ grad.addColorStop(1, 'rgba(0,0,0,0.82)');+ ctx.fillStyle = grad;+ ctx.fillRect(0, img.height - scrimH, img.width, scrimH);++ const pad = Math.round(img.width * 0.03);+ ctx.textBaseline = 'alphabetic';++ // Title+ ctx.fillStyle = '#06b6d4';+ ctx.font = `bold ${Math.round(img.height * 0.045)}px monospace`;+ ctx.fillText('CYBERCITY', pad, img.height - pad - Math.round(img.height * 0.04));++ // Stats caption — one line, separated by middots, right under the title.+ ctx.fillStyle = '#cbd5e1';+ ctx.font = `${Math.round(img.height * 0.026)}px monospace`;+ ctx.fillText(statLines.join(' · '), pad, img.height - pad);++ resolve(canvas.toDataURL('image/png'));+ };+ img.onerror = () => resolve(null);+ img.src = dataUrl;+ });+}++function PresetControls({ presetId, onCycle }) {+ const preset = getPreset(presetId);+ return (+ <div className="flex items-center gap-3 pointer-events-auto">+ <button+ type="button"+ onClick={() => onCycle(-1)}+ className="font-pixel text-cyan-400 text-lg px-2 hover:text-cyan-300 transition-colors"+ title="Previous shot (←)"+ >‹</button>+ <div className="font-pixel text-[11px] text-cyan-300 tracking-widest w-32 text-center" style={{ textShadow: '0 0 8px rgba(6,182,212,0.5)' }}>+ {preset.label}+ </div>+ <button+ type="button"+ onClick={() => onCycle(1)}+ className="font-pixel text-cyan-400 text-lg px-2 hover:text-cyan-300 transition-colors"+ title="Next shot (→)"+ >›</button>+ </div>+ );+}++export default function CityPhotoOverlay({ active, presetId, onPresetChange, onExit, captureFnRef, statsSnapshot }) {+ const [postcard, setPostcard] = useState(null);+ const [busy, setBusy] = useState(false);++ const handleCycle = useCallback((dir) => {+ onPresetChange(cyclePreset(presetId, dir));+ }, [presetId, onPresetChange]);++ const handleCapture = useCallback(async () => {+ // Read the capture fn from the ref at click time — the in-canvas camera populates it after+ // mount, so reading it now (not at render) guarantees the latest registered grabber.+ const captureFn = captureFnRef?.current;+ if (!captureFn || busy) return;+ setBusy(true);+ // Grab the raw frame, then composite the postcard off the WebGL thread.+ const raw = captureFn();+ const lines = buildPostcardStats(statsSnapshot);+ const card = raw ? await composePostcard(raw, lines) : null;+ setPostcard(card || raw);+ setBusy(false);+ }, [captureFnRef, busy, statsSnapshot]);++ const handleDownload = useCallback(() => {+ if (!postcard) return;+ // A detached anchor click is enough to trigger a data-URL download — no need to mount it.+ const a = document.createElement('a');+ a.href = postcard;+ a.download = screenshotFilename(new Date());+ a.click();+ }, [postcard]);++ if (!active) return null;++ return (+ <>+ {/* Cinematic letterbox bars */}+ <div className="absolute top-0 left-0 right-0 h-[10vh] bg-black pointer-events-none z-20 transition-all" />+ <div className="absolute bottom-0 left-0 right-0 h-[10vh] bg-black pointer-events-none z-20 transition-all" />++ {/* Top bar: title + exit */}+ <div className="absolute top-0 left-0 right-0 h-[10vh] flex items-center justify-between px-6 z-30">+ <div className="font-pixel text-[11px] text-cyan-500/70 tracking-widest pointer-events-none">+ PHOTO MODE+ </div>+ <button+ type="button"+ onClick={onExit}+ className="font-pixel text-[10px] text-cyan-400 tracking-wider border border-cyan-500/40 rounded px-3 py-1.5 hover:bg-cyan-500/10 transition-all pointer-events-auto"+ title="Exit photo mode (Esc)"+ >+ [ EXIT ]+ </button>+ </div>++ {/* Bottom bar: preset cycle + capture */}+ <div className="absolute bottom-0 left-0 right-0 h-[10vh] flex items-center justify-between px-6 z-30">+ <PresetControls presetId={presetId} onCycle={handleCycle} />+ <button+ type="button"+ onClick={handleCapture}+ disabled={busy}+ className="font-pixel text-[11px] text-black bg-cyan-400 tracking-wider rounded px-4 py-2 hover:bg-cyan-300 transition-all pointer-events-auto disabled:opacity-50"+ title="Capture a city postcard"+ >+ {busy ? 'CAPTURING…' : '◉ CAPTURE'}+ </button>+ </div>++ {/* Postcard preview modal */}+ {postcard && (+ <div className="absolute inset-0 z-40 flex items-center justify-center bg-black/70 pointer-events-auto" onClick={() => setPostcard(null)}>+ <div className="max-w-[80vw] max-h-[80vh] flex flex-col items-center gap-3" onClick={(e) => e.stopPropagation()}>+ <img src={postcard} alt="City postcard" className="max-w-full max-h-[68vh] rounded-lg border border-cyan-500/40 shadow-[0_0_30px_rgba(6,182,212,0.3)]" />+ <div className="flex gap-3">+ <button+ type="button"+ onClick={handleDownload}+ className="font-pixel text-[11px] text-black bg-cyan-400 tracking-wider rounded px-4 py-2 hover:bg-cyan-300 transition-all"+ >+ ↓ SAVE POSTCARD+ </button>+ <button+ type="button"+ onClick={() => setPostcard(null)}+ className="font-pixel text-[11px] text-cyan-400 tracking-wider border border-cyan-500/40 rounded px-4 py-2 hover:bg-cyan-500/10 transition-all"+ >+ CLOSE+ </button>+ </div>+ </div>+ </div>+ )}+ </>+ );+}++export { PHOTO_PRESETS };diff --git a/client/src/components/city/CityScene.jsx b/client/src/components/city/CityScene.jsxindex ee5a1ab9b9..11a1e6271a 100644--- a/client/src/components/city/CityScene.jsx+++ b/client/src/components/city/CityScene.jsx@@ -38,8 +38,9 @@ import CitySky from './CitySky';import CityEnergyOverlay from './CityEnergyOverlay';import PlayerController from './PlayerController';import CameraTransition from './CameraTransition';+import CityPhotoCamera from './CityPhotoCamera';-export default function CityScene({ apps, agentMap, onBuildingClick, cosStatus, reviewCounts, instances, backupStatus, cosTasks, healthMetrics, voiceState, aiActivity, productivityData, activityCalendar, goals, character, chronotype, memoryGraph, inboxDepth, settings, playSfx, keysRef, dimmedAppIds }) {+export default function CityScene({ apps, agentMap, onBuildingClick, cosStatus, reviewCounts, instances, backupStatus, cosTasks, healthMetrics, voiceState, aiActivity, productivityData, activityCalendar, goals, character, chronotype, memoryGraph, inboxDepth, photoMode, photoPresetId, onPhotoCaptureReady, settings, playSfx, keysRef, dimmedAppIds }) {const [positions, setPositions] = useState(null);const [proximityApp, setProximityApp] = useState(null);const [transitioning, setTransitioning] = useState(false);@@ -78,7 +79,11 @@ export default function CityScene({ apps, agentMap, onBuildingClick, cosStatus,dpr={dpr}shadows={false}style={{ background: '#030308', cursor: explorationMode ? 'crosshair' : 'auto' }}- gl={{ antialias: true }}+ // preserveDrawingBuffer lets photo mode read the frame back via toDataURL. It's a+ // WebGL context-creation attribute, so it can't be toggled at runtime without recreating+ // the renderer (which would flash the scene) — we accept it always-on. The cost on modern+ // GPUs is a small per-frame copy; negligible against this scene's particle/bloom load.+ gl={{ antialias: true, preserveDrawingBuffer: true }}><CitySky settings={settings} /><CityClouds settings={settings} />@@ -142,7 +147,7 @@ export default function CityScene({ apps, agentMap, onBuildingClick, cosStatus,active={explorationMode}/>)}- {!explorationMode && !transitioning && (+ {!explorationMode && !transitioning && !photoMode && (<OrbitControlsmaxPolarAngle={Math.PI / 2.2}minDistance={5}@@ -155,6 +160,7 @@ export default function CityScene({ apps, agentMap, onBuildingClick, cosStatus,active={explorationMode}onTransitionComplete={handleTransitionComplete}/>+ <CityPhotoCamera active={photoMode} presetId={photoPresetId} onReady={onPhotoCaptureReady} /></Canvas>);}diff --git a/client/src/pages/CyberCity.jsx b/client/src/pages/CyberCity.jsxindex ded1112d0e..e8e53b8c1d 100644--- a/client/src/pages/CyberCity.jsx+++ b/client/src/pages/CyberCity.jsx@@ -1,4 +1,4 @@-import { useCallback, useState, useEffect, useMemo } from 'react';+import { useCallback, useState, useEffect, useMemo, useRef } from 'react';import { useNavigate, useLocation } from 'react-router-dom';import { useCityData } from '../hooks/useCityData';import useCityAudio from '../hooks/useCityAudio';@@ -8,9 +8,11 @@ import * as api from '../services/api';import CityScene from '../components/city/CityScene';import CityHud from '../components/city/CityHud';import CityScanlines from '../components/city/CityScanlines';+import CityPhotoOverlay from '../components/city/CityPhotoOverlay';import { CitySettingsProvider, useCitySettingsContext } from '../components/city/CitySettingsContext';import CitySettingsPanel from '../components/city/CitySettingsPanel';import { computeFilterResult } from '../utils/cityFilter';+import { DEFAULT_PRESET_ID, cyclePreset } from '../utils/cityPhotoMode';function CyberCityInner() {const { apps, cosAgents, cosStatus, eventLogs, agentMap, reviewCounts, instances, systemHealth, notificationCounts, backupStatus, cosTasks, healthMetrics, voiceState, character, aiActivity, loading, connected } = useCityData();@@ -61,6 +63,37 @@ function CyberCityInner() {const keysRef = useKeyboardControls(handleToggleExploration);+ // Photo mode (roadmap 3.3): a cinematic capture mode with framing presets and a postcard+ // screenshot. The in-canvas CityPhotoCamera registers its capture function here via a ref so+ // the overlay (outside the Canvas) can trigger a grab. Exiting photo mode clears the fn.+ const [photoMode, setPhotoMode] = useState(false);+ const [photoPresetId, setPhotoPresetId] = useState(DEFAULT_PRESET_ID);+ const captureFnRef = useRef(null);+ const handlePhotoCaptureReady = useCallback((fn) => { captureFnRef.current = fn; }, []);++ // Entering photo mode leaves exploration; they're mutually exclusive camera modes.+ const enterPhotoMode = useCallback(() => {+ updateSetting('explorationMode', false);+ setPhotoPresetId(DEFAULT_PRESET_ID);+ setPhotoMode(true);+ }, [updateSetting]);+ const exitPhotoMode = useCallback(() => setPhotoMode(false), []);++ // Esc exits photo mode; ←/→ cycle the framing preset. Bound only while photo mode is on so it+ // doesn't shadow other shortcuts. Ignores key events while typing in an input.+ useEffect(() => {+ if (!photoMode) return;+ const onKey = (e) => {+ const tag = e.target?.tagName;+ if (tag === 'INPUT' || tag === 'TEXTAREA') return;+ if (e.key === 'Escape') setPhotoMode(false);+ else if (e.key === 'ArrowLeft') setPhotoPresetId(id => cyclePreset(id, -1));+ else if (e.key === 'ArrowRight') setPhotoPresetId(id => cyclePreset(id, 1));+ };+ window.addEventListener('keydown', onKey);+ return () => window.removeEventListener('keydown', onKey);+ }, [photoMode]);+// Productivity data for HUD vitals and billboards. Let errors throw —// `useAutoRefetch` preserves the last-good snapshot on transient failures.const { data: productivityData } = useAutoRefetch(@@ -119,6 +152,20 @@ function CyberCityInner() {if (first?.id) navigate(`/apps/${first.id}`);}, [filterResult.matches, navigate]);+ // Headline numbers baked onto a captured city postcard. Derived from data the page already+ // has — no extra fetch. buildPostcardStats (in the overlay) omits absent/zero fields.+ const photoStats = useMemo(() => {+ const active = (apps || []).filter(a => !a.archived);+ return {+ online: active.filter(a => a.overallStatus === 'online').length,+ total: active.length,+ agents: (cosAgents || []).filter(a => a.status === 'running' || a.state === 'coding' || a.state === 'thinking').length,+ peers: (instances?.peers || []).filter(p => p.status === 'online').length,+ level: character?.level,+ streak: productivityData?.currentStreak ?? productivityData?.streak,+ };+ }, [apps, cosAgents, instances, character, productivityData]);+if (loading) {return (<div className="flex flex-col items-center justify-center h-full gap-4" style={{ background: '#030308' }}>@@ -156,31 +203,46 @@ function CyberCityInner() {chronotype={chronotypeData}memoryGraph={memoryGraph}inboxDepth={inboxData?.counts?.needs_review ?? 0}+ photoMode={photoMode}+ photoPresetId={photoPresetId}+ onPhotoCaptureReady={handlePhotoCaptureReady}settings={settings}playSfx={playSfx}keysRef={keysRef}dimmedAppIds={filterResult.dimmed}/>- <CityHud- cosStatus={cosStatus}- cosAgents={cosAgents}- agentMap={agentMap}- eventLogs={eventLogs}- connected={connected}- apps={apps}- reviewCounts={reviewCounts}- instances={instances}- productivityData={productivityData}- systemHealth={systemHealth}- notificationCounts={notificationCounts}- character={character}- filter={filter}- onFilterChange={setFilter}- onJumpToFirst={handleJumpToFirst}- matchCount={filterResult.matches.length}- onToggleExploration={handleToggleExploration}- explorationMode={settings?.explorationMode}- onSelectApp={handleBuildingClick}+ {/* The full HUD hides in photo mode so captures are clean; the photo overlay replaces it. */}+ {!photoMode && (+ <CityHud+ cosStatus={cosStatus}+ cosAgents={cosAgents}+ agentMap={agentMap}+ eventLogs={eventLogs}+ connected={connected}+ apps={apps}+ reviewCounts={reviewCounts}+ instances={instances}+ productivityData={productivityData}+ systemHealth={systemHealth}+ notificationCounts={notificationCounts}+ character={character}+ filter={filter}+ onFilterChange={setFilter}+ onJumpToFirst={handleJumpToFirst}+ matchCount={filterResult.matches.length}+ onToggleExploration={handleToggleExploration}+ explorationMode={settings?.explorationMode}+ onSelectApp={handleBuildingClick}+ onEnterPhotoMode={enterPhotoMode}+ />+ )}+ <CityPhotoOverlay+ active={photoMode}+ presetId={photoPresetId}+ onPresetChange={setPhotoPresetId}+ onExit={exitPhotoMode}+ captureFnRef={captureFnRef}+ statsSnapshot={photoStats}/><CityScanlines settings={settings} />{showSettings && <CitySettingsPanel />}diff --git a/client/src/utils/cityPhotoMode.js b/client/src/utils/cityPhotoMode.jsnew file mode 100644index 0000000000..8ab25b7a31--- /dev/null+++ b/client/src/utils/cityPhotoMode.js@@ -0,0 +1,65 @@+// Pure, deterministic helpers for CyberCity's photo mode (roadmap 3.3): cinematic camera+// presets, the "city postcard" stats overlay, and screenshot filename generation. No three.js+// / React imports so it's unit-testable (mirrors the other city helpers). The component reads+// these presets to fly the camera and composites the postcard caption from a live stats+// snapshot the page passes in.++// Cinematic camera presets. Each is a stable framing of the city — position + look-at target —+// the photo UI cycles through. Tuned against the default orbital view (camera at [0,25,45]+// looking at origin) and the ±60-unit landmark ring, so every preset keeps downtown and at+// least one landmark district in frame.+export const PHOTO_PRESETS = [+ { id: 'establishing', label: 'ESTABLISHING', position: [0, 28, 52], target: [0, 2, 0] },+ { id: 'downtown', label: 'DOWNTOWN', position: [0, 10, 26], target: [0, 4, 0] },+ { id: 'skyline', label: 'SKYLINE', position: [44, 6, 44], target: [-6, 8, -6] },+ { id: 'overhead', label: 'OVERHEAD', position: [0, 70, 0.01], target: [0, 0, 0] },+ { id: 'horizon', label: 'HORIZON', position: [0, 4, 60], target: [0, 10, -60] },+ { id: 'low-angle', label: 'LOW ANGLE', position: [-18, 2, 30], target: [0, 12, 0] },+];++export const DEFAULT_PRESET_ID = 'establishing';++// Resolve a preset by id, falling back to the default establishing shot for an unknown id so a+// stale persisted id can never strand the camera with no framing.+export function getPreset(id) {+ return PHOTO_PRESETS.find(p => p.id === id) || PHOTO_PRESETS.find(p => p.id === DEFAULT_PRESET_ID);+}++// Step to the next/previous preset in the ring (wraps). Used by the ‹ › controls and arrow keys.+export function cyclePreset(currentId, direction = 1) {+ const idx = PHOTO_PRESETS.findIndex(p => p.id === currentId);+ const base = idx === -1 ? 0 : idx;+ const next = (base + direction + PHOTO_PRESETS.length) % PHOTO_PRESETS.length;+ return PHOTO_PRESETS[next].id;+}++// Build the short stat lines printed on a "city postcard". Pulls a handful of headline numbers+// from a stats snapshot the page already has (apps, agents, peers, level). Missing fields are+// omitted rather than rendered as "0/undefined", so a sparse install still prints a clean card.+export function buildPostcardStats(snapshot = {}) {+ const lines = [];+ const { online, total, agents, peers, level, streak } = snapshot;+ if (Number.isFinite(total)) lines.push(`${online ?? 0}/${total} SYSTEMS ONLINE`);+ if (Number.isFinite(agents) && agents > 0) lines.push(`${agents} AGENT${agents === 1 ? '' : 'S'} ACTIVE`);+ if (Number.isFinite(peers) && peers > 0) lines.push(`${peers} PEER${peers === 1 ? '' : 'S'} LINKED`);+ if (Number.isFinite(level)) lines.push(`LEVEL ${level}`);+ if (Number.isFinite(streak) && streak > 0) lines.push(`${streak}-DAY STREAK`);+ return lines;+}++// Pad a number to two digits without Date formatting (Date.now is unavailable in some contexts;+// the timestamp is always passed in from the caller).+const pad2 = (n) => String(n).padStart(2, '0');++// Build a stable, filesystem-safe screenshot filename from a Date. Format:+// `cybercity-YYYYMMDD-HHMMSS.png`. The Date is injected so the function is deterministic in+// tests and the caller controls the clock.+export function screenshotFilename(date = new Date()) {+ const y = date.getFullYear();+ const m = pad2(date.getMonth() + 1);+ const d = pad2(date.getDate());+ const hh = pad2(date.getHours());+ const mm = pad2(date.getMinutes());+ const ss = pad2(date.getSeconds());+ return `cybercity-${y}${m}${d}-${hh}${mm}${ss}.png`;+}diff --git a/client/src/utils/cityPhotoMode.test.js b/client/src/utils/cityPhotoMode.test.jsnew file mode 100644index 0000000000..6932b73989--- /dev/null+++ b/client/src/utils/cityPhotoMode.test.js@@ -0,0 +1,88 @@+import { describe, it, expect } from 'vitest';+import {+ PHOTO_PRESETS,+ DEFAULT_PRESET_ID,+ getPreset,+ cyclePreset,+ buildPostcardStats,+ screenshotFilename,+} from './cityPhotoMode';++describe('PHOTO_PRESETS', () => {+ it('has unique ids and a position + target each', () => {+ const ids = PHOTO_PRESETS.map(p => p.id);+ expect(new Set(ids).size).toBe(ids.length);+ for (const p of PHOTO_PRESETS) {+ expect(p.position).toHaveLength(3);+ expect(p.target).toHaveLength(3);+ expect(typeof p.label).toBe('string');+ }+ });+ it('includes the default preset id', () => {+ expect(PHOTO_PRESETS.some(p => p.id === DEFAULT_PRESET_ID)).toBe(true);+ });+});++describe('getPreset', () => {+ it('resolves a known id', () => {+ expect(getPreset('downtown').id).toBe('downtown');+ });+ it('falls back to the default for an unknown id', () => {+ expect(getPreset('nope').id).toBe(DEFAULT_PRESET_ID);+ expect(getPreset(undefined).id).toBe(DEFAULT_PRESET_ID);+ });+});++describe('cyclePreset', () => {+ it('advances forward and wraps', () => {+ const first = PHOTO_PRESETS[0].id;+ const last = PHOTO_PRESETS[PHOTO_PRESETS.length - 1].id;+ expect(cyclePreset(last, 1)).toBe(first);+ });+ it('advances backward and wraps', () => {+ const first = PHOTO_PRESETS[0].id;+ const last = PHOTO_PRESETS[PHOTO_PRESETS.length - 1].id;+ expect(cyclePreset(first, -1)).toBe(last);+ });+ it('treats an unknown current id as the first preset', () => {+ expect(cyclePreset('bogus', 1)).toBe(PHOTO_PRESETS[1].id);+ });+});++describe('buildPostcardStats', () => {+ it('renders the headline lines that have data', () => {+ const lines = buildPostcardStats({ online: 3, total: 5, agents: 2, peers: 1, level: 7, streak: 4 });+ expect(lines).toContain('3/5 SYSTEMS ONLINE');+ expect(lines).toContain('2 AGENTS ACTIVE');+ expect(lines).toContain('1 PEER LINKED');+ expect(lines).toContain('LEVEL 7');+ expect(lines).toContain('4-DAY STREAK');+ });+ it('omits zero/absent fields rather than printing 0', () => {+ const lines = buildPostcardStats({ online: 0, total: 2, agents: 0, peers: 0 });+ expect(lines).toEqual(['0/2 SYSTEMS ONLINE']);+ });+ it('singularizes agent/peer counts of one', () => {+ const lines = buildPostcardStats({ agents: 1, peers: 1, total: 1, online: 1 });+ expect(lines).toContain('1 AGENT ACTIVE');+ expect(lines).toContain('1 PEER LINKED');+ });+ it('handles an empty snapshot', () => {+ expect(buildPostcardStats()).toEqual([]);+ expect(buildPostcardStats({})).toEqual([]);+ });+ it('renders level 0', () => {+ expect(buildPostcardStats({ level: 0 })).toContain('LEVEL 0');+ });+});++describe('screenshotFilename', () => {+ it('formats a zero-padded timestamped name', () => {+ const d = new Date(2026, 5, 3, 9, 7, 5); // 2026-06-03 09:07:05 (month is 0-based)+ expect(screenshotFilename(d)).toBe('cybercity-20260603-090705.png');+ });+ it('is deterministic for the same date', () => {+ const d = new Date(2026, 0, 1, 0, 0, 0);+ expect(screenshotFilename(d)).toBe(screenshotFilename(d));+ });+});diff --git a/client/src/utils/easing.js b/client/src/utils/easing.jsnew file mode 100644index 0000000000..309f946eb2--- /dev/null+++ b/client/src/utils/easing.js@@ -0,0 +1,5 @@+// Shared easing functions for camera/animation interpolation. Pure math, no deps — safe to use+// from inside useFrame loops. Extend here rather than re-defining easings inline per component.++// Classic Hermite smoothstep: eases in and out, t clamped to [0,1] by the caller.+export const smoothstep = (t) => t * t * (3 - 2 * t);