Skip to content

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

fix([issue-2930]): address review — keep video playback, gate previews on renderable formats

[._.]/ Adam Eivyc1386a2f648c
diff --git a/client/src/App.jsx b/client/src/App.jsx
index 3307369c90..4af6c959c8 100644
--- a/client/src/App.jsx
+++ b/client/src/App.jsx
@@ -350,16 +350,16 @@ export default function App() {
<Route path="universe-builder/:universeId" element={<UniverseRouteRedirect fromPrefix={/^\/media\/universe-builder/} />} />
<Route path="universe-builder/:universeId/canon" element={<UniverseRouteRedirect fromPrefix={/^\/media\/universe-builder/} canon />} />
</Route>
- {/* Creative Director — a top-level Create page (moved out of the
- Media Gen tabs). :id with no tab redirects to the overview tab,
- carrying any query string + hash (relative Navigate preserves the
- :id in the path) so a deep-link like /creative-director/abc?x#y
- lands 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 />} />
+ {/* Creative Director — a top-level Create page (moved out of the
+ Media Gen tabs). :id with no tab redirects to the overview tab,
+ carrying any query string + hash (relative Navigate preserves the
+ :id in the path) so a deep-link like /creative-director/abc?x#y
+ lands on /creative-director/abc/overview?x#y intact. */}
<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/sprites/AssetInspector.jsx b/client/src/components/sprites/AssetInspector.jsx
index 67fcca23a9..0359177f58 100644
--- a/client/src/components/sprites/AssetInspector.jsx
+++ b/client/src/components/sprites/AssetInspector.jsx
@@ -9,10 +9,10 @@
* handling, focus trap, and focus restore to the thumbnail that opened it.
*/
-import { Download, ClipboardCopy, X } from 'lucide-react';
+import { Download, ClipboardCopy, ExternalLink, X } from 'lucide-react';
import Modal from '../ui/Modal.jsx';
import SpritePreview from './SpritePreview.jsx';
-import { spriteAssetUrl, hasSpritePreview } from './spriteAssets.js';
+import { spriteAssetUrl, hasSpritePreview, isVideoAsset } from './spriteAssets.js';
import { formatBytes, timeAgo } from '../../utils/formatters.js';
import { copyToClipboard } from '../../lib/clipboard.js';
@@ -58,6 +58,11 @@ export default function AssetInspector({ recordId, asset, onClose }) {
cell={10}
loading="eager"
/>
+ ) : isVideoAsset(asset) ? (
+ // A walk run's grok source clip lives in the listing; play it here
+ // rather than forcing a download just to review a render.
+ // eslint-disable-next-line jsx-a11y/media-has-caption
+ <video src={url} controls className="w-full max-h-[55vh] bg-port-bg rounded border border-port-border" />
) : (
<p className="text-xs text-gray-500 border border-port-border rounded p-4 text-center">
{/* `imageError` distinguishes "PortOS tried and failed" from "this
@@ -65,7 +70,7 @@ export default function AssetInspector({ recordId, asset, onClose }) {
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.'}
+ : 'No inline preview for this file type — use Open to view it.'}
</p>
)}
@@ -86,6 +91,16 @@ export default function AssetInspector({ recordId, asset, onClose }) {
>
<Download className="w-3.5 h-3.5" /> Download
</a>
+ {/* `download` forces a save, so Download alone can't replace the
+ open-in-a-tab the non-image rows used to have. */}
+ <a
+ href={url}
+ target="_blank"
+ rel="noreferrer"
+ 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"
+ >
+ <ExternalLink className="w-3.5 h-3.5" /> Open
+ </a>
<button
type="button"
onClick={() => copyToClipboard(asset.path, 'Asset path copied')}
diff --git a/client/src/components/sprites/AssetInspector.test.jsx b/client/src/components/sprites/AssetInspector.test.jsx
index 8f95fdf504..4e516191b8 100644
--- a/client/src/components/sprites/AssetInspector.test.jsx
+++ b/client/src/components/sprites/AssetInspector.test.jsx
@@ -36,6 +36,13 @@ describe('hasSpritePreview', () => {
expect(hasSpritePreview({ path: 'a.json', size: 3 })).toBe(false);
expect(hasSpritePreview(null)).toBe(false);
});
+
+ it('rejects a format sharp can probe but a browser cannot paint', () => {
+ // TIFF probes cleanly and yields real dimensions, so a probe-presence check
+ // alone would render a broken-image icon.
+ expect(hasSpritePreview({ path: 'a.tiff', width: 8, height: 8, format: 'tiff' })).toBe(false);
+ expect(hasSpritePreview({ path: 'a.webp', width: 8, height: 8, format: 'webp' })).toBe(true);
+ });
});
describe('AssetInspector', () => {
@@ -89,6 +96,32 @@ describe('AssetInspector', () => {
expect(screen.getByRole('link', { name: /download/i })).toBeInTheDocument();
});
+ it('plays a walk run source clip inline instead of forcing a download', () => {
+ const { container } = render(
+ <AssetInspector
+ recordId="trail-hand"
+ asset={{ path: 'grok/walk-east-abc/generated/source-video.mp4', size: 900, mtime: Date.now() }}
+ onClose={() => {}}
+ />,
+ );
+ const video = container.querySelector('video');
+ expect(video).toHaveAttribute('src', '/data/sprites/trail-hand/grok/walk-east-abc/generated/source-video.mp4');
+ expect(video).toHaveAttribute('controls');
+ });
+
+ it('offers Open alongside Download, since download= forces a save', () => {
+ render(
+ <AssetInspector
+ recordId="trail-hand"
+ asset={{ path: 'reference/main.generation.json', size: 12, mtime: Date.now() }}
+ onClose={() => {}}
+ />,
+ );
+ const open = screen.getByRole('link', { name: /^open$/i });
+ expect(open).toHaveAttribute('target', '_blank');
+ expect(open).not.toHaveAttribute('download');
+ });
+
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/WalkWorkflow.jsx b/client/src/components/sprites/WalkWorkflow.jsx
index 349579d022..f1b38935c1 100644
--- a/client/src/components/sprites/WalkWorkflow.jsx
+++ b/client/src/components/sprites/WalkWorkflow.jsx
@@ -53,8 +53,10 @@ function StripLoop({ recordId, stripPreview }) {
// 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.
+ // `overflow-hidden` matters: the strip is painted by the INNER div, whose
+ // corners are square, so without clipping it covers the rounded corners.
<div
- className="border border-port-border rounded"
+ className="border border-port-border rounded overflow-hidden"
style={{ width: CELL_PX, height, ...checkerboardStyle(6) }}
>
<div
diff --git a/client/src/components/sprites/spriteAssets.js b/client/src/components/sprites/spriteAssets.js
index 7d49aff853..fbcae2ac66 100644
--- a/client/src/components/sprites/spriteAssets.js
+++ b/client/src/components/sprites/spriteAssets.js
@@ -38,12 +38,28 @@ export function checkerboardStyle(cell = 6) {
// constant, and every consumer treats React style props as read-only.
export const PIXELATED = Object.freeze({ imageRendering: 'pixelated' });
+// sharp can probe more formats than a browser can paint — a TIFF yields clean
+// metadata but renders as a broken-image icon in Chrome/Firefox. So the server
+// probe list (for metadata) and this list (for "can I put it in an <img>") are
+// deliberately different sets, not duplicates of each other.
+const RENDERABLE_FORMATS = new Set(['png', 'gif', 'webp', 'jpeg', 'jpg', 'svg']);
+
/**
- * 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.
+ * Can this asset row be previewed inline as an image? Driven by the SERVER's
+ * probe result (`listSpriteAssets` sets `format`/`width`/`height` only for
+ * images it read successfully) rather than by a client-side copy of the
+ * extension regex — that copy would silently drift, and a truncated PNG passes
+ * any extension test while rendering as a broken <img>. The extra
+ * RENDERABLE_FORMATS gate covers the opposite case: probed fine, but the
+ * browser still can't paint it.
*/
-export const hasSpritePreview = (asset) => Boolean(asset?.format && asset?.width && asset?.height);
+export const hasSpritePreview = (asset) => Boolean(
+ asset?.width && asset?.height && RENDERABLE_FORMATS.has(asset.format),
+);
+
+// Walk runs keep their grok i2v source clip (`generated/source-video.mp4`) in
+// the listing, so the inspector plays it inline rather than making the user
+// download it just to review a render.
+const VIDEO_EXT = /\.(mp4|webm|mov|m4v)$/i;
+
+export const isVideoAsset = (asset) => VIDEO_EXT.test(asset?.path || '');
diff --git a/server/services/sprites/pathsAssets.test.js b/server/services/sprites/pathsAssets.test.js
index 7d12e7aeee..7c01432fc2 100644
--- a/server/services/sprites/pathsAssets.test.js
+++ b/server/services/sprites/pathsAssets.test.js
@@ -6,7 +6,9 @@
* PATHS mock) and this suite needs a real tmpdir sprite tree.
*/
-import { describe, it, expect, afterAll, vi } from 'vitest';
+import {
+ describe, it, expect, afterAll, beforeEach, vi,
+} from 'vitest';
import { mkdtempSync, rmSync } from 'fs';
import { tmpdir } from 'os';
import { join } from 'path';
@@ -21,7 +23,12 @@ vi.mock('../../lib/fileUtils.js', async (importOriginal) => {
return actual;
});
-const { listSpriteAssets } = await import('./paths.js');
+const { listSpriteAssets, __resetSpriteMetadataCache } = await import('./paths.js');
+
+// Fixtures are rewritten in place within one suite run, so mtime+size could in
+// principle collide at coarse filesystem timestamp granularity — clear the
+// probe cache between tests so no assertion depends on that resolution.
+beforeEach(() => __resetSpriteMetadataCache());
afterAll(() => rmSync(TEST_ROOT, { recursive: true, force: true }));