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
feat: re-process one turnaround candidate with a per-attempt correction note
[._.]/ Adam Eivy9f6304bcc83d
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.mdindex aa33298209..601e4eab10 100644--- a/.changelog/NEXT.md+++ b/.changelog/NEXT.md@@ -45,6 +45,7 @@## Sprite Manager+- **Steer a single turnaround candidate with a correction note, without re-rolling the whole sheet** — each turnaround candidate now has its own **Correction** box and a **Re-process with note** button: describe what's wrong with that one attempt ("add the missing sleeve pocket") and it re-renders image-to-image from that exact candidate with the fix appended to the prompt, instead of generating a fresh sheet from scratch and hoping the same issue doesn't recur.- **A locked turnaround can now be reopened and regenerated without losing its history** — if you spot a bad side or inconsistent detail after freezing a character’s turnaround, the Reference Set now offers **Unlock turnaround** behind a confirmation that names the full consequence: because the main reference, all 8 directional anchors, and their walks descend from that sheet, they reopen together. Any approved walks are invalidated before the reference pointers reset, so stale animation cannot survive the revision. The old turnaround, main, anchors, rendered clips, and runtime atlases remain as versioned history; replacements lock at the next `vN` filename. A chroma key PortOS auto-picked for the rejected sheet is chosen afresh, while a key you explicitly pinned stays pinned.- **[issue-3017] Sprite sheets can now describe an animation that has no facing — the groundwork for animating places and objects** — every animation in a sprite sheet was assumed to be a character walk: eight rows, one per direction. That is wrong for most of what would come next. A tree moving in the wind, water, a flickering lamp — none of them face anywhere, and a sheet that insisted on eight facings for them would be seven-eighths empty with no way to say so. An animation now states whether it is directional, and one with no facing occupies a single row that the published layout file marks as such (`"rows": 1`), so a game reads that one row no matter which way anything is pointing instead of sampling seven blank ones. Everything still ships as **one** sheet per record — a second image would double what a game has to load and bind, and the unused cells compress to almost nothing. The rule that all of a walk's directions must agree on frame count and speed now applies *within* each animation rather than across the whole sheet, so a three-frame ambient loop can sit beside a twelve-frame walk. The other half is the gate: animation was refused outright for anything that wasn't a character, which is why **Places** and **Objects** had no animation path at all — that check now asks which animations a record kind can actually carry, so admitting those kinds becomes a matter of adding the animation rather than unpicking the refusal. To be clear about what this does and doesn't do: it is the sheet-and-publishing groundwork, not a feature you can use yet. No animation that places or objects can carry exists so far, and rendering and approving one is still walk-shaped — that work is tracked separately. Nothing changes for an existing character: walks compile to byte-identical sheets, already-published sheets are untouched until you republish, and the layout file gains the new row field additively.- **[issue-3021] Walk cycles no longer jitter — the character stays put while only the limbs move** — every frame of a walk was being positioned independently of its neighbours, so the character slid sideways as the arms swung and bobbed up and down when a stray speck of leftover background sat below the feet. Two separate things caused it. First, each frame was horizontally anchored on wherever *its own* hips happened to measure, which drifts as the legs scissor and could flip by a pixel on alternating frames — a walk rendered in place has a fixed hip position by definition, so all frames of a direction now share one. Second, the compiler that builds the final sprite sheet was re-positioning every cell from scratch on a *different* rule than the packer had used (the silhouette's centre rather than the hips), which threw away the alignment and let a swinging arm drag the whole body with it — it now carries the packer's anchor through instead. The feet also now land on the ground line based on the actual sole rather than the single lowest visible pixel, so one leftover speck of background can't lift the body — at both stages, since fixing only the first was silently undone by the second. The standing (idle) pose is anchored the same way as the walk frames now too, so a character no longer pops sideways the moment it starts or stops walking. Feet still sit exactly on the ground line in every frame, so nothing changes for a game using these sheets. Existing walks keep their packed frames until you reprocess them — but simply recompiling one picks up the corrected alignment and saves it as a new atlas version, so you can fix a character's jitter without re-rendering anything.diff --git a/client/src/components/sprites/CorrectionNote.jsx b/client/src/components/sprites/CorrectionNote.jsxindex 87f6ff9791..3aa4403f81 100644--- a/client/src/components/sprites/CorrectionNote.jsx+++ b/client/src/components/sprites/CorrectionNote.jsx@@ -24,14 +24,16 @@ export function correctionPromptPayload(corrections, direction) {return note ? { correctionPrompt: note } : {};}-export default function CorrectionNote({ direction, value, onChange, className = '' }) {+export default function CorrectionNote({ direction, value, onChange, onValueChange, placeholder, className = '' }) {return (<textareavalue={value || ''}- onChange={(e) => onChange((prev) => ({ ...prev, [direction]: e.target.value }))}+ onChange={(e) => onValueChange+ ? onValueChange(e.target.value)+ : onChange((prev) => ({ ...prev, [direction]: e.target.value }))}rows={2}aria-label={`Correction guidance for the ${direction} pose`}- placeholder="Correction (optional), e.g. no pocket on the right sleeve"+ placeholder={placeholder || 'Correction (optional), e.g. no pocket on the right sleeve'}className={`w-full px-1.5 py-1 bg-port-bg border border-port-border rounded text-gray-300 placeholder-gray-600 resize-y focus:border-port-accent focus:outline-none ${className}`}/>);diff --git a/client/src/components/sprites/ReferenceWorkflow.jsx b/client/src/components/sprites/ReferenceWorkflow.jsxindex 403fd7960e..2e5143b413 100644--- a/client/src/components/sprites/ReferenceWorkflow.jsx+++ b/client/src/components/sprites/ReferenceWorkflow.jsx@@ -45,7 +45,7 @@ function SpriteImg({ recordId, path, className }) {// Candidate thumbnail with an inline lock confirm. Locking freezes this// version and its downstream workflow until the relevant explicit unlock, so// the consequential action stays visible in an inline confirm row.-function CandidateTile({ recordId, candidate, locking, onLock, clipRisk }) {+function CandidateTile({ recordId, candidate, locking, onLock, clipRisk, correction, onCorrectionChange, onReprocess, reprocessing }) {const [confirming, setConfirming] = useState(false);return (<div className="flex min-w-0 flex-col gap-2 rounded-lg border border-port-border bg-port-card p-2">@@ -57,6 +57,27 @@ function CandidateTile({ recordId, candidate, locking, onLock, clipRisk }) {<p className="truncate px-0.5 text-[10px] text-gray-500" title={candidate.path}>{candidate.path.split('/').pop()}{candidate.mode ? ` · ${candidate.mode}` : ''}</p>+ {candidate.target === 'turnaround' && onCorrectionChange && (+ <CorrectionNote+ direction={candidate.path}+ value={correction}+ onValueChange={onCorrectionChange}+ placeholder="Correction for this attempt, e.g. add the missing sleeve pocket"+ className="text-[10px]"+ />+ )}+ {candidate.target === 'turnaround' && onReprocess && (+ <button+ type="button"+ onClick={onReprocess}+ disabled={reprocessing || !correction?.trim()}+ title="Render this turnaround again with the correction note"+ className="flex min-h-8 w-full items-center justify-center gap-1 rounded border border-port-border bg-port-bg px-1.5 py-1 text-xs text-gray-300 hover:border-port-accent disabled:opacity-50"+ >+ <RefreshCw className={`h-3 w-3 ${reprocessing ? 'animate-spin' : ''}`} />+ {reprocessing ? 'Re-processing…' : 'Re-process with note'}+ </button>+ )}{clipRisk ? (<div className="mt-auto space-y-1 text-[10px]"><p className="text-port-warning">{clipRisk}</p>@@ -236,7 +257,9 @@ export default function ReferenceWorkflow({ record, reference, renders, correcticonst [spritePickerOpen, setSpritePickerOpen] = useState(false);const [forkOpen, setForkOpen] = useState(false);const [turnaroundUnlockConfirming, setTurnaroundUnlockConfirming] = useState(false);+ const [turnaroundCorrections, setTurnaroundCorrections] = useState({});useEffect(() => { setTurnaroundUnlockConfirming(false); }, [recordId]);+ useEffect(() => { setTurnaroundCorrections({}); }, [recordId]);// Revoke the previous upload's object URL whenever the source changes or the// component unmounts (cleanup runs with the prior closure).@@ -285,6 +308,24 @@ export default function ReferenceWorkflow({ record, reference, renders, correcti}};+ const reprocessTurnaround = async (candidate) => {+ const correctionPrompt = turnaroundCorrections[candidate.path]?.trim();+ if (!correctionPrompt) return;+ beginSubmit('turnaround');+ try {+ const { jobId } = await generateSpriteReference(recordId, {+ target: 'turnaround',+ ...(mode ? { mode } : {}),+ initImageCandidate: candidate.path,+ correctionPrompt,+ }, { silent: true });+ resolveSubmit('turnaround', jobId);+ } catch (err) {+ cancelSubmit('turnaround');+ toast.error(err?.message || 'Failed to re-process turnaround');+ }+ };+// path → clip-risk message; a risky main lock 409s until the user// explicitly locks through it from the candidate tile.const [clipRisks, setClipRisks] = useState({});@@ -629,6 +670,10 @@ export default function ReferenceWorkflow({ record, reference, renders, correctilocking={locking}clipRisk={clipRisks[candidate.path]}onLock={(picked, accept) => lock('turnaround', picked, accept)}+ correction={turnaroundCorrections[candidate.path]}+ onCorrectionChange={(value) => setTurnaroundCorrections((prev) => ({ ...prev, [candidate.path]: value }))}+ onReprocess={() => reprocessTurnaround(candidate)}+ reprocessing={Boolean(pendingJobs.turnaround)}/>))}</div>diff --git a/client/src/components/sprites/ReferenceWorkflow.test.jsx b/client/src/components/sprites/ReferenceWorkflow.test.jsxindex a481ded9e5..0db2ade390 100644--- a/client/src/components/sprites/ReferenceWorkflow.test.jsx+++ b/client/src/components/sprites/ReferenceWorkflow.test.jsx@@ -27,6 +27,7 @@ vi.mock('./SpritePreview.jsx', () => ({import ReferenceWorkflow from './ReferenceWorkflow.jsx';import {+ generateSpriteReference,unlockSpriteReferenceAnchor, unlockSpriteTurnaround,} from '../../services/apiSprites.js';@@ -144,4 +145,20 @@ describe('ReferenceWorkflow workspace', () => {{ silent: true },);});++ it('re-processes one turnaround attempt with its own correction note', async () => {+ const user = userEvent.setup();+ generateSpriteReference.mockClear();+ renderWorkflow();+ const turnaround = screen.getByRole('region', { name: 'Turnaround sheet' });+ const note = within(turnaround).getByPlaceholderText(/Correction for this attempt/);+ await user.type(note, 'add the missing sleeve pocket');+ await user.click(within(turnaround).getByRole('button', { name: 'Re-process with note' }));+ expect(generateSpriteReference).toHaveBeenCalledWith('example-pioneer', {+ target: 'turnaround',+ mode: 'codex',+ initImageCandidate: 'reference/example-pioneer-turnaround-candidate-01.png',+ correctionPrompt: 'add the missing sleeve pocket',+ }, { silent: true });+ });});diff --git a/client/src/services/apiSprites.js b/client/src/services/apiSprites.jsindex 0bb2e27926..2109bb9031 100644--- a/client/src/services/apiSprites.js+++ b/client/src/services/apiSprites.js@@ -62,7 +62,8 @@ export const importSprites = (body, options = {}) => request('/sprites/import',// Queue one reference candidate render. `referenceImageFile` (main target// only) switches the POST to multipart so the design reference uploads with-// the fields. Returns { jobId, mode, target, anchorId }.+// the fields. `initImageCandidate` re-processes one turnaround candidate with+// a correctionPrompt. Returns { jobId, mode, target, anchorId }.export const generateSpriteReference = (id, { referenceImageFile, ...fields }, options = {}) => {let body;if (referenceImageFile) {diff --git a/server/lib/validation.js b/server/lib/validation.jsindex bc3332ed3f..c00b6c2b89 100644--- a/server/lib/validation.js+++ b/server/lib/validation.js@@ -1118,6 +1118,8 @@ export const spriteReferenceGenerateSchema = z.object({// seeds this one (the "fork"/derive-from case). Ignored for anchor targets.initImageGalleryFile: z.string().trim().max(300).optional(),initImageSpriteId: z.string().trim().max(200).optional(),+ // Re-process one turnaround candidate as the i2i seed (turnaround target only).+ initImageCandidate: z.string().trim().max(300).optional(),});// Fork a new character from an existing sprite's locked main reference: creatediff --git a/server/services/sprites/prompts.js b/server/services/sprites/prompts.jsindex 91daa1f8d3..2e34ae5f2c 100644--- a/server/services/sprites/prompts.js+++ b/server/services/sprites/prompts.js@@ -140,7 +140,7 @@ export const TURNAROUND_ID = 'turnaround';* panels of the SAME character, so the model that later draws a back or side* anchor has actually been shown that side instead of inventing it.*/-export function buildTurnaroundPrompt({ name, designPrompt, chromaKey }) {+export function buildTurnaroundPrompt({ name, designPrompt, chromaKey, correctionPrompt }) {const description = (typeof designPrompt === 'string' && designPrompt.trim())? designPrompt.trim(): 'Use the attached visual reference as the character design.';@@ -157,6 +157,9 @@ export function buildTurnaroundPrompt({ name, designPrompt, chromaKey }) {const panelRules = TURNAROUND_VIEWS.map((view, i) => `Panel ${i + 1} (${REFERENCE_FACING[view] || view}): ${viewGeometryClause(view)}`).join(' ');+ const correction = (typeof correctionPrompt === 'string' && correctionPrompt.trim())+ ? ` Important correction — apply this over the attached turnaround: ${correctionPrompt.trim()}`+ : '';return (`Create a character turnaround model sheet for a game character named ${name}. `+ `Character design: ${description} `@@ -187,6 +190,7 @@ export function buildTurnaroundPrompt({ name, designPrompt, chromaKey }) {+ `reference on a plain exact ${keyColorPhrase(chromaKey)} background. No panel borders, `+ 'labels, captions, arrows, grid, shadows, scenery, wireframe, or extra characters. '+ 'Return exactly one PNG.'+ + correction);}diff --git a/server/services/sprites/reference.js b/server/services/sprites/reference.jsindex 2c5c33aeb8..47f937075a 100644--- a/server/services/sprites/reference.js+++ b/server/services/sprites/reference.js@@ -242,6 +242,21 @@ async function nextCandidateName(candidatesDir, anchorId) {return `${anchorId}-candidate-${String(max + 1).padStart(2, '0')}.png`;}+async function requireTurnaroundCandidatePath(recordId, candidatePath) {+ if (typeof candidatePath !== 'string' || !candidatePath.startsWith('reference/candidates/')) {+ throw new ServerError('Turnaround seed must be a reference candidate', { status: 400, code: 'INVALID_CANDIDATE' });+ }+ const name = candidatePath.slice('reference/candidates/'.length);+ if (!TURNAROUND_CANDIDATE_RE.test(name)) {+ throw new ServerError('Turnaround seed must be a turnaround candidate', { status: 400, code: 'CANDIDATE_TARGET_MISMATCH' });+ }+ const abs = resolveSpriteAssetPath(recordId, candidatePath);+ if (!await pathExists(abs)) {+ throw new ServerError('Turnaround candidate file is missing on disk', { status: 404, code: 'CANDIDATE_NOT_FOUND' });+ }+ return abs;+}+function findAnchor(manifest, anchorId) {return manifest.anchors.find((a) => a.id === anchorId) || null;}@@ -376,6 +391,7 @@ async function startReferenceGenerationImpl(recordId, body, upload = null) {// prompt, an uploaded image, a gallery pick, another sprite's reference —// or, on a legacy record, the locked main this backfill expands.if (!designPrompt && !upload && !body.initImageGalleryFile && !body.initImageSpriteId+ && !body.initImageCandidate&& !manifest.mainReference.locked) {throw new ServerError('Provide a design prompt and/or a reference image', { status: 400, code: 'DESIGN_INPUT_REQUIRED' });}@@ -384,8 +400,15 @@ async function startReferenceGenerationImpl(recordId, body, upload = null) {name: record.name,designPrompt: designPrompt || manifest.designPrompt,chromaKey: genKey,+ correctionPrompt: body.correctionPrompt,});- ({ initImagePath, designReferencePath } = await resolveSeedSource(recordId, body, upload));+ correctionPrompt = typeof body.correctionPrompt === 'string' ? body.correctionPrompt.trim() : '';+ if (body.initImageCandidate) {+ initImagePath = await requireTurnaroundCandidatePath(recordId, body.initImageCandidate);+ designReferencePath = body.initImageCandidate;+ } else {+ ({ initImagePath, designReferencePath } = await resolveSeedSource(recordId, body, upload));+ }// Legacy backfill: no explicit seed, but a frozen main exists — expand the// one view we already have into the full sheet rather than inventing a new// character from text.diff --git a/server/services/sprites/reference.test.js b/server/services/sprites/reference.test.jsindex 6f2b869492..b5213a0b51 100644--- a/server/services/sprites/reference.test.js+++ b/server/services/sprites/reference.test.js@@ -347,6 +347,34 @@ describe('startReferenceGeneration', () => {expect(call.params.spriteRef.correctionPrompt).toBe('no pocket on the right sleeve');});+ it('re-processes a specific turnaround candidate as the i2i seed with a correction', async () => {+ const id = newId();+ await createCharacter(id);+ const candidate = await placeCandidate(id, 'turnaround', 'turnaround-candidate-01.png');+ await startReferenceGeneration(id, {+ target: 'turnaround',+ initImageCandidate: candidate,+ correctionPrompt: 'add the missing pocket to the right sleeve',+ });+ const call = enqueueJob.mock.calls[0][0];+ expect(call.params.initImagePath).toBe(join(TEST_ROOT, 'sprites', id, candidate));+ expect(call.params.initImageStrength).toBe(0.65);+ expect(call.params.prompt).toContain('Important correction — apply this over the attached turnaround: add the missing pocket to the right sleeve');+ expect(call.params.spriteRef).toMatchObject({+ designReferencePath: candidate,+ correctionPrompt: 'add the missing pocket to the right sleeve',+ });+ });++ it('rejects a non-turnaround candidate as a turnaround seed', async () => {+ const id = newId();+ await createCharacter(id);+ const candidate = await placeCandidate(id, 'east', 'walk-east-candidate-01.png');+ await expect(startReferenceGeneration(id, {+ target: 'turnaround', initImageCandidate: candidate,+ })).rejects.toMatchObject({ code: 'CANDIDATE_TARGET_MISMATCH', status: 400 });+ });+it('omits the correction from the tag when blank', async () => {const id = newId();await createCharacter(id);