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: surface a missing sprite walk strip as an error instead of a blank card

[._.]/ Adam Eivy98492f929d3c
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.md
index 2eb5e53591..b9b1b03d39 100644
--- a/.changelog/NEXT.md
+++ b/.changelog/NEXT.md
@@ -131,3 +131,4 @@
- **Fix two cross-schema breaks in the sprite detail endpoint that were hiding imported walk data** — `GET /api/sprites/:id` 500'd for every imported character because `getWalkState()`'s run-sort called `.localeCompare()` on `createdAt`, which the ElsewhereAcres source pipeline stamps as a Python epoch-seconds number rather than PortOS's own ISO string; the comparator now normalizes both shapes to milliseconds. Separately, each run's `stripPreview` field is now normalized through the existing `toRecordRelativeAssetPath()` helper (`server/services/sprites/paths.js`, mirroring the same rebase-on-read convention `reference.js` already uses for anchor paths): the source pipeline names the field `stripPreview.path` and anchors it at its own repo root, so PortOS's `stripPreview.stripPath`-reading client 404'd on every animated walk-loop thumbnail even once the 500 was fixed. Neither fix rewrites the imported files on disk — normalization happens in memory at read time, so the importer's hash-verified provenance is untouched. New regression coverage in `walk.test.js`. Filed #2924 to cover the one remaining gap: `pioneer`'s `east` direction was approved from an imagegen-redraw pipeline the grok-video-only walk viewer doesn't model, so it shows "approved" but no animated thumbnail.
- **Accessibility audit pass: switches, icon-only buttons, focus rings, and the media lightbox** — four hand-rolled toggle switches (CoS Dynamic Avatar, Digital Twin ingestion, scheduled backups, Sharing import mode) were announced as plain unlabeled buttons with no on/off state; they now carry `role="switch"` + `aria-checked` + a name. A dozen icon-only buttons gained accessible names (cron cancel, folder "go up", rapid-reader chunk size, JIRA project clear, writing-sample remove, memory-practice mark correct/incorrect, calendar icon picker) and the process/agent expand carets gained `aria-expanded`. Six inputs that set `focus:outline-none` inside an unstyled wrapper were invisible when focused — their containers now carry `focus-within:border-port-accent`, and four standalone selects/buttons gained a `focus-visible` ring. The Sprites asset preview moved from a click-to-dismiss overlay to the shared `<Modal>` (Esc, focus trap, focus restore), and `MediaLightbox` — which deliberately opts out of `<Modal>` — now supplies its own `role="dialog"`/`aria-modal` and focus trap instead of letting Tab walk out into the page behind it. ~20 unlabeled toolbar controls on the highest-traffic pages (Runner, Review, Wiki, Tribe, Loras, Media History, Media Collections, Prompt Manager) gained labels. A new `client/src/a11yConventions.test.js` guard fails the suite if a new hand-rolled full-screen backdrop or an unlabeled toggle-switch button is introduced; the remaining unlabeled-control backlog is tracked in `PLAN.md`.
- **Heal the `grok/` run-path residue that blanked imported sprite walk cycles (migration 203)** — imported characters whose source pipeline anchored run paths at `art-source/sprites/<id>/grok/…` rendered every walk direction's "approved" badge over an empty cell (observed on `pioneer`: 7 of 8 directions blank, only the imagegen-redraw `east` — which never carried a `grok/` segment — animated). Migration 202 physically relocated those runs `grok/` → `runs/` but its `startsWith('grok/')` neutralizer only matched record-relative paths, so it left every repo-anchored `…/sprites/<id>/grok/…` string pointing at the now-nonexistent directory — the read layer stripped the `art-source/…` prefix to `grok/…`, which no longer resolved, so `getWalkState` couldn't find the run behind each direction and the strip-loop preview URL 404'd. New migration `203-heal-imported-grok-run-paths.js` rewrites the leftover `sprites/<id>/grok/` segment to `runs/` (preserving the `art-source/…` provenance prefix and image-byte shas, exactly as 202 preserved its anchoring) across the selection, walk-set, run records, and postprocess manifests, then recomputes the same `runManifestSha256`/`selectionSha256`/`walkSetSha256` cascade so the healed state is internally consistent. Gated to records 202 already moved (`runs/` present, `grok/` gone) that still carry the residue — a self-consistent `grok/`-layout record is left untouched. Non-path strings that merely contain "grok" (`grok-game-animation-frames-run`, `local-postprocess-of-existing-grok-session-video`) are unaffected.
+- **Surface a missing walk strip as an error instead of a silent blank card** — a finalized sprite direction whose packed `…-strip.png` had gone missing on disk (how `pioneer`'s `north`/`west` strips vanished — dropped during a `grok/`→`runs/` relocation while the record still advertised the path) rendered its "approved" badge over an empty cell: `getWalkState`'s native run path handed the client a `stripPreview.stripPath` that 404'd into a blank CSS-`background-image` `StripLoop`, unlike `loadRedrawRun` which already returns null on a missing strip. `getWalkState` now checks the strip on disk (`normalizeMissingStrip`, mirroring the existing `normalizeStaleRendering` read-time normalization — never persisted) and, when absent, surfaces the run as an `error` with `stripMissing: true` + a "regenerate this direction to repack it" message and drops the dangling `stripPath` so `StripLoop`/the trim button don't render it. As defense-in-depth (a background-image fires no `onError`), `StripLoop` also preloads the strip via an `Image` probe and shows an explicit "strip missing" placeholder if it fails to load.
diff --git a/client/src/components/sprites/WalkWorkflow.jsx b/client/src/components/sprites/WalkWorkflow.jsx
index ae5a6b0800..1579dd6802 100644
--- a/client/src/components/sprites/WalkWorkflow.jsx
+++ b/client/src/components/sprites/WalkWorkflow.jsx
@@ -49,6 +49,30 @@ function stripGeometry(stripPreview) {
function StripLoop({ recordId, stripPreview }) {
const { frameCount, fps, height } = stripGeometry(stripPreview);
const scrub = CELL_PX * frameCount;
+ const url = spriteAssetUrl(recordId, stripPreview.stripPath);
+ // The strip paints as a CSS background-image, which fires no onError — a
+ // missing/404 file just renders blank. The server now surfaces a missing
+ // strip as an error run (dropping stripPath so we never get here), but keep a
+ // client-side preload probe as defense-in-depth: a strip that fails to load
+ // for any other reason shows an explicit placeholder instead of a silent gap.
+ const [failed, setFailed] = useState(false);
+ useEffect(() => {
+ setFailed(false);
+ const img = new Image();
+ img.onerror = () => setFailed(true);
+ img.src = url;
+ return () => { img.onerror = null; };
+ }, [url]);
+ if (failed) {
+ return (
+ <div
+ className="border border-port-error/60 rounded flex items-center justify-center text-[9px] leading-tight text-port-error text-center px-1"
+ style={{ width: CELL_PX, height }}
+ >
+ strip missing
+ </div>
+ );
+ }
return (
// 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
@@ -67,7 +91,7 @@ function StripLoop({ recordId, stripPreview }) {
style={{
// Quoted: encodeURIComponent leaves `(`/`)` intact, and an externally
// authored redraw filename containing one would end the url() token early.
- backgroundImage: `url("${spriteAssetUrl(recordId, stripPreview.stripPath)}")`,
+ backgroundImage: `url("${url}")`,
backgroundSize: `${scrub}px ${height}px`,
...PIXELATED,
'--sprite-walk-loop-end': `-${scrub}px`,
diff --git a/client/src/components/sprites/WalkWorkflow.test.jsx b/client/src/components/sprites/WalkWorkflow.test.jsx
index db8427a25a..bb10f3ae5c 100644
--- a/client/src/components/sprites/WalkWorkflow.test.jsx
+++ b/client/src/components/sprites/WalkWorkflow.test.jsx
@@ -87,6 +87,43 @@ describe('WalkWorkflow loop preview', () => {
expect(loop.style.backgroundSize).toBe(`${CELL_PX * 8}px ${CELL_PX}px`);
});
+ // A strip painted as a CSS background-image fires no onError, so a missing/404
+ // file would otherwise render a silent blank box. The server drops the path
+ // for a known-missing strip, but a preload probe is the client-side backstop:
+ // a strip that fails to load shows an explicit placeholder instead of a gap.
+ it('shows a "strip missing" placeholder when the strip fails to load', async () => {
+ const OriginalImage = global.Image;
+ // Simulate the strip 404ing: fire onerror as soon as src is assigned.
+ global.Image = class {
+ set src(_v) { if (this.onerror) queueMicrotask(() => this.onerror()); }
+ };
+ try {
+ render(
+ <MemoryRouter>
+ <WalkWorkflow
+ record={{ id: 'example-walker' }}
+ reference={{ manifest: { mainReference: { locked: true }, anchors: [{ direction: 'east', status: 'locked' }] } }}
+ walk={{
+ runs: [{ id: 'run-east', direction: 'east', status: 'approved', stripPreview: APPROVED_STRIP }],
+ selection: { directions: { east: { status: 'approved', runId: 'run-east' } } },
+ walkSet: null,
+ }}
+ renders={noRenders()}
+ duration={6}
+ onDurationChange={vi.fn()}
+ onGenerate={vi.fn()}
+ onChanged={vi.fn()}
+ />
+ </MemoryRouter>,
+ );
+ expect(await screen.findByText('strip missing')).toBeInTheDocument();
+ // The animated loop is NOT rendered in the failed state.
+ expect(screen.queryByRole('img', { name: 'walk loop preview' })).toBeNull();
+ } finally {
+ global.Image = OriginalImage;
+ }
+ });
+
it('scales the preview box to a non-square cell', () => {
const loop = renderWalk({
stripPath: 'grok/walk-east-abc/generated/strip.png',
diff --git a/server/services/sprites/walk.js b/server/services/sprites/walk.js
index 224ab01fa2..796bf002d1 100644
--- a/server/services/sprites/walk.js
+++ b/server/services/sprites/walk.js
@@ -179,6 +179,31 @@ function normalizeStripPreview(recordId, run) {
return { ...run, stripPreview: { ...run.stripPreview, stripPath } };
}
+// A candidate/approved run's stripPreview names a packed strip PNG on disk. If
+// that file has since gone missing — a botched migration dropped it, a manual
+// cleanup nuked it — the run record still advertises the path, so the native
+// render path (unlike loadRedrawRun, which returns null on a missing strip)
+// hands the client a healthy-looking run and StripLoop paints a blank
+// background-image with no signal that anything is wrong. That's exactly how the
+// pioneer north/west strips vanished silently. Surface it as an error at read
+// time — never persisted — so the card shows the missing-strip message + a
+// regenerate affordance instead of a mystery blank, and drop the dangling
+// stripPath so StripLoop and the trim button don't try to render it. A run with
+// no stripPreview (rendering/postprocessing/pre-package) is untouched.
+async function normalizeMissingStrip(recordId, run) {
+ const stripPath = run?.stripPreview?.stripPath;
+ if (!stripPath) return run;
+ if (await pathExists(join(spriteDir(recordId), stripPath))) return run;
+ const { stripPath: _dropped, ...stripPreviewRest } = run.stripPreview;
+ return {
+ ...run,
+ status: 'error',
+ stripMissing: true,
+ postprocessError: 'Packed walk strip is missing on disk — regenerate this direction to repack it.',
+ stripPreview: stripPreviewRest,
+ };
+}
+
// PortOS stamps `id` on every run record it writes; imported source-pipeline
// records don't carry one at all (see importer.test.js's fixtures). The run
// DIRECTORY is the run id under both layouts, so fall back to it. Two
@@ -347,9 +372,11 @@ export async function getWalkState(recordId) {
// run that somehow exists under both scan roots surfaces once.
.filter((run, i, all) => !resolvedRunIds.has(run.id) && all.findIndex((r) => r.id === run.id) === i);
- const allRuns = [...entryRuns, ...scannedRuns]
- .map(normalizeStaleRendering)
- .sort((a, b) => runCreatedAtMs(b.createdAt) - runCreatedAtMs(a.createdAt));
+ const allRuns = (await Promise.all(
+ [...entryRuns, ...scannedRuns]
+ .map(normalizeStaleRendering)
+ .map((run) => normalizeMissingStrip(recordId, run)),
+ )).sort((a, b) => runCreatedAtMs(b.createdAt) - runCreatedAtMs(a.createdAt));
// Stamp the imported flag so the client reads intent (`walkSet.imported`)
// instead of re-deriving the source-pipeline path convention itself.
const stampedWalkSet = walkSet ? { ...walkSet, imported: isImportedWalkSet(walkSet) } : null;
diff --git a/server/services/sprites/walk.test.js b/server/services/sprites/walk.test.js
index 8f7c1bfd92..4fb71f6e8b 100644
--- a/server/services/sprites/walk.test.js
+++ b/server/services/sprites/walk.test.js
@@ -10,7 +10,7 @@ import { describe, it, expect, vi, beforeEach, afterAll } from 'vitest';
import { mkdtempSync, rmSync } from 'fs';
import { tmpdir } from 'os';
import { join } from 'path';
-import { mkdir, writeFile, readFile } from 'fs/promises';
+import { mkdir, writeFile, readFile, rm } from 'fs/promises';
import { createHash } from 'crypto';
import { lockAllAnchors } from './spriteTestFixtures.js';
@@ -56,10 +56,17 @@ const prepareWalkAnchorChromaInput = vi.fn(async (_anchorAbs, destAbs) => {
await writeFile(destAbs, 'stub-chroma-anchor');
return { preparation: 'composited-over-solid-chroma-matte' };
});
-const runWalkPostprocess = vi.fn(async ({ runRel }) => ({
- manifestPath: `${runRel}/generated/manifest.json`,
- stripPreview: { stripPath: `${runRel}/generated/strip.png`, frameCount: 8, fps: 12, cellWidth: 384, cellHeight: 384, row: 0, startColumn: 0 },
-}));
+const runWalkPostprocess = vi.fn(async ({ runRel, runAbs }) => {
+ // Faithfully land the packed strip on disk (the real postprocess writes it) —
+ // getWalkState's missing-strip guard now flips a candidate whose strip is
+ // absent to an error, so a mock that only returns the path would look broken.
+ await mkdir(join(runAbs, 'generated'), { recursive: true });
+ await writeFile(join(runAbs, 'generated', 'strip.png'), 'packaged-strip-bytes');
+ return {
+ manifestPath: `${runRel}/generated/manifest.json`,
+ stripPreview: { stripPath: `${runRel}/generated/strip.png`, frameCount: 8, fps: 12, cellWidth: 384, cellHeight: 384, row: 0, startColumn: 0 },
+ };
+});
vi.mock('./walkPostprocess.js', async (importOriginal) => {
const actual = await importOriginal();
return {
@@ -115,6 +122,11 @@ async function makeCandidateRun(recordId, direction, { stripBytes = `strip-${dir
chromaKey: '#FF00FF',
createdAt: new Date().toISOString(),
postprocessManifest: manifestRel,
+ // Real candidate records carry the packed-strip preview the UI renders.
+ stripPreview: {
+ stripPath: `runs/${runId}/generated/${stripName}`,
+ frameCount: 8, fps: 12, cellWidth: 384, cellHeight: 384, row: 0, startColumn: 0,
+ },
}));
return { runId, manifestRel };
}
@@ -468,6 +480,43 @@ describe('getWalkState', () => {
expect(runs[0].id).toBe(second.runId);
});
+ // A candidate/approved run whose packed strip PNG has gone missing on disk
+ // (a botched migration or manual cleanup dropped it — how pioneer's north/west
+ // strips silently vanished) must NOT surface as a healthy run: the native
+ // render path otherwise hands the client a stripPath that 404s into a blank
+ // StripLoop. getWalkState surfaces it as an error with stripMissing, drops the
+ // dangling stripPath, and never rewrites the record on disk.
+ it('surfaces a candidate run whose strip is missing on disk as an error', async () => {
+ const id = await characterWithLockedAnchors(newId(), ['east']);
+ const { runId } = await makeCandidateRun(id, 'east');
+ const runRecordPath = join(TEST_ROOT, 'sprites', id, 'runs', runId, 'animation-run.json');
+ const bytesBefore = await readFile(runRecordPath);
+ // Drop the packed strip the record advertises.
+ await rm(join(TEST_ROOT, 'sprites', id, 'runs', runId, 'generated', `${id}-walk-east-strip.png`));
+
+ const { runs } = await getWalkState(id);
+ const run = runs.find((r) => r.id === runId);
+ expect(run.status).toBe('error');
+ expect(run.stripMissing).toBe(true);
+ expect(run.postprocessError).toMatch(/strip is missing/i);
+ // Dangling stripPath is dropped so StripLoop / the trim button don't render it.
+ expect(run.stripPreview.stripPath).toBeUndefined();
+ // Read-time only — the record on disk is untouched.
+ expect(await readFile(runRecordPath)).toEqual(bytesBefore);
+ });
+
+ // A run whose strip IS on disk stays a healthy candidate — the guard only
+ // fires on an actually-missing file, not on every read.
+ it('leaves a candidate run with its strip present untouched', async () => {
+ const id = await characterWithLockedAnchors(newId(), ['east']);
+ const { runId } = await makeCandidateRun(id, 'east');
+ const { runs } = await getWalkState(id);
+ const run = runs.find((r) => r.id === runId);
+ expect(run.status).toBe('candidate');
+ expect(run.stripMissing).toBeUndefined();
+ expect(run.stripPreview.stripPath).toBe(`runs/${runId}/generated/${id}-walk-east-strip.png`);
+ });
+
// Imported run records (issue #2895 importer, ElsewhereAcres source
// pipeline) stamp createdAt as a Python time.time() epoch-seconds float
// and stripPreview as { path: <source-repo-relative> } instead of