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

add Unlock action to revise a finalized sprite walk set

[._.]/ Adam Eivy221b09d0836c
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.md
index 0e47f4a795..c7e110b9a9 100644
--- a/.changelog/NEXT.md
+++ b/.changelog/NEXT.md
@@ -7,6 +7,10 @@
## Sprite Manager
+- **Unlock a finalized walk set to revise it** — a frozen 8-direction walk set was one-way: the "walk set frozen · immutable" badge was the end of the road, and the only way to change a direction was to start a whole new character version. The Walk Cycles panel now offers an **Unlock** button beside that badge (with an inline "Re-open all directions?" confirm). Unlocking removes the frozen set and re-opens every direction back into the generate / regenerate / approve flow — your already-rendered clips are kept on disk, so you can re-approve the ones you like and re-render just the ones you don't; re-approving all eight re-freezes the set exactly as before. Walk sets imported from an external source pipeline (which have no regenerable clips behind them) still can't be unlocked and say so.
+- **The Loop Trimmer auto-plays when you open its tab** — switching to the Loop Trimmer now starts the loop preview animating immediately instead of waiting for a manual Play click; switching the animation source keeps it playing.
+- **The asset inspector is readable again** — clicking an atlas or any sprite asset opens the inspector over a solid card and a darker backdrop, so the metadata (path, dimensions, frame count, size) and the Download / Open / Copy-path buttons no longer have the page bleeding through behind them.
+- **The Directional anchors grid collapses once complete** — while you're building the reference set the "Directional anchors" grid stays open so you can generate and lock each direction, but once all eight are locked it's just static previews of files the "Reference set" browser below already lists (and lets you inspect / download). It now collapses by default when complete — with a one-click toggle to reopen it — so the same anchors no longer read as a duplicate set on the page.
- **[issue-2933] Trim walk loops in a real editor, not a buried 8-checkbox strip** — loop trimming used to be a tiny row of checkboxes tucked inside a walk candidate card, with no way to see what you were doing: no playback, no scrubbing, no frame rate control, no per-frame preview. It's now its own **Loop Trimmer** workspace on the Sprites page, switchable from a tab beside the asset **Library** and deep-linkable (`?spriteTab=trimmer&run=<id>`) so a specific run is shareable and bookmarkable — and "Edit in Loop Trimmer", from either a walk card or an asset tile, jumps straight to it. Pick an animation source (any packaged walk run, plus your previously saved trims for review), play the loop on a checkerboarded canvas or scrub it frame by frame with prev/next and a frame label, tune the frame rate with a live slider, and toggle individual frames on and off from a grid of per-frame thumbnails (disabled frames dim and desaturate, the current frame is outlined) with a live enabled-count and Enable-all / Invert shortcuts. Name the output (it's normalized to a safe `a-z0-9-` slug) and save — the trimmed strip, preview GIF, and manifest paths are surfaced right there, and the source artwork is never touched. The old inline trim panel is gone, so there's exactly one place to trim.
- **[issue-2932] Search the sprite library, and organize it by character / place / object** — the Sprites sidebar used to dump every record as a flat wall of names under just two buckets ("Characters" and "Props"), so a standalone place or object had nowhere to live and a big library was hard to scan. It now leads with a labelled autocomplete search box: type any part of a name, id, or kind and it narrows to a bounded, keyboard-navigable suggestion list (↑/↓ to move, Enter to open, Esc to clear); the full list is one click away behind a **Browse all** disclosure. Records group under **Characters**, **Places**, and **Objects**, and the New button (now **New Sprite**) lets you pick which of those three you're creating. Existing imported prop-atlas families keep working unchanged — they simply show under Objects alongside standalone objects. The reference / walk / publish workflows remain character-only.
- **[issue-2938] Asset badges and Regenerate now reflect approval and backend state, not just the file path** — a walk direction you've already approved now shows its strip, frames, and animation with an **approved** badge instead of "candidate": approval is tracked in the walk selection, and the artwork never moves on disk, so the browser now reads that selection to badge the assets correctly. And a reference candidate's **Regenerate** button is greyed out with the same "No image backend configured" guidance the reference workflow shows when no image backend is set up — so it no longer queues a render that just fails with a toast — and when you do re-roll a candidate, it uses the same backend you picked in the reference workflow above instead of falling back to the install default.
diff --git a/client/src/components/sprites/WalkWorkflow.jsx b/client/src/components/sprites/WalkWorkflow.jsx
index 319a9f6f4f..e721210610 100644
--- a/client/src/components/sprites/WalkWorkflow.jsx
+++ b/client/src/components/sprites/WalkWorkflow.jsx
@@ -1,7 +1,8 @@
import { useEffect, useMemo, useState } from 'react';
-import { Check, Film, RefreshCw, Scissors, Lock } from 'lucide-react';
+import { Check, Film, RefreshCw, Scissors, Lock, Unlock } from 'lucide-react';
import toast from '../ui/Toast';
-import { approveSpriteWalk, postprocessSpriteWalk } from '../../services/apiSprites.js';
+import { approveSpriteWalk, postprocessSpriteWalk, unlockSpriteWalk } from '../../services/apiSprites.js';
+import ConfirmButtonPair from '../ui/ConfirmButtonPair.jsx';
import { useAsyncAction } from '../../hooks/useAsyncAction.js';
import { spriteAssetUrl, checkerboardStyle, PIXELATED } from './spriteAssets.js';
import { WALK_PHASES } from '../../lib/spriteTrimmer.js';
@@ -170,6 +171,11 @@ export default function WalkWorkflow({
const runs = walk?.runs || [];
const selection = walk?.selection || null;
const finalized = Boolean(walk?.walkSet);
+ // A source-pipeline import (#2895) has no regenerable grok clips behind its
+ // frozen set, so the server refuses to unlock it — hide the affordance and
+ // show why rather than offering a button that always 409s. The server stamps
+ // this flag on the walk state so the client doesn't re-derive the path convention.
+ const importedWalkSet = Boolean(walk?.walkSet?.imported);
// direction → jobId for in-flight video renders. The hook instance is owned
// by the Sprites page and shared with the asset collection (#2931) so both
@@ -230,6 +236,17 @@ export default function WalkWorkflow({
onChanged();
}, { errorMessage: 'Postprocess failed' });
+ // Unlock (un-freeze) the finalized walk set. Irreversible-ish (it re-opens
+ // every direction), so it's gated behind an inline confirm per the repo's
+ // confirmation UX — not a hidden two-click arm or a browser dialog.
+ const [unlockConfirm, setUnlockConfirm] = useState(false);
+ const [unlock, unlocking] = useAsyncAction(async () => {
+ await unlockSpriteWalk(recordId, { silent: true });
+ setUnlockConfirm(false);
+ toast.success('Walk set unlocked — directions are editable again');
+ onChanged();
+ }, { errorMessage: 'Unlock failed' });
+
// The walk workflow only becomes actionable once the main is frozen (the
// south anchor IS the main); hide it entirely before that.
if (!manifest?.mainReference?.locked) return null;
@@ -248,9 +265,36 @@ export default function WalkWorkflow({
</span>
</h3>
{finalized ? (
- <p className="text-xs text-port-success flex items-center gap-1">
- <Lock className="w-3 h-3" /> walk set frozen · immutable
- </p>
+ <div className="flex items-center gap-2">
+ <p className="text-xs text-port-success flex items-center gap-1">
+ <Lock className="w-3 h-3" /> walk set frozen · immutable
+ </p>
+ {importedWalkSet ? (
+ <span className="text-[10px] text-gray-500" title="Imported from the source pipeline — no regenerable clips">
+ imported · new version to revise
+ </span>
+ ) : unlockConfirm ? (
+ <ConfirmButtonPair
+ prompt="Re-open all directions?"
+ confirmText="Unlock"
+ confirmIcon={Unlock}
+ busy={unlocking}
+ busyText="Unlocking…"
+ tone="warning"
+ ariaLabel="Confirm unlock walk set"
+ onConfirm={() => unlock()}
+ onCancel={() => setUnlockConfirm(false)}
+ />
+ ) : (
+ <button
+ onClick={() => setUnlockConfirm(true)}
+ title="Un-freeze the walk set to regenerate or re-approve directions (rendered clips are kept)"
+ className="flex items-center gap-1 px-1.5 py-0.5 text-xs bg-port-bg border border-port-border rounded text-gray-400 hover:border-port-accent hover:text-white"
+ >
+ <Unlock className="w-3 h-3" /> Unlock
+ </button>
+ )}
+ </div>
) : (
<label className="flex items-center gap-2 text-xs text-gray-400">
Clip length
diff --git a/client/src/components/ui/ConfirmButtonPair.jsx b/client/src/components/ui/ConfirmButtonPair.jsx
index 3e7b6f813c..e6b0c45767 100644
--- a/client/src/components/ui/ConfirmButtonPair.jsx
+++ b/client/src/components/ui/ConfirmButtonPair.jsx
@@ -7,10 +7,11 @@ import { Loader2 } from 'lucide-react';
//
// Tones pre-compose full Tailwind class names — the JIT scans for complete
// tokens, so `bg-port-${tone}/20` would NOT generate the utility. Spell it out.
-// Only `error` ships today (every confirm pair is destructive); add a map entry
-// when a non-destructive tone is actually needed.
+// `error` for destructive confirms; `warning` for expensive-but-safe confirms
+// (e.g. unlocking a frozen walk set) where the action isn't destructive.
const TONES = {
error: 'bg-port-error/20 text-port-error hover:bg-port-error/30',
+ warning: 'bg-port-warning/20 text-port-warning hover:bg-port-warning/30',
};
export default function ConfirmButtonPair({
diff --git a/client/src/services/apiSprites.js b/client/src/services/apiSprites.js
index adf2779007..d81803191e 100644
--- a/client/src/services/apiSprites.js
+++ b/client/src/services/apiSprites.js
@@ -66,6 +66,11 @@ export const postprocessSpriteWalk = (id, body, options = {}) => request(`/sprit
method: 'POST', body: JSON.stringify(body), ...options,
});
+// Un-freeze a finalized walk set so its directions can be regenerated/re-approved.
+export const unlockSpriteWalk = (id, options = {}) => request(`/sprites/${encodeURIComponent(id)}/walk/unlock`, {
+ method: 'POST', ...options,
+});
+
// Save a non-destructive loop trim (strip + GIF + manifest, versioned).
export const trimSpriteWalk = (id, body, options = {}) => request(`/sprites/${encodeURIComponent(id)}/walk/trim`, {
method: 'POST', body: JSON.stringify(body), ...options,
diff --git a/server/routes/sprites.js b/server/routes/sprites.js
index 00777f4d9a..fbf3ffa01e 100644
--- a/server/routes/sprites.js
+++ b/server/routes/sprites.js
@@ -37,7 +37,7 @@ import {
getReferenceSet, startReferenceGeneration, lockReference, patchSpriteRecord,
} from '../services/sprites/reference.js';
import {
- getWalkState, startWalkGeneration, approveWalkDirection, rerunWalkPostprocess,
+ getWalkState, startWalkGeneration, approveWalkDirection, rerunWalkPostprocess, unlockWalkSet,
} from '../services/sprites/walk.js';
import { saveLoopTrim } from '../services/sprites/walkTrims.js';
import { compileAtlas, getAtlasState } from '../services/sprites/atlas.js';
@@ -128,6 +128,13 @@ router.post('/:id/walk/approve', asyncHandler(async (req, res) => {
res.json(await approveWalkDirection(req.params.id, body));
}));
+// Un-freeze a finalized walk set so it can be revised in place (#2933
+// follow-up): removes the frozen walk-set file and re-opens every direction,
+// preserving the rendered clips. 409s a legacy source-pipeline import. No body.
+router.post('/:id/walk/unlock', asyncHandler(async (req, res) => {
+ res.json(await unlockWalkSet(req.params.id));
+}));
+
// Re-run the deterministic postprocess for a run whose video already landed
// (crash recovery / determinism verification). No AI call involved.
router.post('/:id/walk/postprocess', asyncHandler(async (req, res) => {
diff --git a/server/services/sprites/atlas.js b/server/services/sprites/atlas.js
index 7c6c3e28a4..5395263ca3 100644
--- a/server/services/sprites/atlas.js
+++ b/server/services/sprites/atlas.js
@@ -40,7 +40,7 @@ import {
sampleBorderKey, validateMeasuredKey, recoverAlphaFrame, despillKeyFrame,
alphaBbox, compositeOnto, sha256Buffer,
} from './walkPostprocess.js';
-import { withWalkWriteTail, walkSetRelPath } from './walk.js';
+import { withWalkWriteTail, walkSetRelPath, isImportedWalkSet } from './walk.js';
// Player atlas contract (source pipeline runtime_publish.py): 96px cells,
// pivot (48,88) — silhouette centered on x=48, feet on the y=88 ground line —
@@ -188,12 +188,9 @@ export async function validateForCompile(recordId) {
// frames/ to minimize copies). Recompiling them here is structurally
// impossible; say so plainly instead of a misleading tamper error. Their
// already-published runtime atlases were imported and remain browsable.
- // Match the importer's own legacy-path recognition (relToCharacterDir):
- // the marker can sit at any index (absolute/repo-prefixed variants), not
- // just the string start.
- if (
- typeof walkSet.selectionPath === 'string' && walkSet.selectionPath.includes('art-source/sprites/')
- ) {
+ // Shared predicate (walk.js) so this recompile guard and unlockWalkSet's
+ // stay in lockstep on what counts as a legacy import.
+ if (isImportedWalkSet(walkSet)) {
throw new ServerError(
'This walk set was imported from the source pipeline — its packaged frames were not imported, so PortOS cannot recompile it. Imported runtime atlases remain available in the asset library; to compile here, run the walk workflow on a new character.',
{ status: 409, code: 'LEGACY_IMPORTED_WALK_SET' },
diff --git a/server/services/sprites/walk.js b/server/services/sprites/walk.js
index 8d783bb260..1e3bfa8e6f 100644
--- a/server/services/sprites/walk.js
+++ b/server/services/sprites/walk.js
@@ -18,7 +18,7 @@
*/
import { join } from 'path';
-import { copyFile, readdir } from 'fs/promises';
+import { copyFile, readdir, rm } from 'fs/promises';
import { randomUUID } from 'crypto';
import {
PATHS, ensureDir, atomicWrite, readJSONFile, pathExists, sha256File,
@@ -58,6 +58,19 @@ async function loadWalkSet(recordId) {
return readJSONFile(join(spriteDir(recordId), walkSetRelPath(recordId)), null);
}
+// A phase-1 imported walk set (#2895) is copied verbatim from the source
+// pipeline: its selectionPath is repo-root-anchored (`art-source/sprites/…`)
+// and its packaged per-frame PNGs were never imported. Such a set has no
+// regenerable clips behind it, so it can neither be recompiled (atlas.js) nor
+// unlocked (unlockWalkSet) — both surface `LEGACY_IMPORTED_WALK_SET`. Single
+// source of truth for the marker so the three call sites (here, atlas.js, and
+// the client via the getWalkState flag) can't drift. The marker can sit at any
+// index (absolute/repo-prefixed variants), matching the importer's own
+// relToCharacterDir recognition — hence `includes`, not a prefix test.
+export const isImportedWalkSet = (walkSet) => (
+ typeof walkSet?.selectionPath === 'string' && walkSet.selectionPath.includes('art-source/sprites/')
+);
+
async function loadSelection(recordId) {
return readJSONFile(join(spriteDir(recordId), selectionRelPath(recordId)), null);
}
@@ -278,7 +291,10 @@ export async function getWalkState(recordId) {
const allRuns = [...entryRuns, ...scannedRuns]
.sort((a, b) => runCreatedAtMs(b.createdAt) - runCreatedAtMs(a.createdAt));
- return { runs: allRuns, selection, walkSet };
+ // 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;
+ return { runs: allRuns, selection, walkSet: stampedWalkSet };
}
/**
@@ -488,6 +504,57 @@ export function approveWalkDirection(recordId, args) {
return walkWriteTail(recordId, () => approveWalkDirectionImpl(recordId, args));
}
+/**
+ * Unlock (un-freeze) a finalized walk set so it can be revised in place.
+ *
+ * The finalized walk set is normally one-way — `requireUnfinalized` 409s every
+ * mutating walk op while `walk/<id>-walk-set-v1.json` exists — with "a new
+ * character version" as the only escape. This gives the single user a
+ * deliberate way back to the editable state (#2933 follow-up): it removes the
+ * frozen walk-set file and resets the per-direction selection to in-progress,
+ * so every direction returns to the generate/regenerate/approve flow with its
+ * already-rendered clips preserved on disk (the `grok/<runId>/` run records are
+ * never touched). Re-approving all 8 directions re-freezes the set exactly as
+ * the original finalize did. The record status drops back to
+ * `reference-complete` (all anchors locked, walk in progress).
+ *
+ * Legacy source-pipeline imports (#2895) are refused: their walk set was copied
+ * byte-for-byte from `art-source/sprites/` with no `grok/` candidate runs behind
+ * it, so unlocking would strand the record with nothing to regenerate from —
+ * the same reason atlas.js refuses to recompile them (#2918).
+ */
+export function unlockWalkSet(recordId) {
+ return walkWriteTail(recordId, () => unlockWalkSetImpl(recordId));
+}
+
+async function unlockWalkSetImpl(recordId) {
+ await requireCharacter(recordId);
+ const walkSet = await loadWalkSet(recordId);
+ if (!walkSet) {
+ throw new ServerError('No finalized walk set to unlock', { status: 409, code: 'WALK_SET_NOT_FINAL' });
+ }
+ if (isImportedWalkSet(walkSet)) {
+ throw new ServerError(
+ 'This walk set was imported from the source pipeline and has no regenerable clips — unlocking is not supported. Create a new character version to revise it.',
+ { status: 409, code: 'LEGACY_IMPORTED_WALK_SET' },
+ );
+ }
+ // Order mirrors finalize's inverse: drop the canonical "finalized" signal
+ // (the walk-set file) first so a crash mid-unlock can only leave a cosmetic
+ // stale record status, never a walk-complete record with no frozen set.
+ await rm(join(spriteDir(recordId), walkSetRelPath(recordId)), { force: true });
+ // Reset the selection to in-progress: with the walk set gone `finalized` is
+ // false, but each direction still reads `approved` from the selection, which
+ // keeps the generate/regenerate buttons gated off. Seeding a fresh selection
+ // re-opens every direction; the rendered runs remain, so re-approval is a
+ // single click per direction the user is happy with. (atomicWrite ensures the
+ // walk/ dir, which already exists since we just removed the walk-set file.)
+ await atomicWrite(join(spriteDir(recordId), selectionRelPath(recordId)), seedSelection(recordId));
+ await updateRecord(recordId, { status: 'reference-complete' });
+ console.log(`🔓 sprite walk set unlocked for ${recordId}`);
+ return getWalkState(recordId);
+}
+
async function approveWalkDirectionImpl(recordId, { direction, runId }) {
await requireCharacter(recordId);
await requireUnfinalized(recordId);
diff --git a/server/services/sprites/walk.test.js b/server/services/sprites/walk.test.js
index cd1daba696..b8efe544d0 100644
--- a/server/services/sprites/walk.test.js
+++ b/server/services/sprites/walk.test.js
@@ -69,7 +69,7 @@ const records = await import('./records.js');
const { listSpriteAssets } = await import('./paths.js');
const { lockReference } = await import('./reference.js');
const {
- getWalkState, startWalkGeneration, attachWalkVideo, approveWalkDirection, rerunWalkPostprocess,
+ getWalkState, startWalkGeneration, attachWalkVideo, approveWalkDirection, rerunWalkPostprocess, unlockWalkSet,
} = await import('./walk.js');
const { SPRITE_DIRECTIONS, ANCHOR_DIRECTIONS } = await import('./prompts.js');
@@ -345,6 +345,55 @@ describe('approveWalkDirection', () => {
});
});
+describe('unlockWalkSet', () => {
+ async function finalizedCharacter() {
+ const id = await characterWithLockedAnchors(newId(), ANCHOR_DIRECTIONS);
+ for (const direction of SPRITE_DIRECTIONS) {
+ const { runId } = await makeCandidateRun(id, direction);
+ await approveWalkDirection(id, { direction, runId });
+ }
+ return id;
+ }
+
+ it('409s when there is no finalized walk set', async () => {
+ const id = await characterWithLockedAnchors(newId(), ['east']);
+ await expect(unlockWalkSet(id)).rejects.toMatchObject({ code: 'WALK_SET_NOT_FINAL' });
+ });
+
+ it('un-freezes the set, re-opens every direction, and reverts the record status', async () => {
+ const id = await finalizedCharacter();
+ expect((await records.getRecord(id)).status).toBe('walk-complete');
+
+ const state = await unlockWalkSet(id);
+ // The frozen set is gone and the selection is back to an editable, empty set.
+ expect(state.walkSet).toBeNull();
+ expect(state.selection.status).toBe('in-progress');
+ expect(state.selection.directions).toEqual({});
+ expect((await records.getRecord(id)).status).toBe('reference-complete');
+
+ // Regeneration/approval is allowed again (no WALK_SET_FINAL), and the
+ // already-rendered clips remain on disk to re-approve.
+ const { runId } = await makeCandidateRun(id, 'east');
+ const reapproved = await approveWalkDirection(id, { direction: 'east', runId });
+ expect(reapproved.selection.directions.east.status).toBe('approved');
+ });
+
+ it('refuses to unlock a legacy source-pipeline import', async () => {
+ const id = await characterWithLockedAnchors(newId(), ['east']);
+ await mkdir(join(TEST_ROOT, 'sprites', id, 'walk'), { recursive: true });
+ await writeFile(join(TEST_ROOT, 'sprites', id, 'walk', `${id}-walk-set-v1.json`), JSON.stringify({
+ schemaVersion: 1,
+ kind: 'finalized-eight-direction-walk-set',
+ characterId: id,
+ status: 'final',
+ // The importer copies this source-repo-anchored, which marks it legacy.
+ selectionPath: `art-source/sprites/${id}/walk/${id}-walk-selection-v1.json`,
+ directions: {},
+ }));
+ await expect(unlockWalkSet(id)).rejects.toMatchObject({ code: 'LEGACY_IMPORTED_WALK_SET' });
+ });
+});
+
describe('listSpriteAssets run-intermediate exclusion', () => {
it('omits raw extraction frames but keeps packaged frames and the review sheet', async () => {
const id = await characterWithLockedAnchors(newId(), []);