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-2930]): promote Sprites to a top-level page and give assets a real inspector
[._.]/ Adam Eivyfb78b689a19e
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.mdindex c5ab01fb35..b748ce21de 100644--- a/.changelog/NEXT.md+++ b/.changelog/NEXT.md@@ -7,6 +7,7 @@## Sprite Manager+- **[issue-2930] Sprites is now its own page, and assets are properly inspectable** — the Sprite Manager was a hidden tab inside Media Gen; it now has its own **Sprites** entry in the Create sidebar and lives at its own address, so it's directly linkable, bookmarkable, and reachable from ⌘K and voice. Old Media Gen sprite links (including links to a specific sprite) redirect to the new page and keep any deep-link state. Every surface that shows a transparent sprite — asset thumbnails, the reference set, walk-loop previews, trim results, and the compiled atlas — now paints a checkerboard behind the artwork, so a cut-out region is finally distinguishable from a black pixel instead of both reading as the same dark rectangle. Clicking any asset opens a real inspector: a pixel-perfect preview over that checkerboard, plus the file's path, dimensions, format, frame count, size, and last-modified time, with Download and Copy-path buttons. Non-image files (manifests, sidecars) open there too instead of silently downloading. An asset PortOS can't read — a truncated PNG, say — now shows its basic details rather than breaking the whole page.- **[issue-2924] Animate walk directions approved from an imported redraw cycle** — a direction whose approved artwork came from the source pipeline's video-first *redraw* path (rather than a Grok walk clip) showed its "approved ✓" badge with a blank space where the loop preview should be, because there was no walk-run record behind it to render. Those directions now animate from their own packaged cycle: PortOS reads the redraw manifest, prefers its clean transparent strip (falling back to the keyed one), and plays the loop at the cycle's real length and frame rate. The viewer no longer assumes every walk strip is exactly 8 frames, so a 12-frame imported stride plays its full gait instead of being cropped to two thirds; native 8-phase runs are unchanged. A direction whose strip is missing on disk still shows nothing rather than a broken image.- **[issue-2898] Compile the runtime atlas and publish it to your game (phase 4)** — a finalized walk set can now be compiled into the immutable runtime sprite-sheet (the 10×8 grid of idle, the 8 named gait phases, and a scanner placeholder for all 8 directions, each frame scaled once per direction and pinned to the pivot ground line) and published straight into a managed app's repository. Every compile revalidates the whole evidence chain first — the finalized walk set, every packaged frame, and every locked anchor are checksum-verified — and recompiling the same set is a no-op instead of a new version. Publishing binds a character to a managed app and a repo-relative destination, replaces the atlas atomically, and refuses to clobber a destination that changed outside PortOS since the last publish; an optional code-binding guard verifies (occurrence-counted) that the game source still references the atlas where expected before anything is written. The Sprites tab gains the compile/publish panel with an inline confirmation and a publish history, and sprite walk-run raw frame intermediates are now excluded from backups by default (they regenerate deterministically from the archived source video — the toggle to re-include them is in the Backup tab).- **[issue-2897] Animate walk cycles from locked anchors (phase 3)** — each locked directional anchor can now be animated: PortOS asks Grok for exactly one walk-in-place video on the character's key-color matte, then packages it locally and deterministically — no further AI involved — into the canonical 8-phase walk strip (frame extraction, chroma un-key and de-spill keyed to the character's selected key color, automatic walk-cycle detection, fixed-scale pivot alignment, and a light/dark/checker contrast review sheet). Review each direction's loop right in the Sprites tab (animated preview), optionally trim frames non-destructively into a versioned loop GIF, and approve per direction; the eighth approval freezes the finalized walk set, which becomes immutable like the reference set. Every run carries a full provenance manifest with per-frame checksums, matching the format the phase-1 importer already understands.diff --git a/client/src/App.jsx b/client/src/App.jsxindex 448f521451..265cd7083c 100644--- a/client/src/App.jsx+++ b/client/src/App.jsx@@ -175,6 +175,17 @@ function CreativeDirectorLegacyRedirect() {return <Navigate to={`/creative-director${rest}${search}${hash}`} replace />;}+// Sprite Manager moved from the Media Gen tab shell to the top-level /sprites+// route (Create sidebar link). Rebases a legacy /media/sprites/:id URL onto it,+// preserving the id, query string, and hash so bookmarks and media-job+// completion deep-links keep resolving. (The bare /media/sprites index needs no+// id rebase and uses RedirectWithSearch.)+function SpritesLegacyRedirect() {+ const { pathname, search, hash } = useLocation();+ const rest = pathname.replace(/^\/media\/sprites/, '');+ return <Navigate to={`/sprites${rest}${search}${hash}`} replace />;+}+// Normalize a tab-less /creative-director/:id URL to its overview tab while// preserving any query string + hash. A bare `<Navigate to="overview">` would// drop them; building the relative target from useLocation keeps deep-link@@ -327,8 +338,11 @@ export default function App() {<Route path="creative-director/:id/:tab" element={<CreativeDirectorLegacyRedirect />} /><Route path="music-video" element={<MusicVideo />} /><Route path="music-video/:projectId" element={<MusicVideo />} />- <Route path="sprites" element={<Sprites />} />- <Route path="sprites/:id" element={<Sprites />} />+ {/* Sprites live at /sprites (Create sidebar link). These redirects+ keep legacy /media/sprites bookmarks working after the MediaGen+ tab was removed. */}+ <Route path="sprites" element={<RedirectWithSearch to="/sprites" />} />+ <Route path="sprites/:id" element={<SpritesLegacyRedirect />} /><Route path="timeline" element={<VideoTimeline />} /><Route path="timeline/:projectId" element={<VideoTimelineEditor />} /><Route path="models" element={<MediaModels />} />@@ -347,6 +361,11 @@ export default function App() {carrying any query string + hash (relative Navigate preserves the:id in the path) so a deep-link like /creative-director/abc?x#ylands on /creative-director/abc/overview?x#y intact. */}+ {/* Sprite Manager — a top-level Create page (moved out of the Media+ Gen tabs). The record id is the URL, per the ID-based deep-linking+ convention. */}+ <Route path="sprites" element={<Sprites />} />+ <Route path="sprites/:id" element={<Sprites />} /><Route path="creative-director" element={<CreativeDirector />} /><Route path="creative-director/:id" element={<CreativeDirectorOverviewRedirect />} /><Route path="creative-director/:id/:tab" element={<CreativeDirectorDetail />} />diff --git a/client/src/components/Layout.jsx b/client/src/components/Layout.jsxindex 9b3e7debf2..57765aa2f6 100644--- a/client/src/components/Layout.jsx+++ b/client/src/components/Layout.jsx@@ -92,7 +92,8 @@ import {Music,Workflow as WorkflowIcon,ChartGantt,- Clapperboard+ Clapperboard,+ PersonStanding} from 'lucide-react';/* global __APP_VERSION__ */import { safeReadStorage, safeWriteStorage } from '../lib/safeStorage';@@ -230,6 +231,7 @@ const navItems = [{ to: '/rounds', label: 'Rounds', icon: Music },{ to: '/pipeline', label: 'Series Pipeline', icon: WorkflowIcon, dynamic: 'pipelineSeries' },{ to: '/sharing', label: 'Sharing', icon: Share2 },+ { to: '/sprites', label: 'Sprites', icon: PersonStanding },{ to: '/start-story', label: 'Start a Story', icon: Rocket },{ to: '/story-builder', label: 'Story Builder', icon: Wand2 },{ to: '/universes', label: 'Universes', icon: Globe, dynamic: 'universes' },diff --git a/client/src/components/sprites/AssetInspector.jsx b/client/src/components/sprites/AssetInspector.jsxnew file mode 100644index 0000000000..6195525e4d--- /dev/null+++ b/client/src/components/sprites/AssetInspector.jsx@@ -0,0 +1,109 @@+/**+ * Asset inspector (#2930 phase 2) — replaces the bare lightbox that rendered a+ * transparent PNG against plain black with no way to learn anything about it.+ *+ * Shows a checkerboarded, pixel-preserving preview plus the metadata the+ * pipeline actually needs when debugging a sprite (record-relative path,+ * dimensions, format, frame count, size, mtime) and the two actions that were+ * missing entirely: Download and Copy path. Modal supplies the backdrop, Esc+ * handling, focus trap, and focus restore to the thumbnail that opened it.+ */++import { Download, ClipboardCopy, X } from 'lucide-react';+import Modal from '../ui/Modal.jsx';+import { spriteAssetUrl, spritePreviewStyle } from './spriteAssets.js';+import { formatBytes, timeAgo } from '../../utils/formatters.js';+import { copyToClipboard } from '../../lib/clipboard.js';++const IMAGE_EXT = /\.(png|gif|webp|jpe?g|avif|tiff?)$/i;++export const isImageAsset = (path) => IMAGE_EXT.test(path);++function Row({ label, value }) {+ // `frameCount: 0` is meaningful, so only null/undefined/'' are omitted.+ if (value === null || value === undefined || value === '') return null;+ return (+ <>+ <dt className="text-gray-500">{label}</dt>+ <dd className="text-gray-200 break-all">{value}</dd>+ </>+ );+}++export default function AssetInspector({ recordId, asset, onClose }) {+ const open = !!asset;+ const url = asset ? spriteAssetUrl(recordId, asset.path) : '';+ const fileName = asset ? asset.path.split('/').pop() : '';+ // The server omits image fields entirely for non-images and for files sharp+ // couldn't read, so `undefined` here means "unknown", not "zero".+ const dimensions = asset?.width && asset?.height ? `${asset.width} × ${asset.height}` : null;++ return (+ <Modal+ open={open}+ onClose={onClose}+ size="2xl"+ ariaLabel={asset ? `Asset ${asset.path}` : undefined}+ >+ {asset && (+ <div className="space-y-3">+ <div className="flex items-start justify-between gap-3">+ <h3 className="text-sm font-semibold text-white break-all">{fileName}</h3>+ <button+ type="button"+ onClick={onClose}+ aria-label="Close asset inspector"+ className="shrink-0 text-gray-400 hover:text-white"+ >+ <X className="w-4 h-4" />+ </button>+ </div>++ {isImageAsset(asset.path) ? (+ <div+ className="rounded border border-port-border flex items-center justify-center p-2"+ style={spritePreviewStyle(10)}+ >+ <img+ src={url}+ alt={asset.path}+ className="max-w-full max-h-[55vh] object-contain"+ style={{ imageRendering: 'pixelated' }}+ />+ </div>+ ) : (+ <p className="text-xs text-gray-500 border border-port-border rounded p-4 text-center">+ No inline preview for this file type — use Download to open it.+ </p>+ )}++ <dl className="grid grid-cols-[auto_1fr] gap-x-3 gap-y-1 text-xs">+ <Row label="Path" value={asset.path} />+ <Row label="Dimensions" value={dimensions} />+ <Row label="Format" value={asset.format} />+ <Row label="Frames" value={asset.frameCount} />+ <Row label="Size" value={formatBytes(asset.size)} />+ <Row label="Modified" value={asset.mtime ? timeAgo(asset.mtime) : null} />+ </dl>++ <div className="flex flex-wrap items-center gap-2">+ <a+ href={url}+ download={fileName}+ className="flex items-center gap-1.5 px-2.5 py-1.5 text-xs bg-port-accent hover:bg-blue-600 text-white rounded"+ >+ <Download className="w-3.5 h-3.5" /> Download+ </a>+ <button+ type="button"+ onClick={() => copyToClipboard(asset.path, 'Asset path copied')}+ className="flex items-center gap-1.5 px-2.5 py-1.5 text-xs bg-port-bg border border-port-border hover:border-port-accent text-gray-300 rounded"+ >+ <ClipboardCopy className="w-3.5 h-3.5" /> Copy path+ </button>+ </div>+ </div>+ )}+ </Modal>+ );+}diff --git a/client/src/components/sprites/AssetInspector.test.jsx b/client/src/components/sprites/AssetInspector.test.jsxnew file mode 100644index 0000000000..c6e1361a08--- /dev/null+++ b/client/src/components/sprites/AssetInspector.test.jsx@@ -0,0 +1,77 @@+/**+ * Asset inspector (#2930 phase 2). Covers the two things the old bare lightbox+ * got wrong: it showed nothing about the asset, and it had no way to get the+ * file or its path out. Also pins the "unknown vs zero" rule — the server omits+ * image fields for unreadable/non-image files, and an omitted field must not+ * render as a blank or bogus row.+ */++import { describe, it, expect, vi, beforeEach } from 'vitest';+import { render, screen } from '@testing-library/react';+import userEvent from '@testing-library/user-event';+import AssetInspector, { isImageAsset } from './AssetInspector.jsx';++const copyToClipboard = vi.fn();+vi.mock('../../lib/clipboard.js', () => ({ copyToClipboard: (...a) => copyToClipboard(...a) }));++const IMAGE = {+ path: 'reference/main.png',+ size: 2048,+ mtime: Date.now(),+ width: 48,+ height: 32,+ format: 'png',+ frameCount: 1,+};++beforeEach(() => copyToClipboard.mockClear());++describe('isImageAsset', () => {+ it('accepts the formats the server probes and rejects sidecars', () => {+ for (const p of ['a.png', 'a.GIF', 'a.webp', 'a.jpeg', 'a.jpg']) expect(isImageAsset(p)).toBe(true);+ for (const p of ['a.json', 'a.mp4', 'manifest']) expect(isImageAsset(p)).toBe(false);+ });+});++describe('AssetInspector', () => {+ it('renders the metadata the pipeline needs plus download + copy actions', async () => {+ render(<AssetInspector recordId="trail-hand" asset={IMAGE} onClose={() => {}} />);++ expect(screen.getByText('reference/main.png')).toBeInTheDocument();+ expect(screen.getByText('48 × 32')).toBeInTheDocument();+ expect(screen.getByText('png')).toBeInTheDocument();+ expect(screen.getByText('2 KB')).toBeInTheDocument();++ const download = screen.getByRole('link', { name: /download/i });+ expect(download).toHaveAttribute('href', '/data/sprites/trail-hand/reference/main.png');+ expect(download).toHaveAttribute('download', 'main.png');++ await userEvent.click(screen.getByRole('button', { name: /copy path/i }));+ expect(copyToClipboard).toHaveBeenCalledWith('reference/main.png', 'Asset path copied');+ });++ it('paints a checkerboard behind the preview so alpha is not read as black', () => {+ const { container } = render(<AssetInspector recordId="trail-hand" asset={IMAGE} onClose={() => {}} />);+ const checker = container.querySelector('[style*="linear-gradient"]');+ expect(checker).toBeTruthy();+ expect(screen.getByAltText('reference/main.png')).toHaveStyle({ imageRendering: 'pixelated' });+ });++ it('omits image rows entirely for an asset the server could not probe', () => {+ render(+ <AssetInspector+ recordId="trail-hand"+ asset={{ path: 'reference/main.generation.json', size: 12, mtime: Date.now() }}+ onClose={() => {}}+ />,+ );+ expect(screen.queryByText('Dimensions')).not.toBeInTheDocument();+ expect(screen.queryByText('Format')).not.toBeInTheDocument();+ expect(screen.getByText(/no inline preview/i)).toBeInTheDocument();+ });++ it('renders nothing when no asset is selected', () => {+ const { container } = render(<AssetInspector recordId="trail-hand" asset={null} onClose={() => {}} />);+ expect(container).toBeEmptyDOMElement();+ });+});diff --git a/client/src/components/sprites/PublishWorkflow.jsx b/client/src/components/sprites/PublishWorkflow.jsxindex 7c44d73b27..8611b81388 100644--- a/client/src/components/sprites/PublishWorkflow.jsx+++ b/client/src/components/sprites/PublishWorkflow.jsx@@ -9,7 +9,7 @@ import { useAsyncAction } from '../../hooks/useAsyncAction.js';import AppContextPicker from '../AppContextPicker.jsx';import InlineConfirmRow from '../ui/InlineConfirmRow.jsx';import { FormField } from '../ui/FormField.jsx';-import { spriteAssetUrl } from './spriteAssets.js';+import { spriteAssetUrl, spritePreviewStyle } from './spriteAssets.js';import { timeAgo } from '../../utils/formatters.js';// Publish workflow (issue #2898): compile the immutable runtime atlas from@@ -145,8 +145,8 @@ export default function PublishWorkflow({ record, walk, atlas, onChanged }) {<imgsrc={spriteAssetUrl(record.id, current.atlasPath)}alt="compiled runtime atlas"- className="w-full sm:w-60 object-contain bg-port-bg border border-port-border rounded"- style={{ imageRendering: 'pixelated' }}+ className="w-full sm:w-60 object-contain border border-port-border rounded"+ style={spritePreviewStyle(6)}/>)}<buttondiff --git a/client/src/components/sprites/ReferenceWorkflow.jsx b/client/src/components/sprites/ReferenceWorkflow.jsxindex 1aabaa3054..262b439f08 100644--- a/client/src/components/sprites/ReferenceWorkflow.jsx+++ b/client/src/components/sprites/ReferenceWorkflow.jsx@@ -6,7 +6,7 @@ import { getSettings } from '../../services/apiSystem.js';import { deriveAvailableBackends } from '../../lib/imageGenBackends.js';import { useAsyncAction } from '../../hooks/useAsyncAction.js';import { useSpritePendingRenders } from '../../hooks/useSpritePendingRenders.js';-import { spriteAssetUrl } from './spriteAssets.js';+import { spriteAssetUrl, spritePreviewStyle } from './spriteAssets.js';// Reference workflow (issue #2896): generate main-reference candidates from// text + optional uploaded design image, freeze the approved main, then@@ -25,7 +25,10 @@ function SpriteImg({ recordId, path, className }) {alt={path}loading="lazy"className={className}- style={{ imageRendering: 'pixelated' }}+ // Checkerboard behind the alpha — reference candidates are transparent+ // PNGs and PortOS's surfaces are near-black, so without it a cut-out+ // region is indistinguishable from a black pixel (#2930).+ style={spritePreviewStyle(6)}/>);}diff --git a/client/src/components/sprites/WalkWorkflow.jsx b/client/src/components/sprites/WalkWorkflow.jsxindex af60e538f6..c873f983cd 100644--- a/client/src/components/sprites/WalkWorkflow.jsx+++ b/client/src/components/sprites/WalkWorkflow.jsx@@ -6,7 +6,7 @@ import {} from '../../services/apiSprites.js';import { useAsyncAction } from '../../hooks/useAsyncAction.js';import { useSpritePendingRenders } from '../../hooks/useSpritePendingRenders.js';-import { spriteAssetUrl } from './spriteAssets.js';+import { spriteAssetUrl, spritePreviewStyle } from './spriteAssets.js';// Walk workflow (issue #2897): one grok image_to_video clip per locked// directional anchor, deterministic server-side packaging into the 8-phase@@ -48,22 +48,29 @@ function StripLoop({ recordId, stripPreview }) {const { frameCount, fps, height } = stripGeometry(stripPreview);const scrub = CELL_PX * frameCount;return (+ // The loop itself paints the strip as its own background-image, so the+ // checkerboard can't share that property — it goes on a wrapper sized to+ // match, and shows through the frame's alpha (#2930).<div- role="img"- aria-label="walk loop preview"- className="bg-port-bg border border-port-border rounded"- style={{- width: CELL_PX,- height,- // Quoted: encodeURIComponent leaves `(`/`)` intact, and an externally- // authored redraw filename containing one would end the url() token early.- backgroundImage: `url("${spriteAssetUrl(recordId, stripPreview.stripPath)}")`,- backgroundSize: `${scrub}px ${height}px`,- imageRendering: 'pixelated',- '--sprite-walk-loop-end': `-${scrub}px`,- animation: `sprite-walk-loop ${(frameCount / fps).toFixed(3)}s steps(${frameCount}) infinite`,- }}- />+ className="border border-port-border rounded"+ style={{ width: CELL_PX, height, ...spritePreviewStyle(6) }}+ >+ <div+ role="img"+ aria-label="walk loop preview"+ style={{+ width: CELL_PX,+ height,+ // Quoted: encodeURIComponent leaves `(`/`)` intact, and an externally+ // authored redraw filename containing one would end the url() token early.+ backgroundImage: `url("${spriteAssetUrl(recordId, stripPreview.stripPath)}")`,+ backgroundSize: `${scrub}px ${height}px`,+ imageRendering: 'pixelated',+ '--sprite-walk-loop-end': `-${scrub}px`,+ animation: `sprite-walk-loop ${(frameCount / fps).toFixed(3)}s steps(${frameCount}) infinite`,+ }}+ />+ </div>);}@@ -124,8 +131,8 @@ function TrimPanel({ recordId, run, onClose }) {<imgsrc={spriteAssetUrl(recordId, result.loop)}alt="trimmed loop"- className="w-24 h-24 object-contain bg-port-card border border-port-border rounded"- style={{ imageRendering: 'pixelated' }}+ className="w-24 h-24 object-contain border border-port-border rounded"+ style={spritePreviewStyle(6)}/><p className="text-[10px] text-gray-500 break-all">{result.loop}</p></div>diff --git a/client/src/components/sprites/spriteAssets.js b/client/src/components/sprites/spriteAssets.jsindex d490ed4e0c..d8fc361af9 100644--- a/client/src/components/sprites/spriteAssets.js+++ b/client/src/components/sprites/spriteAssets.js@@ -1,3 +1,43 @@// Shared URL builder for sprite record assets served by the /data/sprites// static mount — one place for the per-segment encoding rules.export const spriteAssetUrl = (recordId, relPath) => `/data/sprites/${encodeURIComponent(recordId)}/${relPath.split('/').map(encodeURIComponent).join('/')}`;++// Every sprite asset is a transparent-capable PNG/GIF, and PortOS's dark+// surfaces are near-black — so alpha regions are indistinguishable from black+// pixels on a plain background. Every surface that can show one paints this+// checkerboard behind it instead (#2930).+const CHECKER_DARK = '#191919';+const CHECKER_LIGHT = '#2e2e2e';++/**+ * Inline style for a transparency checkerboard. `cell` is the square size in+ * px — use a smaller cell on thumbnails so the pattern stays legible.+ * Returns a fresh object each call (React style props must not be shared and+ * mutated), and only sets background-* properties so it composes with any+ * caller-supplied sizing/border classes.+ */+export function checkerboardStyle(cell = 8) {+ const tile = cell * 2;+ return {+ backgroundColor: CHECKER_DARK,+ backgroundImage: [+ `linear-gradient(45deg, ${CHECKER_LIGHT} 25%, transparent 25%)`,+ `linear-gradient(-45deg, ${CHECKER_LIGHT} 25%, transparent 25%)`,+ `linear-gradient(45deg, transparent 75%, ${CHECKER_LIGHT} 75%)`,+ `linear-gradient(-45deg, transparent 75%, ${CHECKER_LIGHT} 75%)`,+ ].join(', '),+ backgroundSize: `${tile}px ${tile}px`,+ backgroundPosition: `0 0, 0 ${cell}px, ${cell}px -${cell}px, -${cell}px 0`,+ };+}++// Pixel art must never be smoothed on upscale.+export const PIXELATED = { imageRendering: 'pixelated' };++/**+ * Checkerboard + pixelated in one style object, for an <img> that paints its+ * own background (the common case — the checker shows through the alpha).+ */+export function spritePreviewStyle(cell = 8) {+ return { ...checkerboardStyle(cell), ...PIXELATED };+}diff --git a/client/src/pages/MediaGen.jsx b/client/src/pages/MediaGen.jsxindex 41b5a67c50..9b874c202a 100644--- a/client/src/pages/MediaGen.jsx+++ b/client/src/pages/MediaGen.jsx@@ -1,5 +1,5 @@import { useNavigate, useLocation, Outlet } from 'react-router-dom';-import { Layers, Image as ImageIcon, Film, History, HardDrive, Scissors, FolderOpen, Sparkles, GraduationCap, Music, PersonStanding } from 'lucide-react';+import { Layers, Image as ImageIcon, Film, History, HardDrive, Scissors, FolderOpen, Sparkles, GraduationCap, Music } from 'lucide-react';import TabPills from '../components/ui/TabPills';const TABS = [@@ -7,7 +7,6 @@ const TABS = [{ id: 'video', label: 'Video', icon: Film },{ id: 'timeline', label: 'Timeline', icon: Scissors },{ id: 'music-video', label: 'Music Video', icon: Music },- { id: 'sprites', label: 'Sprites', icon: PersonStanding },{ id: 'history', label: 'History', icon: History },{ id: 'collections', label: 'Collections', icon: FolderOpen },{ id: 'loras', label: 'LoRAs', icon: Sparkles },diff --git a/client/src/pages/Sprites.jsx b/client/src/pages/Sprites.jsxindex 433b43df29..9330935f57 100644--- a/client/src/pages/Sprites.jsx+++ b/client/src/pages/Sprites.jsx@@ -2,14 +2,14 @@ import { useEffect, useState, useCallback, useMemo } from 'react';import { useParams, useNavigate } from 'react-router-dom';import { PersonStanding, Package, Download, FolderOpen, X, RefreshCw, Plus } from 'lucide-react';import toast from '../components/ui/Toast';-import Modal from '../components/ui/Modal.jsx';import { listSpriteRecords, getSpriteRecord, importSprites, createSpriteRecord } from '../services/apiSprites.js';import { getApps } from '../services/apiApps.js';import AppContextPicker from '../components/AppContextPicker.jsx';import ReferenceWorkflow from '../components/sprites/ReferenceWorkflow.jsx';import WalkWorkflow from '../components/sprites/WalkWorkflow.jsx';import PublishWorkflow from '../components/sprites/PublishWorkflow.jsx';-import { spriteAssetUrl } from '../components/sprites/spriteAssets.js';+import AssetInspector, { isImageAsset } from '../components/sprites/AssetInspector.jsx';+import { spriteAssetUrl, spritePreviewStyle } from '../components/sprites/spriteAssets.js';import { useAsyncAction } from '../hooks/useAsyncAction.js';import { formatBytes, timeAgo } from '../utils/formatters.js';@@ -21,8 +21,6 @@ import { formatBytes, timeAgo } from '../utils/formatters.js';// grok i2v clip per anchor, deterministic packaging, per-direction approval// into the finalized walk set — #2897). Publish lands in phase 4.-const IMAGE_EXT = /\.(png|gif|webp|jpe?g)$/i;-function topLevelGroup(assetPath) {const idx = assetPath.indexOf('/');return idx < 0 ? '' : assetPath.slice(0, idx);@@ -236,7 +234,7 @@ function RecordList({ records, selectedId, onSelect }) {}function AssetGroups({ recordId, assets }) {- const [preview, setPreview] = useState(null);+ const [inspecting, setInspecting] = useState(null);const groups = useMemo(() => assets.reduce((acc, a) => {const g = topLevelGroup(a.path) || 'files';(acc[g] ||= []).push(a);@@ -251,56 +249,45 @@ function AssetGroups({ recordId, assets }) {<span className="text-xs text-gray-500 font-normal">({files.length})</span></h4><div className="grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-6 gap-2">- {files.map((a) => {- const url = spriteAssetUrl(recordId, a.path);- return IMAGE_EXT.test(a.path) ? (- <button- key={a.path}- onClick={() => setPreview({ url, path: a.path })}- className="bg-port-bg border border-port-border rounded p-1 hover:border-port-accent"- title={a.path}- >- <img src={url} alt={a.path} loading="lazy" className="w-full h-20 object-contain" style={{ imageRendering: 'pixelated' }} />- <span className="block text-[10px] text-gray-500 truncate">{a.path.split('/').pop()}</span>- </button>- ) : (- <a- key={a.path}- href={url}- target="_blank"- rel="noreferrer"- className="bg-port-bg border border-port-border rounded p-2 text-xs text-gray-400 hover:border-gray-500 truncate"- title={a.path}- >- {a.path.split('/').pop()}- <span className="block text-[10px] text-gray-600">{formatBytes(a.size)}</span>- </a>- );- })}+ {files.map((a) => (isImageAsset(a.path) ? (+ <button+ key={a.path}+ onClick={() => setInspecting(a)}+ className="bg-port-bg border border-port-border rounded p-1 hover:border-port-accent"+ title={a.path}+ >+ {/* Checkerboard on the tile, not the <img>: object-contain+ letterboxes the image, and a background on the img itself+ would only paint the letterboxed box, not the tile. */}+ <span className="block rounded" style={spritePreviewStyle(6)}>+ <img+ src={spriteAssetUrl(recordId, a.path)}+ alt={a.path}+ loading="lazy"+ className="w-full h-20 object-contain"+ style={{ imageRendering: 'pixelated' }}+ />+ </span>+ <span className="block text-[10px] text-gray-500 truncate">{a.path.split('/').pop()}</span>+ {a.width && a.height && (+ <span className="block text-[10px] text-gray-600">{a.width}×{a.height}</span>+ )}+ </button>+ ) : (+ <button+ key={a.path}+ onClick={() => setInspecting(a)}+ className="bg-port-bg border border-port-border rounded p-2 text-xs text-gray-400 hover:border-gray-500 text-left truncate"+ title={a.path}+ >+ {a.path.split('/').pop()}+ <span className="block text-[10px] text-gray-600">{formatBytes(a.size)}</span>+ </button>+ )))}</div></div>))}- {/* Shared Modal for the lightbox: Esc-to-close, focus trap, and- focus restore to the thumbnail that opened it — the hand-rolled- overlay this replaced was click-to-dismiss only. */}- <Modal- open={!!preview}- onClose={() => setPreview(null)}- size="none"- backdropClassName="bg-black/80"- ariaLabel={preview ? `Preview ${preview.path}` : undefined}- panelClassName="max-w-full max-h-full"- >- <img src={preview?.url} alt={preview?.path || ''} className="max-w-full max-h-[85vh] object-contain" style={{ imageRendering: 'pixelated' }} />- <p className="text-center text-xs text-gray-400 mt-2">{preview?.path}</p>- <button- type="button"- onClick={() => setPreview(null)}- className="sr-only focus:not-sr-only focus:absolute focus:top-2 focus:right-2 focus:bg-port-card focus:text-white focus:px-3 focus:py-1 focus:rounded"- >- Close preview- </button>- </Modal>+ <AssetInspector recordId={recordId} asset={inspecting} onClose={() => setInspecting(null)} /></div>);}@@ -345,91 +332,97 @@ export default function Sprites() {}, [id, retryTick]);return (- <div className="flex flex-col md:flex-row gap-4 h-full">- <aside className="md:w-64 shrink-0 space-y-3">- <NewCharacterPanel onCreated={(record) => { refresh(); navigate(`/media/sprites/${record.id}`); }} />- {/* Re-import while a sprite is open must refresh the open detail too,- not just the sidebar list. */}- <ImportPanel onImported={() => { refresh(); if (id) setRetryTick((t) => t + 1); }} />- {records === null ? (- <p className="text-sm text-gray-500">Loading…</p>- ) : records.length === 0 ? (- <p className="text-sm text-gray-500">- No sprites yet. Import a production set from a sprite-pipeline checkout to get started.- </p>- ) : (- <RecordList records={records} selectedId={id} onSelect={(rid) => navigate(`/media/sprites/${rid}`)} />- )}- </aside>- <section className="flex-1 min-w-0">- {!id ? (- <p className="text-sm text-gray-500">Select a sprite to browse its reference set, animation strips, and atlases.</p>- ) : detailState === 'missing' ? (- <div className="text-sm text-gray-400">- Sprite not found.{' '}- <button onClick={() => navigate('/media/sprites')} className="text-port-accent hover:underline">Back to library</button>- </div>- ) : detailState === 'error' ? (- <div className="text-sm text-gray-400">- Failed to load this sprite.{' '}- <button onClick={() => setRetryTick((t) => t + 1)} className="text-port-accent hover:underline">Retry</button>- </div>- ) : !detail ? (- <p className="text-sm text-gray-500">Loading…</p>- ) : (- <div className="space-y-4">- <div>- <h2 className="text-lg font-semibold text-white flex items-center gap-2">- {detail.record.kind === 'character' ? <PersonStanding className="w-5 h-5" /> : <Package className="w-5 h-5" />}- {detail.record.name}- </h2>- <p className="text-xs text-gray-500">- {detail.record.kind} · {detail.record.status}- {detail.record.chromaKey && (- <>- {' · chroma key '}- <span className="inline-block w-3 h-3 rounded-sm align-middle border border-port-border" style={{ backgroundColor: detail.record.chromaKey }} />{' '}- {detail.record.chromaKey}- </>+ <div className="space-y-4">+ <div className="flex items-center gap-3">+ <PersonStanding className="w-6 h-6 text-port-accent" />+ <h1 className="text-2xl font-bold text-white">Sprite Manager</h1>+ </div>+ <div className="flex flex-col md:flex-row gap-4">+ <aside className="md:w-64 shrink-0 space-y-3">+ <NewCharacterPanel onCreated={(record) => { refresh(); navigate(`/sprites/${record.id}`); }} />+ {/* Re-import while a sprite is open must refresh the open detail too,+ not just the sidebar list. */}+ <ImportPanel onImported={() => { refresh(); if (id) setRetryTick((t) => t + 1); }} />+ {records === null ? (+ <p className="text-sm text-gray-500">Loading…</p>+ ) : records.length === 0 ? (+ <p className="text-sm text-gray-500">+ No sprites yet. Import a production set from a sprite-pipeline checkout to get started.+ </p>+ ) : (+ <RecordList records={records} selectedId={id} onSelect={(rid) => navigate(`/sprites/${rid}`)} />+ )}+ </aside>+ <section className="flex-1 min-w-0">+ {!id ? (+ <p className="text-sm text-gray-500">Select a sprite to browse its reference set, animation strips, and atlases.</p>+ ) : detailState === 'missing' ? (+ <div className="text-sm text-gray-400">+ Sprite not found.{' '}+ <button onClick={() => navigate('/sprites')} className="text-port-accent hover:underline">Back to library</button>+ </div>+ ) : detailState === 'error' ? (+ <div className="text-sm text-gray-400">+ Failed to load this sprite.{' '}+ <button onClick={() => setRetryTick((t) => t + 1)} className="text-port-accent hover:underline">Retry</button>+ </div>+ ) : !detail ? (+ <p className="text-sm text-gray-500">Loading…</p>+ ) : (+ <div className="space-y-4">+ <div>+ <h2 className="text-lg font-semibold text-white flex items-center gap-2">+ {detail.record.kind === 'character' ? <PersonStanding className="w-5 h-5" /> : <Package className="w-5 h-5" />}+ {detail.record.name}+ </h2>+ <p className="text-xs text-gray-500">+ {detail.record.kind} · {detail.record.status}+ {detail.record.chromaKey && (+ <>+ {' · chroma key '}+ <span className="inline-block w-3 h-3 rounded-sm align-middle border border-port-border" style={{ backgroundColor: detail.record.chromaKey }} />{' '}+ {detail.record.chromaKey}+ </>+ )}+ {detail.record.importedFrom?.importedAt && ` · imported ${timeAgo(detail.record.importedFrom.importedAt)}`}+ </p>+ {detail.record.spec?.archetype && (+ <p className="text-xs text-gray-500">archetype: {detail.record.spec.archetype}</p>)}- {detail.record.importedFrom?.importedAt && ` · imported ${timeAgo(detail.record.importedFrom.importedAt)}`}- </p>- {detail.record.spec?.archetype && (- <p className="text-xs text-gray-500">archetype: {detail.record.spec.archetype}</p>+ </div>+ {detail.record.kind === 'character' && (+ <>+ <ReferenceWorkflow+ record={detail.record}+ reference={detail.reference}+ onChanged={onWorkflowChanged}+ />+ <WalkWorkflow+ record={detail.record}+ reference={detail.reference}+ walk={detail.walk}+ onChanged={onWorkflowChanged}+ />+ {/* Keyed by record so form state and an armed publish/overwrite+ confirmation never survive switching characters. */}+ <PublishWorkflow+ key={detail.record.id}+ record={detail.record}+ walk={detail.walk}+ atlas={detail.atlas}+ onChanged={onWorkflowChanged}+ />+ </>+ )}+ {detail.assets.length === 0 ? (+ <p className="text-sm text-gray-500">No assets on disk for this record.</p>+ ) : (+ <AssetGroups recordId={detail.record.id} assets={detail.assets} />)}</div>- {detail.record.kind === 'character' && (- <>- <ReferenceWorkflow- record={detail.record}- reference={detail.reference}- onChanged={onWorkflowChanged}- />- <WalkWorkflow- record={detail.record}- reference={detail.reference}- walk={detail.walk}- onChanged={onWorkflowChanged}- />- {/* Keyed by record so form state and an armed publish/overwrite- confirmation never survive switching characters. */}- <PublishWorkflow- key={detail.record.id}- record={detail.record}- walk={detail.walk}- atlas={detail.atlas}- onChanged={onWorkflowChanged}- />- </>- )}- {detail.assets.length === 0 ? (- <p className="text-sm text-gray-500">No assets on disk for this record.</p>- ) : (- <AssetGroups recordId={detail.record.id} assets={detail.assets} />- )}- </div>- )}- </section>+ )}+ </section>+ </div></div>);}diff --git a/server/lib/navManifest.js b/server/lib/navManifest.jsindex 24a839c0d5..122d660393 100644--- a/server/lib/navManifest.js+++ b/server/lib/navManifest.js@@ -23,7 +23,10 @@ export const NAV_COMMANDS = [{ id: 'nav.create.creative-commission', path: '/creative-commission', label: 'Creative Commissions', section: 'Create', aliases: ['creative-commission', 'commissions', 'commission', 'creation-engine', 'autonomous-creation', 'standing-brief', 'recurring-brief'], keywords: ['schedule', 'recurring', 'nightly', 'brief', 'autonomous', 'creation engine', 'cron', 'feedback', 'taste', 'standing commission', 'auto-generate'] },{ id: 'nav.media.music-video', path: '/media/music-video', label: 'Music Video', section: 'Create', aliases: ['music-video', 'musicvideo', 'music video', 'mv', 'sync-to-beat'], keywords: ['music', 'beat', 'sync', 'audio-reactive', 'director', 'scene board', 'tempo', 'choreography'] },{ id: 'nav.create.mood-boards', path: '/mood-boards', label: 'Mood Boards', section: 'Create', aliases: ['mood-boards', 'mood-board', 'moodboard', 'mood', 'inspiration', 'references'], keywords: ['inspiration', 'reference', 'pin', 'visual', 'canvas', 'collect', 'pinboard', 'palette', 'ideas'] },- { id: 'nav.media.sprites', path: '/media/sprites', label: 'Sprites', section: 'Create', aliases: ['sprites', 'sprite', 'sprite-manager', 'sprite-sheets'], keywords: ['sprite sheet', 'atlas', 'game art', 'pixel art', 'character animation', 'walk cycle', 'anchors'] },+ // Promoted out of the Media Gen tabs to a top-level Create page (#2930).+ // The id stays `nav.media.sprites` — it's opaque and stored in palette+ // history, so renaming it would orphan those entries.+ { id: 'nav.media.sprites', path: '/sprites', label: 'Sprites', section: 'Create', aliases: ['sprites', 'sprite', 'sprite-manager', 'sprite-sheets'], keywords: ['sprite sheet', 'atlas', 'game art', 'pixel art', 'character animation', 'walk cycle', 'anchors'] },{ id: 'nav.media.timeline', path: '/media/timeline', label: 'Timeline', section: 'Create', aliases: ['timeline', 'video-timeline', 'editor'], keywords: ['edit', 'trim', 'composite', 'stitch', 'cut', 'compose'] },{ id: 'nav.media.models', path: '/media/models', label: 'Media Models', section: 'Create', aliases: ['media-models', 'image-models', 'video-models', 'huggingface'], keywords: ['hf cache', 'model storage', 'disk', 'add model', 'install model', 'custom model'] },{ id: 'nav.create.authors', path: '/authors', label: 'Authors', section: 'Create', aliases: ['authors', 'author', 'byline', 'author-persona', 'writer-persona'], keywords: ['author', 'byline', 'pen name', 'persona', 'writing style', 'bio', 'headshot', 'cover', 'book author'] },diff --git a/server/services/sprites/paths.js b/server/services/sprites/paths.jsindex 8308b9e25d..3596d2b48b 100644--- a/server/services/sprites/paths.js+++ b/server/services/sprites/paths.js@@ -13,6 +13,7 @@import { join, resolve } from 'path';import { readdir, stat } from 'fs/promises';+import sharp from 'sharp';import { PATHS, isPathInsideDir } from '../../lib/fileUtils.js';import { ServerError } from '../../lib/errorHandler.js';import { isValidSpriteId } from './recordsLogic.js';@@ -84,11 +85,44 @@ export function resolveSpriteAssetPath(recordId, relPath) {// review, so the local browser keeps them.const RUN_RAW_INTERMEDIATE = /^(grok|runs)\/[^/]+\/generated\/raw\//;+// Extensions sharp can parse a header for. Anything else (JSON manifests,+// videos, text) skips the metadata probe entirely.+const IMAGE_METADATA_EXT = /\.(png|gif|webp|jpe?g|avif|tiff?)$/i;++/**+ * Header-only image metadata for the asset inspector: `{ width, height,+ * format, frameCount }`. Returns `{}` for a non-image extension OR an+ * unreadable/corrupt file — the inspector renders "unknown" for a missing+ * field, which is strictly better than the whole record detail 500-ing+ * because one truncated PNG landed in the tree. sharp only reads the header+ * here (no decode), so this stays cheap across a few hundred frames.+ */+async function readImageMetadata(absPath) {+ if (!IMAGE_METADATA_EXT.test(absPath)) return {};+ try {+ const meta = await sharp(absPath).metadata();+ return {+ width: meta.width ?? null,+ height: meta.height ?? null,+ format: meta.format ?? null,+ // `pages` is only set for multi-page formats (animated GIF/WebP); a+ // still PNG has exactly one frame.+ frameCount: meta.pages ?? 1,+ };+ } catch {+ return {};+ }+}+/**- * Recursively list a record's on-disk assets as `[{ path, size, mtime }]`- * with `path` relative (posix separators) to the record dir. Dotfiles and- * raw run intermediates are skipped; per-directory stats and subdirectory- * descents run in parallel. A record with no directory yet returns [].+ * Recursively list a record's on-disk assets as+ * `[{ path, size, mtime, width?, height?, format?, frameCount? }]` with+ * `path` relative (posix separators) to the record dir. Dotfiles and raw run+ * intermediates are skipped; per-directory stats, image-metadata probes, and+ * subdirectory descents run in parallel. A record with no directory yet+ * returns []. The image fields are absent (not null) on non-images and on+ * files sharp can't read, so a corrupt asset degrades to the plain+ * `{ path, size, mtime }` row.*/export async function listSpriteAssets(recordId) {const dir = spriteDir(recordId);@@ -107,8 +141,9 @@ export async function listSpriteAssets(recordId) {if (RUN_RAW_INTERMEDIATE.test(`${rel}/`)) return;await walk(join(current, entry.name), rel);} else if (entry.isFile()) {- const s = await stat(join(current, entry.name));- out.push({ path: rel, size: s.size, mtime: s.mtimeMs });+ const abs = join(current, entry.name);+ const [s, meta] = await Promise.all([stat(abs), readImageMetadata(abs)]);+ out.push({ path: rel, size: s.size, mtime: s.mtimeMs, ...meta });}}));}diff --git a/server/services/sprites/pathsAssets.test.js b/server/services/sprites/pathsAssets.test.jsnew file mode 100644index 0000000000..5ef98c097a--- /dev/null+++ b/server/services/sprites/pathsAssets.test.js@@ -0,0 +1,81 @@+/**+ * listSpriteAssets image-metadata enrichment (#2930 phase 2). The asset+ * inspector needs dimensions/format/frame count per asset, and the listing+ * must degrade — never throw — for non-images and unreadable files. Lives in+ * its own file because paths.test.js is deliberately dependency-free (no+ * PATHS mock) and this suite needs a real tmpdir sprite tree.+ */++import { describe, it, expect, afterAll, vi } from 'vitest';+import { mkdtempSync, rmSync } from 'fs';+import { tmpdir } from 'os';+import { join } from 'path';+import { mkdir, writeFile } from 'fs/promises';+import sharp from 'sharp';++const TEST_ROOT = mkdtempSync(join(tmpdir(), 'sprite-paths-assets-'));++vi.mock('../../lib/fileUtils.js', async (importOriginal) => {+ const actual = await importOriginal();+ Object.assign(actual.PATHS, { data: TEST_ROOT, sprites: join(TEST_ROOT, 'sprites') });+ return actual;+});++const { listSpriteAssets } = await import('./paths.js');++afterAll(() => rmSync(TEST_ROOT, { recursive: true, force: true }));++const RECORD = 'meta-probe';+const recDir = join(TEST_ROOT, 'sprites', RECORD);++const byPath = (assets) => Object.fromEntries(assets.map((a) => [a.path, a]));++describe('listSpriteAssets image metadata', () => {+ it('reports dimensions/format/frameCount for readable images and degrades for the rest', async () => {+ await mkdir(join(recDir, 'reference'), { recursive: true });+ await sharp({+ create: { width: 48, height: 32, channels: 4, background: { r: 0, g: 0, b: 0, alpha: 0 } },+ }).png().toFile(join(recDir, 'reference', 'main.png'));+ // A truncated PNG: right extension, unparseable bytes.+ await writeFile(join(recDir, 'reference', 'corrupt.png'), 'not actually a png');+ // A non-image sibling — never probed at all.+ await writeFile(join(recDir, 'reference', 'main.generation.json'), '{}');++ const assets = byPath(await listSpriteAssets(RECORD));++ expect(assets['reference/main.png']).toMatchObject({+ width: 48, height: 32, format: 'png', frameCount: 1,+ });+ expect(assets['reference/main.png'].size).toBeGreaterThan(0);++ // Corrupt + non-image rows keep the base shape with NO image fields, so+ // the client can distinguish "not an image / unreadable" from a real value.+ for (const p of ['reference/corrupt.png', 'reference/main.generation.json']) {+ expect(assets[p]).toHaveProperty('size');+ expect(assets[p]).toHaveProperty('mtime');+ expect(assets[p]).not.toHaveProperty('width');+ expect(assets[p]).not.toHaveProperty('format');+ }+ });++ it('counts pages for an animated image', async () => {+ const gifDir = join(recDir, 'walk');+ await mkdir(gifDir, { recursive: true });+ // Hand-assembled 1x1 two-frame GIF89a. Trim GIFs are encoded by ffmpeg in+ // production (walkTrims.js), and sharp's own gif writer collapses a+ // pageHeight input to a single page — so a literal is the only way to get+ // a real multi-page fixture without shelling out to ffmpeg in a unit test.+ const header = '474946383961' // "GIF89a"+ + '0100' + '0100' // 1x1 logical screen+ + '800000' // global colour table, 2 entries+ + '000000' + 'ffffff'; // black, white+ const frame = '21f904000a000000' // graphic control ext, 100ms+ + '2c00000000010001000002024401' + '00'; // 1x1 image descriptor + LZW block+ const gif = Buffer.from(`${header}${frame}${frame}3b`, 'hex');+ await writeFile(join(gifDir, 'loop.gif'), gif);++ const assets = byPath(await listSpriteAssets(RECORD));+ expect(assets['walk/loop.gif'].format).toBe('gif');+ expect(assets['walk/loop.gif'].frameCount).toBe(2);+ });+});