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
refactor([issue-2930]): share one sprite preview element, cache the metadata probe, and generalize the legacy redirect
[._.]/ Adam Eivy33924a600e07
diff --git a/client/src/App.jsx b/client/src/App.jsxindex 265cd7083c..3307369c90 100644--- a/client/src/App.jsx+++ b/client/src/App.jsx@@ -165,26 +165,20 @@ function UniverseRouteRedirect({ fromPrefix, canon = false }) {return <Navigate to={target} replace />;}-// Redirect legacy /media/creative-director/* deep-links to the top-level-// /creative-director/* route (Creative Director moved out of the Media Gen-// tabs into its own Create page). Preserves the trailing path (id + tab),-// query string, and hash.-function CreativeDirectorLegacyRedirect() {+// Rebase a legacy route prefix onto its current one, preserving the trailing+// path (ids, tabs), query string, and hash. Every page promoted out of the+// Media Gen tab shell into its own Create page needs exactly this — Creative+// Director (`/media/creative-director/:id/:tab`) and Sprites+// (`/media/sprites/:id`) so far — so it's parameterized rather than copied per+// move. `from` must be an anchored regex so it can only match the prefix.+function PrefixRedirect({ from, to }) {const { pathname, search, hash } = useLocation();- const rest = pathname.replace(/^\/media\/creative-director/, '');- return <Navigate to={`/creative-director${rest}${search}${hash}`} replace />;+ const rest = pathname.replace(from, '');+ return <Navigate to={`${to}${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 />;-}+const MEDIA_CREATIVE_DIRECTOR_PREFIX = /^\/media\/creative-director/;+const MEDIA_SPRITES_PREFIX = /^\/media\/sprites/;// Normalize a tab-less /creative-director/:id URL to its overview tab while// preserving any query string + hash. A bare `<Navigate to="overview">` would@@ -334,15 +328,15 @@ export default function App() {(Create sidebar link). These redirects keep legacy/media/creative-director bookmarks + in-app deep-links working. */}<Route path="creative-director" element={<RedirectWithSearch to="/creative-director" />} />- <Route path="creative-director/:id" element={<CreativeDirectorLegacyRedirect />} />- <Route path="creative-director/:id/:tab" element={<CreativeDirectorLegacyRedirect />} />+ <Route path="creative-director/:id" element={<PrefixRedirect from={MEDIA_CREATIVE_DIRECTOR_PREFIX} to="/creative-director" />} />+ <Route path="creative-director/:id/:tab" element={<PrefixRedirect from={MEDIA_CREATIVE_DIRECTOR_PREFIX} to="/creative-director" />} /><Route path="music-video" element={<MusicVideo />} /><Route path="music-video/:projectId" element={<MusicVideo />} />{/* Sprites live at /sprites (Create sidebar link). These redirectskeep legacy /media/sprites bookmarks working after the MediaGentab was removed. */}- <Route path="sprites" element={<RedirectWithSearch to="/sprites" />} />- <Route path="sprites/:id" element={<SpritesLegacyRedirect />} />+ <Route path="sprites" element={<PrefixRedirect from={MEDIA_SPRITES_PREFIX} to="/sprites" />} />+ <Route path="sprites/:id" element={<PrefixRedirect from={MEDIA_SPRITES_PREFIX} to="/sprites" />} /><Route path="timeline" element={<VideoTimeline />} /><Route path="timeline/:projectId" element={<VideoTimelineEditor />} /><Route path="models" element={<MediaModels />} />diff --git a/client/src/components/sprites/AssetInspector.jsx b/client/src/components/sprites/AssetInspector.jsxindex 6195525e4d..67fcca23a9 100644--- a/client/src/components/sprites/AssetInspector.jsx+++ b/client/src/components/sprites/AssetInspector.jsx@@ -11,14 +11,11 @@import { Download, ClipboardCopy, X } from 'lucide-react';import Modal from '../ui/Modal.jsx';-import { spriteAssetUrl, spritePreviewStyle } from './spriteAssets.js';+import SpritePreview from './SpritePreview.jsx';+import { spriteAssetUrl, hasSpritePreview } 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;@@ -31,79 +28,73 @@ function Row({ label, value }) {}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;+ if (!asset) return null;++ const url = spriteAssetUrl(recordId, asset.path);+ const fileName = asset.path.split('/').pop();+ const previewable = hasSpritePreview(asset);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>+ <Modal open onClose={onClose} size="2xl" ariaLabel={`Asset ${asset.path}`}>+ <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>- )}+ {previewable ? (+ <SpritePreview+ recordId={recordId}+ path={asset.path}+ className="rounded border border-port-border p-2"+ imgClassName="mx-auto max-w-full max-h-[55vh] object-contain"+ cell={10}+ loading="eager"+ />+ ) : (+ <p className="text-xs text-gray-500 border border-port-border rounded p-4 text-center">+ {/* `imageError` distinguishes "PortOS tried and failed" from "this+ was never an image" — the server keeps them apart precisely so+ a corrupt asset reads as broken rather than as a sidecar. */}+ {asset.imageError+ ? 'This looks like an image, but PortOS could not read it — it may be truncated or corrupt.'+ : '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>+ <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={previewable ? `${asset.width} × ${asset.height}` : null} />+ <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 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.jsxindex c6e1361a08..8f95fdf504 100644--- a/client/src/components/sprites/AssetInspector.test.jsx+++ b/client/src/components/sprites/AssetInspector.test.jsx@@ -9,7 +9,8 @@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';+import AssetInspector from './AssetInspector.jsx';+import { hasSpritePreview } from './spriteAssets.js';const copyToClipboard = vi.fn();vi.mock('../../lib/clipboard.js', () => ({ copyToClipboard: (...a) => copyToClipboard(...a) }));@@ -26,10 +27,14 @@ const IMAGE = {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('hasSpritePreview', () => {+ it('follows the server probe rather than the file extension', () => {+ expect(hasSpritePreview(IMAGE)).toBe(true);+ // A .png the server could not read has no dimensions — it must NOT be+ // previewed, or the grid renders a broken <img>.+ expect(hasSpritePreview({ path: 'a.png', size: 3, imageError: true })).toBe(false);+ expect(hasSpritePreview({ path: 'a.json', size: 3 })).toBe(false);+ expect(hasSpritePreview(null)).toBe(false);});});@@ -57,7 +62,7 @@ describe('AssetInspector', () => {expect(screen.getByAltText('reference/main.png')).toHaveStyle({ imageRendering: 'pixelated' });});- it('omits image rows entirely for an asset the server could not probe', () => {+ it('omits image rows entirely for a non-image sidecar', () => {render(<AssetInspectorrecordId="trail-hand"@@ -70,6 +75,20 @@ describe('AssetInspector', () => {expect(screen.getByText(/no inline preview/i)).toBeInTheDocument();});+ it('says an image was unreadable rather than reusing the sidecar wording', () => {+ render(+ <AssetInspector+ recordId="trail-hand"+ asset={{ path: 'reference/corrupt.png', size: 12, mtime: Date.now(), imageError: true }}+ onClose={() => {}}+ />,+ );+ expect(screen.getByText(/could not read it/i)).toBeInTheDocument();+ expect(screen.queryByText(/no inline preview/i)).not.toBeInTheDocument();+ // Still downloadable — the user may want to inspect the broken bytes.+ expect(screen.getByRole('link', { name: /download/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 8611b81388..ecc6c409e2 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, spritePreviewStyle } from './spriteAssets.js';+import SpritePreview from './SpritePreview.jsx';import { timeAgo } from '../../utils/formatters.js';// Publish workflow (issue #2898): compile the immutable runtime atlas from@@ -142,11 +142,12 @@ export default function PublishWorkflow({ record, walk, atlas, onChanged }) {<div className="flex flex-col sm:flex-row gap-3"><div className="space-y-2">{current && (- <img- src={spriteAssetUrl(record.id, current.atlasPath)}+ <SpritePreview+ recordId={record.id}+ path={current.atlasPath}alt="compiled runtime atlas"- className="w-full sm:w-60 object-contain border border-port-border rounded"- style={spritePreviewStyle(6)}+ className="w-full sm:w-60 border border-port-border rounded"+ imgClassName="w-full object-contain"/>)}<buttondiff --git a/client/src/components/sprites/ReferenceWorkflow.jsx b/client/src/components/sprites/ReferenceWorkflow.jsxindex 262b439f08..513d1fe8dc 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, spritePreviewStyle } from './spriteAssets.js';+import SpritePreview from './SpritePreview.jsx';// Reference workflow (issue #2896): generate main-reference candidates from// text + optional uploaded design image, freeze the approved main, then@@ -18,19 +18,11 @@ import { spriteAssetUrl, spritePreviewStyle } from './spriteAssets.js';// import server modules).const CHROMA_KEYS = ['#FF00FF', '#00FF00', '#0000FF'];+// Thin alias so the existing call sites keep their `className` semantics+// (sizing on the box) while the checkerboard + pixelation rules live in one+// place — see SpritePreview.function SpriteImg({ recordId, path, className }) {- return (- <img- src={spriteAssetUrl(recordId, path)}- alt={path}- loading="lazy"- className={className}- // 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)}- />- );+ return <SpritePreview recordId={recordId} path={path} className={className} />;}// Candidate thumbnail with an inline lock confirm (locking is irreversible —diff --git a/client/src/components/sprites/SpritePreview.jsx b/client/src/components/sprites/SpritePreview.jsxnew file mode 100644index 0000000000..de9e6df7fd--- /dev/null+++ b/client/src/components/sprites/SpritePreview.jsx@@ -0,0 +1,39 @@+/**+ * The one way to render a sprite asset (#2930).+ *+ * Every sprite is a transparent PNG on PortOS's near-black surfaces, so each+ * preview needs a checkerboard behind it and `image-rendering: pixelated` on+ * the art. Applying that per call site went wrong immediately: the checker+ * belongs on the BOX, not on the <img>, because `object-contain` letterboxes+ * the image and a background set on the img itself paints only the letterboxed+ * content area — leaving the surrounding gap unmarked. Sharing the style+ * object alone let each site re-derive (and get) that rule wrong, so the+ * element is shared instead.+ */++import { checkerboardStyle, spriteAssetUrl, PIXELATED } from './spriteAssets.js';++export default function SpritePreview({+ recordId,+ path,+ alt,+ className = '',+ imgClassName = 'w-full h-full object-contain',+ cell = 6,+ loading = 'lazy',+}) {+ return (+ <span+ className={`block overflow-hidden ${className}`}+ style={checkerboardStyle(cell)}+ >+ <img+ src={spriteAssetUrl(recordId, path)}+ alt={alt ?? path}+ loading={loading}+ className={imgClassName}+ style={PIXELATED}+ />+ </span>+ );+}diff --git a/client/src/components/sprites/WalkWorkflow.jsx b/client/src/components/sprites/WalkWorkflow.jsxindex c873f983cd..349579d022 100644--- a/client/src/components/sprites/WalkWorkflow.jsx+++ b/client/src/components/sprites/WalkWorkflow.jsx@@ -6,7 +6,8 @@ import {} from '../../services/apiSprites.js';import { useAsyncAction } from '../../hooks/useAsyncAction.js';import { useSpritePendingRenders } from '../../hooks/useSpritePendingRenders.js';-import { spriteAssetUrl, spritePreviewStyle } from './spriteAssets.js';+import { spriteAssetUrl, checkerboardStyle, PIXELATED } from './spriteAssets.js';+import SpritePreview from './SpritePreview.jsx';// Walk workflow (issue #2897): one grok image_to_video clip per locked// directional anchor, deterministic server-side packaging into the 8-phase@@ -48,24 +49,24 @@ 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).+ // The loop paints the strip as its OWN background-image, so it can't also+ // carry the checkerboard — that goes on a wrapper sized to match, and shows+ // through the frame's alpha (#2930). SpritePreview doesn't fit here: there+ // is no <img>, the animation is a stepped background scrub.<divclassName="border border-port-border rounded"- style={{ width: CELL_PX, height, ...spritePreviewStyle(6) }}+ style={{ width: CELL_PX, height, ...checkerboardStyle(6) }}><divrole="img"aria-label="walk loop preview"+ className="w-full h-full"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',+ ...PIXELATED,'--sprite-walk-loop-end': `-${scrub}px`,animation: `sprite-walk-loop ${(frameCount / fps).toFixed(3)}s steps(${frameCount}) infinite`,}}@@ -128,11 +129,11 @@ function TrimPanel({ recordId, run, onClose }) {</div>{result && (<div className="flex items-center gap-2">- <img- src={spriteAssetUrl(recordId, result.loop)}+ <SpritePreview+ recordId={recordId}+ path={result.loop}alt="trimmed loop"- className="w-24 h-24 object-contain border border-port-border rounded"- style={spritePreviewStyle(6)}+ className="w-24 h-24 shrink-0 border border-port-border rounded"/><p className="text-[10px] text-gray-500 break-all">{result.loop}</p></div>diff --git a/client/src/components/sprites/WalkWorkflow.test.jsx b/client/src/components/sprites/WalkWorkflow.test.jsxindex 25d516c7e5..25d30d4724 100644--- a/client/src/components/sprites/WalkWorkflow.test.jsx+++ b/client/src/components/sprites/WalkWorkflow.test.jsx@@ -82,7 +82,9 @@ describe('WalkWorkflow loop preview', () => {stripPath: 'grok/walk-east-abc/generated/strip.png',frameCount: 8, fps: 12, cellWidth: 384, cellHeight: 192,});- expect(loop.style.height).toBe(`${CELL_PX / 2}px`);+ // The box is the checkerboarded wrapper (#2930) — the scrubbing element+ // fills it, so the computed cell height is asserted on the parent.+ expect(loop.parentElement.style.height).toBe(`${CELL_PX / 2}px`);expect(loop.style.backgroundSize).toBe(`${CELL_PX * 8}px ${CELL_PX / 2}px`);});});diff --git a/client/src/components/sprites/spriteAssets.js b/client/src/components/sprites/spriteAssets.jsindex d8fc361af9..7d49aff853 100644--- a/client/src/components/sprites/spriteAssets.js+++ b/client/src/components/sprites/spriteAssets.js@@ -5,18 +5,21 @@ export const spriteAssetUrl = (recordId, relPath) => `/data/sprites/${encodeURIC// 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';+// checkerboard behind it instead (#2930). Read through CSS custom properties+// so a light theme can re-map them in index.css; the literals are the dark+// defaults, since a theme that sets neither still needs a working checker.+const CHECKER_DARK = 'var(--sprite-checker-dark, #191919)';+const CHECKER_LIGHT = 'var(--sprite-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.+ * px — thumbnails want a smaller cell so the pattern stays legible, the+ * inspector a larger one. Inline rather than a CSS class because the cell size+ * varies per surface. 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) {+export function checkerboardStyle(cell = 6) {const tile = cell * 2;return {backgroundColor: CHECKER_DARK,@@ -31,13 +34,16 @@ export function checkerboardStyle(cell = 8) {};}-// Pixel art must never be smoothed on upscale.-export const PIXELATED = { imageRendering: 'pixelated' };+// Pixel art must never be smoothed on upscale. Frozen and shared — it's a+// constant, and every consumer treats React style props as read-only.+export const PIXELATED = Object.freeze({ 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).+ * Can this asset row be previewed inline? Driven by the SERVER's probe result+ * (`listSpriteAssets` sets `format`/`width`/`height` only for images it read+ * successfully) rather than by a client-side extension list. Two reasons:+ * a second copy of the extension regex would silently drift from the server's,+ * and a truncated PNG passes any extension test but would render as a broken+ * <img> — here it correctly falls through to the plain file row.*/-export function spritePreviewStyle(cell = 8) {- return { ...checkerboardStyle(cell), ...PIXELATED };-}+export const hasSpritePreview = (asset) => Boolean(asset?.format && asset?.width && asset?.height);diff --git a/client/src/pages/Sprites.jsx b/client/src/pages/Sprites.jsxindex 9330935f57..1d3baef538 100644--- a/client/src/pages/Sprites.jsx+++ b/client/src/pages/Sprites.jsx@@ -8,8 +8,9 @@ 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 AssetInspector, { isImageAsset } from '../components/sprites/AssetInspector.jsx';-import { spriteAssetUrl, spritePreviewStyle } from '../components/sprites/spriteAssets.js';+import AssetInspector from '../components/sprites/AssetInspector.jsx';+import SpritePreview from '../components/sprites/SpritePreview.jsx';+import { hasSpritePreview } from '../components/sprites/spriteAssets.js';import { useAsyncAction } from '../hooks/useAsyncAction.js';import { formatBytes, timeAgo } from '../utils/formatters.js';@@ -249,41 +250,22 @@ 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) => (isImageAsset(a.path) ? (+ {files.map((a) => (<buttonkey={a.path}onClick={() => setInspecting(a)}- className="bg-port-bg border border-port-border rounded p-1 hover:border-port-accent"+ className="bg-port-bg border border-port-border rounded p-1 text-left 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>+ {hasSpritePreview(a) && (+ <SpritePreview recordId={recordId} path={a.path} className="h-20 rounded" />)}+ <span className="block text-[10px] text-gray-500 truncate">{a.path.split('/').pop()}</span>+ <span className="block text-[10px] text-gray-600">+ {hasSpritePreview(a) ? `${a.width}×${a.height}` : formatBytes(a.size)}+ </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>))}diff --git a/server/lib/navManifest.test.js b/server/lib/navManifest.test.jsindex 87324d6762..ec21998dab 100644--- a/server/lib/navManifest.test.js+++ b/server/lib/navManifest.test.js@@ -320,7 +320,7 @@ const NAV_COVERAGE_OPT_OUT = new Map([// Element wrappers that forward to another route rather than render a page. A// NEW redirect wrapper must be added here, or the scanner will treat it as a// real page and (loudly, not silently) demand a nav entry for its route.-const REDIRECT_ELEMENT = /element=\{<\s*(Navigate|RedirectWithSearch|CanonRedirect|UniverseRouteRedirect)\b/;+const REDIRECT_ELEMENT = /element=\{<\s*(Navigate|RedirectWithSearch|PrefixRedirect|CanonRedirect|UniverseRouteRedirect)\b/;// Flatten a stack of (possibly multi-segment, possibly "/") route path pieces// into a single absolute path: ['/', 'media', 'image'] → '/media/image'.diff --git a/server/services/sprites/paths.js b/server/services/sprites/paths.jsindex 3596d2b48b..4511429eb5 100644Binary files a/server/services/sprites/paths.js and b/server/services/sprites/paths.js differdiff --git a/server/services/sprites/pathsAssets.test.js b/server/services/sprites/pathsAssets.test.jsindex 5ef98c097a..7d12e7aeee 100644--- a/server/services/sprites/pathsAssets.test.js+++ b/server/services/sprites/pathsAssets.test.js@@ -48,14 +48,32 @@ describe('listSpriteAssets image metadata', () => {});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.+ // Both degrade to the base shape with no dimensions — but they must stay+ // DISTINGUISHABLE: "sharp tried and failed" carries imageError, "never an+ // image" carries nothing. The inspector words the two differently.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');}+ expect(assets['reference/corrupt.png'].imageError).toBe(true);+ expect(assets['reference/main.generation.json']).not.toHaveProperty('imageError');+ });++ it('reuses the cached probe until the file changes on disk', async () => {+ const spinner = join(recDir, 'reference', 'cached.png');+ await sharp({+ create: { width: 4, height: 4, channels: 4, background: { r: 0, g: 0, b: 0, alpha: 0 } },+ }).png().toFile(spinner);+ expect(byPath(await listSpriteAssets(RECORD))['reference/cached.png'].width).toBe(4);++ // Rewrite at a different size — mtime AND size both move, so the cache key+ // changes and the new dimensions must be picked up rather than served stale.+ await sharp({+ create: { width: 16, height: 16, channels: 4, background: { r: 0, g: 0, b: 0, alpha: 0 } },+ }).png().toFile(spinner);+ expect(byPath(await listSpriteAssets(RECORD))['reference/cached.png'].width).toBe(16);});it('counts pages for an animated image', async () => {