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
Plan — CyberCity timeline scrubber (playback mode) — issue #967
Context
Follow-up to #877. The snapshot-capture pipeline shipped (PR #966): the City records a
compact state frame every ~5 min to a rolling capped store, readable via
GET /api/city/snapshots. This issue is the scrubber slice — the 3D HUD that replays
that history: a playback mode on /city where dragging a timeline drives the scene from a
past frame instead of live data, with buildings appearing/disappearing via construction/
teardown animations and recoloring on status change (roadmap 3.6).
Scope decided with the user:
- Landmark data: playback drives everything the snapshot can feed (buildings, agent assignments, counts/HUD, health tower, backup vault, task queue, federation, character). Landmarks the snapshot can't feed (memory district, goal monuments, jira, activity heatmap, productivity) keep their live data, visually static during scrub — the scrubber HUD notes which readouts are time-accurate vs. live.
- Animations: buildings scale-in from 0 on appear (construction), scale-out to 0 on disappear (teardown), and recolor with a brief transition on status change.
- Control: full transport — draggable timeline, play/pause, speed (1×/2×/4×), ←/→ step, Esc exit. Mirrors the existing photo-mode overlay pattern.
This completes roadmap 3.6 and closes #967.
Approach
Mirror the photoMode structure in CyberCity.jsx (an established "special mode" with a
toggle, keyboard handling, and an overlay rendered alongside CityHud). In playback mode the
page substitutes a derived snapshot frame for the live props it passes to CityScene,
leaving the live data hook untouched. Buildings gain a small scale-animation layer keyed off a
per-app transition signal. The snapshot series is fetched once via a new client API wrapper.
New files
client/src/services/apiCity.js— wrappers over the shipped endpoints:getCitySnapshots({ since, limit, silent })→GET /api/city/snapshots,getCitySnapshotConfig(opts)→GET /api/city/snapshots/config,captureCitySnapshot(opts)→POST /api/city/snapshots/capture. Use therequest()helper fromapiCore.jswith anoptionsparam (silent-capable), per the services convention. Maintenance rule: re-export fromclient/src/services/api.jsbarrel + add a row toclient/src/services/README.md(enforced by the services barrel test).client/src/hooks/useCityPlayback.js— owns playback state + transport, soCyberCity.jsxstays lean. Returns{ active, enter, exit, snapshots, frameIndex, currentFrame, setFrameIndex, playing, togglePlay, speed, cycleSpeed, loading, frameTimestamps }. Fetches the series onenter()viaapiCity.getCitySnapshots({ limit: <cap> })(reuseuseAutoRefetchfor the fetch + last-good semantics, or a one-shot fetch inenter). Auto-advance uses asetIntervaldriven byspeed, guarded by amountedRef+ cleared on pause/exit/unmount (per CLAUDE.md deferred-work rule).useCityPlayback.js→ barrel + README row inclient/src/hooks/(enforced).client/src/lib/cityPlaybackFrame.js— pure helpermergeFrameIntoCityProps(frame, live)that maps a snapshot frame onto the prop shapeCitySceneconsumes:apps: take eachframe.apps[]{id,name,status}, look up the live app by id to recover render-only fields (processes,repoPath,type,archived), and overrideoverallStatuswith the frame's status. Apps absent from the frame are dropped (they'll teardown-animate out); apps present in the frame but not live render from the compact fields with sane defaults. Honorframe.apps === null(source failed) → fall back to liveapps, not an empty city.agentMap: rebuild fromframe.assignments[]({agentId, appId, status}) asMap<appId, { app, agents: [{agentId, status}] }>.nullassignments → empty map.cosStatus/backupStatus/counts-derived HUD values/character/health: map fromframe.cos,frame.backup,frame.counts,frame.character,frame.health. Anullfield means "unavailable at capture" → passnull/omit so the component shows its empty state, never a fabricated zero.- Returns ONLY the snapshot-backed props; the page spreads these over the live ones, so unfed landmark props (memoryGraph, goals, jira, activityCalendar, productivityData) pass through live untouched (the "freeze at live" decision).
- Pure + unit-tested →
client/src/lib/barrel + README row (enforced).
client/src/components/city/CityPlaybackOverlay.jsx— the transport HUD, mirroringCityPhotoOverlay.jsx's bottom control bar. A bottom strip with: play/pause button, speed cycle (1×/2×/4×), a range-input timeline slider bound toframeIndex, ←/→ step buttons, the current frame's timestamp (formatDateTime) +timeAgo, a small legend noting which readouts are historical vs. live (frozen), and an[ EXIT ]button. Uses the samefont-pixel/ cyan token styling.activeprop gates render (like the photo overlay).
Modified files
client/src/pages/CyberCity.jsx— add playback alongside photoMode:const playback = useCityPlayback();- Compute the scene props once: when
playback.active && playback.currentFrame, derivemergeFrameIntoCityProps(currentFrame, liveProps)and spread over the live values passed toCityScene; otherwise pass live as today. Pass aplaybackFrame/transitionSignalso the scene/buildings can animate (see below). - Render
{!photoMode && !playback.active && <CityHud … onEnterPlayback={playback.enter} />}and<CityPlaybackOverlay active={playback.active} … />next toCityPhotoOverlay. - Keyboard handler mirroring photo mode (Esc exit, Space play/pause, ←/→ step) bound only
while
playback.active, ignoring INPUT/TEXTAREA. - Photo mode and playback are mutually exclusive (entering one exits the other).
client/src/components/city/CityHud.jsx— add an entry button in the existing bottom-left control stack (next to the photo-mode button),onEnterPlaybackprop, e.g. "⟲ HISTORY". Gate it out when no snapshots exist yet (optional: always show; overlay shows an empty-state).client/src/components/city/Building.jsx— add the construction/teardown + recolor animation layer on the existing outer<group>(it already runs auseFrame):- Track a
mountScaleRefthat lerpsgroup.scale0→1 on mount (construction) using the existing clock-drivenuseFrame(damp toward target). This makes any newly-appearing building rise in during scrub, with no per-frame React churn. - Teardown: a building leaving the
appsarray unmounts immediately in React today. To animate out, the cluster must keep it mounted briefly — handle teardown inBuildingCluster.jsx(below) by retaining "exiting" apps for one animation beat with atransitionState: 'exiting'prop;Buildinglerps scale→0 then signals removal. - Status recolor:
getBuildingColoris currently computed once; lerp the body/edge material color toward the new status color whenapp.overallStatuschanges (damp inuseFrame), rather than snapping. Keep it cheap — reuseTHREE.MathUtils.damp/Color.lerp.
- Track a
client/src/components/city/BuildingCluster.jsx— own the enter/exit lifecycle so teardown can animate: track previous app id set; when an app id disappears between frames, keep rendering itsBoroughwithtransitionState='exiting'for one beat (a short timer or anonExitedcallback fromBuilding), then drop it. New ids render withtransitionState='entering'. This is the only place that needs the diff;Boroughjust forwards the flag toBuilding. Keep keyed byapp.idso React reuse still holds.
Reuse (don't re-implement)
request(client/src/services/apiCore.js) — API wrappers;{ silent: true }to suppress toasts.useAutoRefetch(client/src/hooks/useAutoRefetch.js) — series fetch with last-good semantics.formatDateTime/formatClockTime/timeAgo(client/src/utils/formatters.js) — timeline labels.- Photo-mode structure in
CyberCity.jsx+CityPhotoOverlay.jsx— the overlay/keyboard template. cityDayMix,getBuildingColor,getBuildingHeight,getAccentColor(cityConstants.js) — reuse for recolor lerp targets.- The
dimmed/isProximityper-app prop-forwarding path (BuildingCluster→Borough→Building) — the exact seam for the newtransitionStateprop.
Animation strategy note (kept contained)
All animation rides the existing useFrame clock loop in Building.jsx — no new
animation library, no React re-render per frame. Scrubbing changes the apps array (React
diff handles enter/recolor); teardown is the one case needing a retain-for-one-beat in the
cluster. Scene stays on frameloop='always' so the slider feels live (photo mode's 'demand'
freeze does NOT apply here).
Migration / compat / changelog obligations
- No NAV_COMMANDS entry — playback lives inside the existing
/cityroute (no new page), per the issue. (Confirmed: photo mode added none either.) - No server change, no migration — read-only consumer of the shipped
GET /api/city/snapshots. HonorschemaVersionon each frame: ifframe.schemaVersion !== SNAPSHOT_SCHEMA_VERSION, skip/ flag that frame in the overlay rather than mis-rendering (forward-compat for a future bump). - Barrel + README — every new
apiCity.js/useCityPlayback.js/cityPlaybackFrame.jsgets its barrel re-export + README row (server/client barrel tests enforce this; boot/test fails loudly otherwise). - Changelog — one user-facing entry under
[issue-967]in.changelog/NEXT.md.
Verification
- Unit tests:
client/src/lib/cityPlaybackFrame.test.js— frame→props mapping: status override, agentMap rebuild from assignments,null-field fallthrough (failed source → live, not fabricated 0), apps added/removed between frames,schemaVersionmismatch handling.client/src/services/api.test.*/ hooks test — apiCity wrappers hit the right paths withsince/limit;useCityPlaybacktransport (enter loads series, step clamps at ends, play advances + pauses, exit clears the timer).
- Suite:
cd client && npm test(Vitest/jsdom) green;cd server && npm teststill green (no server change, but the barrel/README enforcement tests run there too — confirm clean).npm run build --prefix clientsucceeds (lint + bundle). - Manual end-to-end: start the app, open
/city, click "⟲ HISTORY". Confirm: the slider scrubs through frames; buildings appear/teardown and recolor as status changes between frames; play/pause auto-advances at the selected speed; ←/→ step; Esc exits back to live; frozen landmarks are labeled as live. Seed history quickly by loweringintervalMinutes(orPOST /api/city/snapshots/capturea few times) so there are several frames to scrub. - Review:
/simplify, then the claude+codex dual-review loop (per the--review-withflag), converge to mutual CLEAN before merge.