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
fix([issue-2938]): badge approved sprite runs and gate anchor re-roll on backend state
[._.]/ Adam Eivy4b1f355e6fa8
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.mdindex bc93d0030c..87bded7af2 100644--- a/.changelog/NEXT.md+++ b/.changelog/NEXT.md@@ -7,6 +7,7 @@## Sprite Manager+- **[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.- **[issue-2931] A character's assets now group by what they are, and you can act on them in place** — the asset browser used to be a flat dump grouped by folder name (`reference`, `grok`, `runtime`), with every tile inert. Assets are now grouped by their actual role — reference set, strips, animations, frames, atlases, review evidence, manifests — and each one carries a status badge (runtime · approved · candidate · superseded · rejected · source), so you can see at a glance which reference version is current and which have been replaced. Walk strips, frames and animations gain two buttons: **Regenerate**, which re-runs that direction's render, and **Edit in Loop Trimmer**, which jumps straight to the trimmer for that run — including for a direction you've already approved, since trims are saved separately and never overwrite the approved artwork. Regenerate is correctly greyed out when the walk set is finalized, when the direction is already approved, when its reference anchor isn't locked yet, or while a render for it is already running — and it now shares one in-flight view with the workflow panels above, so starting a render in one place immediately disables it in the other instead of letting you pay for the same render twice. An unlocked reference candidate can be re-rolled the same way. Switching between characters no longer carries a stale "Rendering…" state across from the previous one.- **[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-2928] Show walk previews for every imported run layout, not just one** — the walk viewer found a character's animation runs by looking in a single fixed folder, so an imported character whose source pipeline filed its runs elsewhere showed the same blank "approved ✓" card that #2924 just fixed for redraw directions. Each approved direction is now looked up by where its own approval record says its run lives, so any layout the importer produces animates. Unapproved candidates and in-flight generations still appear as before.diff --git a/client/src/components/sprites/AssetCollection.jsx b/client/src/components/sprites/AssetCollection.jsxindex 05c9b21c4f..4cc43d95fc 100644--- a/client/src/components/sprites/AssetCollection.jsx+++ b/client/src/components/sprites/AssetCollection.jsx@@ -103,10 +103,29 @@ function AssetCard({ recordId, asset, actions, onInspect }) {* reference workflow to re-fire). Shape:* { regenerateFor(asset) → { run, disabled, pending, title, kind } | null,* trimFor(asset) → { run } | null }+ *+ * `approvedRunIds` (#2938) is the set of run ids the walk selection has+ * approved. A run's strip/frames never move on approval — approval lives in+ * `walk.selection.directions[dir]`, not the path — so `spriteFacets.js` (a pure+ * PATH classifier) still reads their status as `candidate`. This is the ONE+ * facet that needs the record's live selection state, so the enrichment lands+ * here in the caller: an asset whose `runId` is an approved run is promoted to+ * `approved` for its badge, keeping the classifier free of workflow state.*/-export default function AssetCollection({ recordId, assets, actions = null }) {+export default function AssetCollection({ recordId, assets, actions = null, approvedRunIds }) {const [inspecting, setInspecting] = useState(null);- const groups = useMemo(() => groupSpriteAssetsByRole(assets), [assets]);+ const groups = useMemo(() => {+ const grouped = groupSpriteAssetsByRole(assets);+ if (!approvedRunIds || approvedRunIds.size === 0) return grouped;+ return grouped.map((group) => ({+ ...group,+ assets: group.assets.map((row) => (+ row.facets.status === 'candidate' && row.facets.runId && approvedRunIds.has(row.facets.runId)+ ? { ...row, facets: { ...row.facets, status: 'approved' } }+ : row+ )),+ }));+ }, [assets, approvedRunIds]);return (<div className="space-y-4">diff --git a/client/src/components/sprites/AssetCollection.test.jsx b/client/src/components/sprites/AssetCollection.test.jsxindex ded7a50252..f465bf46bb 100644--- a/client/src/components/sprites/AssetCollection.test.jsx+++ b/client/src/components/sprites/AssetCollection.test.jsx@@ -59,6 +59,27 @@ describe('AssetCollection grouping', () => {render(<AssetCollection recordId="example-walker" assets={[]} />);expect(screen.queryAllByRole('heading', { level: 4 })).toHaveLength(0);});++ it('keeps an unapproved run\'s strip badged `candidate` (#2938)', () => {+ render(<AssetCollection recordId="example-walker" assets={ASSETS} />);+ const stripGroup = screen.getByRole('heading', { name: /Strips/ }).parentElement;+ expect(within(stripGroup).getByText('candidate')).toBeTruthy();+ });++ it('promotes an approved run\'s assets to `approved` from the walk selection (#2938)', () => {+ // The strip path is unchanged by approval — the pure classifier still reads+ // it as `candidate`; the approvedRunIds set is what promotes the badge.+ render(+ <AssetCollection+ recordId="example-walker"+ assets={ASSETS}+ approvedRunIds={new Set(['walk-east-abc12345'])}+ />,+ );+ const stripGroup = screen.getByRole('heading', { name: /Strips/ }).parentElement;+ expect(within(stripGroup).getByText('approved')).toBeTruthy();+ expect(within(stripGroup).queryByText('candidate')).toBeNull();+ });});describe('AssetCollection inline actions', () => {diff --git a/client/src/components/sprites/ReferenceWorkflow.jsx b/client/src/components/sprites/ReferenceWorkflow.jsxindex 4082c979c3..5061141c2f 100644--- a/client/src/components/sprites/ReferenceWorkflow.jsx+++ b/client/src/components/sprites/ReferenceWorkflow.jsx@@ -1,9 +1,7 @@-import { useEffect, useMemo, useRef, useState } from 'react';+import { useMemo, useRef, useState } from 'react';import { Lock, Sparkles, RefreshCw, Upload } from 'lucide-react';import toast from '../ui/Toast';import { generateSpriteReference, lockSpriteReference, updateSpriteRecord } from '../../services/apiSprites.js';-import { getSettings } from '../../services/apiSystem.js';-import { deriveAvailableBackends } from '../../lib/imageGenBackends.js';import { useAsyncAction } from '../../hooks/useAsyncAction.js';import SpritePreview from './SpritePreview.jsx';@@ -65,15 +63,17 @@ function CandidateTile({ recordId, candidate, locking, onLock, clipRisk }) {);}-export default function ReferenceWorkflow({ record, reference, renders, onChanged }) {+export default function ReferenceWorkflow({ record, reference, renders, backends, mode, onModeChange, onChanged }) {const recordId = record.id;const manifest = reference?.manifest || null;const candidates = reference?.candidates || [];const mainLocked = manifest?.mainReference?.locked === true;- // null = settings not loaded yet; [] = loaded, no queue backend configured.- const [backends, setBackends] = useState(null);- const [mode, setMode] = useState('');+ // Image-backend availability + the selected `mode` are page-owned (#2938) so+ // that the Sprites page's asset-card Regenerate re-rolls through the SAME+ // backend this picker drives (a per-component fetch would let the two+ // diverge). `backends`: null = settings not loaded yet; [] = loaded, no+ // backend configured.const [designPrompt, setDesignPrompt] = useState(manifest?.designPrompt || '');const [uploadFile, setUploadFile] = useState(null);const fileInputRef = useRef(null);@@ -82,20 +82,6 @@ export default function ReferenceWorkflow({ record, reference, renders, onChange// on one map — see the matching note in WalkWorkflow.const { pendingJobs, beginSubmit, resolveSubmit, cancelSubmit } = renders;- useEffect(() => {- getSettings({ silent: true })- .then((settings) => {- const available = deriveAvailableBackends(settings, { excludeExternal: true });- setBackends(available);- // Prefer the configured dispatcher default when it's available —- // defaulting to the first list entry would silently send an explicit- // `local` override on installs configured for codex/grok.- const configured = available.find((b) => b.id === settings?.imageGen?.mode)?.id;- setMode((m) => m || configured || available[0]?.id || '');- })- .catch(() => setBackends([]));- }, []);-const candidatesByTarget = useMemo(() => candidates.reduce((acc, c) => {const t = c.target || 'main';(acc[t] ||= []).push(c);@@ -159,7 +145,7 @@ export default function ReferenceWorkflow({ record, reference, renders, onChangeBackend<selectvalue={mode}- onChange={(e) => setMode(e.target.value)}+ onChange={(e) => onModeChange(e.target.value)}className="bg-port-bg border border-port-border rounded px-2 py-1 text-sm text-white">{backends.map((b) => <option key={b.id} value={b.id}>{b.label || b.id}</option>)}diff --git a/client/src/lib/spriteCollectionActions.js b/client/src/lib/spriteCollectionActions.jsindex 178d3fcce5..2612743631 100644--- a/client/src/lib/spriteCollectionActions.js+++ b/client/src/lib/spriteCollectionActions.js@@ -14,10 +14,12 @@* The gating deliberately TRACKS the authoritative workflow surfaces rather* than inventing its own rules — a walk direction is regenerable on the same* finalized/approved/anchor-locked/in-flight conditions `WalkWorkflow` gates- * its Generate button on. The anchor path is intentionally looser than- * `ReferenceWorkflow`'s: it omits the backend-availability (`!mode`) gate,- * because the asset card doesn't own the backend picker and a re-roll falls- * back to the install's configured image backend server-side.+ * its Generate button on, and an anchor re-roll mirrors `ReferenceWorkflow`'s+ * own backend-availability gate: when no image backend is configured the+ * button is disabled with the same guidance, rather than queuing a job that+ * fails with a toast (#2938). The selected backend `mode` is threaded from the+ * page (the same state `ReferenceWorkflow`'s picker drives) so a card re-roll+ * uses the same backend the workflow would, not a server default.*/// Roles that represent a walk run's rendered output. A manifest or a review@@ -29,14 +31,20 @@ const WALK_OUTPUT_ROLES = new Set(['strip', 'animation', 'frame']);* @param walkPending direction → jobId map for in-flight walk videos* @param referencePending target → jobId map for in-flight reference images* @param generateWalk (direction) => void — fires the walk render- * @param generateAnchor (direction) => void — fires the anchor render+ * @param generateAnchor (direction, mode) => void — fires the anchor render* @param onRequestTrim (runId) => void — opens the Loop Trimmer for a run+ * @param hasBackend whether an image backend is configured (gates the+ * anchor re-roll — defaults true so callers that don't+ * know the backend state keep the pre-#2938 behavior)+ * @param mode the workflow-selected image backend id, threaded+ * into the anchor re-roll so it matches the workflow* @returns `{ regenerateFor(asset), trimFor(asset) }`, each returning null for* an asset it can't act on.*/export function buildCollectionActions({detail, walkPending = {}, referencePending = {},generateWalk, generateAnchor, onRequestTrim,+ hasBackend = true, mode,}) {const walk = detail?.walk || null;const finalized = Boolean(walk?.walkSet);@@ -88,9 +96,11 @@ export function buildCollectionActions({return {kind: 'reference',pending,- disabled: locked || pending,- title: locked ? 'This anchor is locked — its reference set is frozen' : 'Render another candidate for this anchor',- onClick: () => generateAnchor(direction),+ disabled: !hasBackend || locked || pending,+ title: !hasBackend+ ? 'No image backend configured — enable one in Settings → Image Gen'+ : locked ? 'This anchor is locked — its reference set is frozen' : 'Render another candidate for this anchor',+ onClick: () => generateAnchor(direction, mode),};}diff --git a/client/src/lib/spriteCollectionActions.test.js b/client/src/lib/spriteCollectionActions.test.jsindex 501884b454..d594384ec4 100644--- a/client/src/lib/spriteCollectionActions.test.js+++ b/client/src/lib/spriteCollectionActions.test.js@@ -116,6 +116,30 @@ describe('regenerateFor — reference anchors', () => {});});+describe('regenerateFor — backend gate (#2938)', () => {+ const unlockedEast = { reference: { manifest: { anchors: [{ direction: 'east', status: 'pending' }] } } };++ it('disables the anchor re-roll when no image backend is configured', () => {+ const r = build(unlockedEast, { hasBackend: false }).regenerateFor(CANDIDATE_EAST);+ expect(r).toMatchObject({ kind: 'reference', disabled: true });+ expect(r.title).toMatch(/No image backend/);+ });++ it('keeps the re-roll enabled when a backend is available (default) ', () => {+ expect(build(unlockedEast).regenerateFor(CANDIDATE_EAST).disabled).toBe(false);+ });++ it('threads the workflow-selected backend into the anchor re-roll', () => {+ const generateAnchor = vi.fn();+ buildCollectionActions({+ detail: detailWith(unlockedEast),+ generateWalk: vi.fn(), generateAnchor, onRequestTrim: vi.fn(),+ mode: 'grok',+ }).regenerateFor(CANDIDATE_EAST).onClick();+ expect(generateAnchor).toHaveBeenCalledWith('east', 'grok');+ });+});+describe('regenerateFor — non-actionable assets', () => {it.each([['a manifest', 'grok/walk-east-abc12345/generated/example-walk-east-manifest.json'],diff --git a/client/src/pages/Sprites.jsx b/client/src/pages/Sprites.jsxindex 7950a6fdfe..9eceb01422 100644--- a/client/src/pages/Sprites.jsx+++ b/client/src/pages/Sprites.jsx@@ -7,6 +7,8 @@ import {generateSpriteWalk, generateSpriteReference,} from '../services/apiSprites.js';import { getApps } from '../services/apiApps.js';+import { getSettings } from '../services/apiSystem.js';+import { deriveAvailableBackends } from '../lib/imageGenBackends.js';import AppContextPicker from '../components/AppContextPicker.jsx';import ReferenceWorkflow from '../components/sprites/ReferenceWorkflow.jsx';import WalkWorkflow, { WALK_WORKFLOW_DOM_ID, WALK_DURATIONS } from '../components/sprites/WalkWorkflow.jsx';@@ -307,6 +309,43 @@ export default function Sprites() {// panel instead of silently falling back to the server default.const [duration, setDuration] = useState(WALK_DURATIONS[0]);+ // Image-backend availability + the selected backend `mode` are page-owned+ // (#2938): both ReferenceWorkflow's picker and the asset collection's anchor+ // Regenerate must read ONE mode, or a card re-roll would use a different+ // backend than the one the user picked in the workflow. `null` = settings not+ // loaded yet; `[]` = loaded with no image backend configured.+ const [imageBackends, setImageBackends] = useState(null);+ const [imageMode, setImageMode] = useState('');+ useEffect(() => {+ getSettings({ silent: true })+ .then((settings) => {+ const available = deriveAvailableBackends(settings, { excludeExternal: true });+ setImageBackends(available);+ // Prefer the configured dispatcher default when it's available, else+ // the first list entry — matching ReferenceWorkflow's prior logic.+ const configured = available.find((b) => b.id === settings?.imageGen?.mode)?.id;+ setImageMode((m) => m || configured || available[0]?.id || '');+ })+ .catch(() => setImageBackends([]));+ }, []);+ const hasImageBackend = Array.isArray(imageBackends) && imageBackends.length > 0;++ // Run ids the walk selection has approved. An approved run's strip/frames+ // never move on disk (approval is recorded in the selection, not the path),+ // so the pure path classifier still reads them as `candidate` — the asset+ // collection promotes them to `approved` for their badge from this set.+ const approvedRunIds = useMemo(() => {+ const set = new Set();+ const collect = (dirs) => {+ for (const d of Object.values(dirs || {})) {+ if (d?.status === 'approved' && d.runId) set.add(d.runId);+ }+ };+ collect(detail?.walk?.selection?.directions);+ collect(detail?.walk?.walkSet?.directions);+ return set;+ }, [detail]);+// Both generators share the reserve → submit → resolve/cancel dance; only// the endpoint, its args, and the fail message differ. The hook's setters// are stable identities, so depending on THEM (not the whole render-tracking@@ -340,14 +379,17 @@ export default function Sprites() {`Failed to queue ${direction} walk`,), [id, duration, walkBegin, walkResolve, walkCancel, submitRender]);- const generateAnchor = useCallback((direction) => submitRender(+ // `mode` is the workflow-selected backend, threaded from the asset card via+ // buildCollectionActions (#2938) so a re-roll uses the same backend the+ // Reference workflow would, not the server default. Falls back to the+ // page-level selection when a caller omits it.+ const generateAnchor = useCallback((direction, mode) => submitRender(refBegin, refResolve, refCancel, direction,- // The server falls back to the install's configured image backend — the- // asset-card path deliberately doesn't thread ReferenceWorkflow's backend- // picker (that state lives in the workflow); a re-roll uses the default.- () => generateSpriteReference(id, { target: direction }, { silent: true }),+ () => generateSpriteReference(id, {+ target: direction, ...((mode || imageMode) ? { mode: mode || imageMode } : {}),+ }, { silent: true }),`Failed to queue ${direction} render`,- ), [id, refBegin, refResolve, refCancel, submitRender]);+ ), [id, imageMode, refBegin, refResolve, refCancel, submitRender]);const collectionActions = useMemo(() => {if (detail?.record?.kind !== 'character') return null;@@ -357,6 +399,8 @@ export default function Sprites() {referencePending: referenceRenders.pendingJobs,generateWalk,generateAnchor,+ hasBackend: hasImageBackend,+ mode: imageMode,onRequestTrim: (runId) => {setTrimRunId(runId);// The trimmer lives inside WalkWorkflow further up the page; a request@@ -365,7 +409,7 @@ export default function Sprites() {document.getElementById(WALK_WORKFLOW_DOM_ID)?.scrollIntoView({ behavior: 'smooth', block: 'start' });},});- }, [detail, walkRenders.pendingJobs, referenceRenders.pendingJobs, generateWalk, generateAnchor]);+ }, [detail, walkRenders.pendingJobs, referenceRenders.pendingJobs, generateWalk, generateAnchor, hasImageBackend, imageMode]);return (<div className="space-y-4">@@ -432,6 +476,9 @@ export default function Sprites() {record={detail.record}reference={detail.reference}renders={referenceRenders}+ backends={imageBackends}+ mode={imageMode}+ onModeChange={setImageMode}onChanged={onWorkflowChanged}/><WalkWorkflow@@ -464,6 +511,7 @@ export default function Sprites() {recordId={detail.record.id}assets={detail.assets}actions={collectionActions}+ approvedRunIds={approvedRunIds}/>)}</div>