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
add a correction-prompt textarea for regenerating sprite directional anchors
[._.]/ Adam Eivydd29174baef4
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.mdindex 6ac7625275..196bc085d5 100644--- a/.changelog/NEXT.md+++ b/.changelog/NEXT.md@@ -18,8 +18,8 @@## Sprite Manager+- **Steer a directional-anchor re-roll with a correction note** — when a directional anchor comes out wrong (say the north-east pose grew a pocket on the arm that has none in every other view), re-rolling it with the same inputs tended to just reproduce the same mistake. Each unlocked anchor tile now has a small **Correction (optional)** box: type what to fix ("no pocket on the right sleeve") and hit **Regenerate**, and the note is appended to that pose's prompt as an explicit override so the new render actually diverges. The button reads **Generate** on the first render and **Regenerate** once candidates exist, the correction is per-direction (so eight different fixes don't collide), and it rides into the candidate's saved prompt so the image preview shows exactly what was asked for. Main-reference iteration is unchanged — it already has its own design-prompt box.- **Locking a main reference no longer leaves a colored halo around the character** — when you lock a character's main reference, PortOS re-keys the background to whichever chroma color (magenta, green, or blue) sits farthest from the character's own palette. If that swapped the background — e.g. a magenta render re-keyed onto blue — the anti-aliased pixels along the character's outline kept their old magenta tint and showed up as a faint magenta ring against the new blue backdrop. Locking now cleans those edge pixels as it re-keys, so the outline blends into the new background with no leftover halo. Already-locked references (which are immutable and can't be re-locked) are healed automatically on upgrade: each one is re-derived from its saved candidate with the fix applied, and its stored checksum is refreshed — no action needed on your part.-- **See — and copy — the prompt behind any sprite image** — click a reference-set image (the frozen main, a locked directional anchor, or any generation candidate) and the enlarged preview now shows the exact prompt that produced it, with a one-click **Copy prompt** button, the same way the image render-history preview does. The asset inspector gains the same prompt block, so a walk-animation clip or any generated asset you open there shows its prompt too. Older images generated before this shipped still show their prompt — it's reconstructed from the render's recorded design description, direction, and background color — so nothing in your existing library is blank. Imported artwork and internal metadata files simply omit the block. New endpoint `GET /api/sprites/:id/asset-prompt`.- **Seed a character's main reference from an existing sprite, an upload, or your render history — and fork a character from its reference** — the "design image (optional)" upload on the main-reference form is now a three-way **Reference image** picker: upload a file, pick one from your image render-history gallery, or pick another sprite that already has a locked reference, each with a fidelity slider controlling how tightly the render follows it (image+text→image). Separately, a locked reference is immutable and can never be regenerated — so a character with a frozen main now shows a **Fork from this reference** button that spins up a brand-new character whose main is generated from this one's reference plus a prompt describing the change ("same character but in a red coat"), then opens the new sprite. New endpoints `GET /api/sprites/reference-sources` and `POST /api/sprites/:id/fork`.- **The Sprite Manager opens on a full Library catalog, with rename and delete built in** — landing on the Sprite Manager now shows the **Library** itself: a searchable, grouped grid of every character/place/object, each card carrying a real preview thumbnail — a character's locked main reference, or, for a place/object (or a character with no reference yet), the first image asset on disk, falling back to a kind icon only when there's no image at all — instead of jumping you straight into one sprite. The catalog is the `/sprites` route (not a modal buried behind a button), so it's directly linkable, and each card gives you full record control: click to open it, the pencil to **rename** in place (for records whose generated name you want to fix), or the trash to **delete** behind a cautious inline Cancel/Delete confirm (a delete drops the record from your library; its files stay on disk and its id stays reserved). The same **rename** and **delete** controls sit in a sprite's detail header, so you can fix or remove the one you're looking at without going back to the grid (deleting it returns you there). Search, **New Sprite**, and **Import** live in the page header (New Sprite/Import are modals), the left sidebar is gone so the catalog and detail panes run full width, and opening a sprite shows a **Library** link back to the grid. The per-character workspace tab that used to read "Library" is now **Assets**, since "Library" means the catalog. New endpoint `GET /api/sprites/thumbnails`.diff --git a/client/src/components/sprites/ReferenceWorkflow.jsx b/client/src/components/sprites/ReferenceWorkflow.jsxindex 34df32fda7..86da97a1be 100644--- a/client/src/components/sprites/ReferenceWorkflow.jsx+++ b/client/src/components/sprites/ReferenceWorkflow.jsx@@ -106,6 +106,10 @@ export default function ReferenceWorkflow({ record, reference, renders, backends// | { type:'sprite', id, name, path }const [refSource, setRefSource] = useState(null);const [strength, setStrength] = useState(0.65);+ // Per-direction free-text correction re-appended to an anchor re-roll (e.g.+ // "no pocket on the right sleeve"). Keyed by direction because the anchor+ // grid renders all directions at once — unlike the single main designPrompt.+ const [corrections, setCorrections] = useState({});const [galleryOpen, setGalleryOpen] = useState(false);const [spritePickerOpen, setSpritePickerOpen] = useState(false);const [forkOpen, setForkOpen] = useState(false);@@ -139,6 +143,7 @@ export default function ReferenceWorkflow({ record, reference, renders, backendsconst generate = async (target) => {beginSubmit(target);+ const correction = corrections[target]?.trim();try {const { jobId } = await generateSpriteReference(recordId, {target,@@ -149,7 +154,9 @@ export default function ReferenceWorkflow({ record, reference, renders, backends...(refSource?.type === 'gallery' ? { initImageGalleryFile: refSource.filename } : {}),...(refSource?.type === 'sprite' ? { initImageSpriteId: refSource.id } : {}),...(refSource ? { initImageStrength: strength } : {}),- } : {}),+ } : {+ ...(correction ? { correctionPrompt: correction } : {}),+ }),}, { silent: true });resolveSubmit(target, jobId);if (target === 'main') clearSource();@@ -397,7 +404,9 @@ export default function ReferenceWorkflow({ record, reference, renders, backends)}{anchorsOpen && (<div className="grid grid-cols-2 sm:grid-cols-4 gap-3">- {manifest.anchors.map((anchor) => (+ {manifest.anchors.map((anchor) => {+ const cands = candidatesByTarget[anchor.direction] || [];+ return (<div key={anchor.id} className="bg-port-bg border border-port-border rounded p-2 space-y-1.5"><p className="text-xs text-gray-400 flex items-center justify-between">{anchor.direction}@@ -407,6 +416,17 @@ export default function ReferenceWorkflow({ record, reference, renders, backends<SpriteImg recordId={recordId} path={anchor.path} className="w-full h-24 object-contain" />) : (<div className="space-y-1.5">+ {/* Optional correction guidance re-appended to the prompt on+ each re-roll — without it, regenerating with the same+ inputs tends to reproduce the same mistake. */}+ <textarea+ value={corrections[anchor.direction] || ''}+ onChange={(e) => setCorrections((prev) => ({ ...prev, [anchor.direction]: e.target.value }))}+ rows={2}+ aria-label={`Correction guidance for the ${anchor.direction} pose`}+ placeholder="Correction (optional), e.g. no pocket on the right sleeve"+ className="w-full px-1.5 py-1 text-[11px] bg-port-bg border border-port-border rounded text-gray-300 placeholder-gray-600 resize-y focus:border-port-accent focus:outline-none"+ /><buttononClick={() => generate(anchor.direction)}disabled={!mode || !!pendingJobs[anchor.direction]}@@ -414,15 +434,18 @@ export default function ReferenceWorkflow({ record, reference, renders, backends>{pendingJobs[anchor.direction]? <><RefreshCw className="w-3 h-3 animate-spin" /> Rendering…</>- : <><Sparkles className="w-3 h-3" /> Generate</>}+ : cands.length+ ? <><RefreshCw className="w-3 h-3" /> Regenerate</>+ : <><Sparkles className="w-3 h-3" /> Generate</>}</button>- {(candidatesByTarget[anchor.direction] || []).map((c) => (+ {cands.map((c) => (<CandidateTile key={c.path} recordId={recordId} candidate={c} locking={locking} clipRisk={clipRisks[c.path]} onLock={(cand, accept) => lock(anchor.direction, cand, accept)} />))}</div>)}</div>- ))}+ );+ })}</div>)}</div>diff --git a/server/lib/validation.js b/server/lib/validation.jsindex 75718aee65..40fe35a26f 100644--- a/server/lib/validation.js+++ b/server/lib/validation.js@@ -1051,6 +1051,11 @@ export const spriteReferenceGenerateSchema = z.object({model: z.string().trim().max(64).optional(),effort: z.string().trim().max(32).optional(),designPrompt: z.string().max(4000).optional(),+ // Extra free-text guidance appended to an anchor re-roll (e.g. "no pocket on+ // the right sleeve") so regenerating diverges from the previous render+ // instead of reproducing the same mistake. Anchor targets only — the main+ // target iterates via `designPrompt`.+ correctionPrompt: z.string().max(4000).optional(),initImageStrength: optionalUnitNumber,// Alternative i2i seed sources for the main target — resolved server-side and// mutually exclusive with an uploaded `referenceImage` file (which the routediff --git a/server/services/sprites/prompts.js b/server/services/sprites/prompts.jsindex 8b627aa272..8c2dca67b0 100644--- a/server/services/sprites/prompts.js+++ b/server/services/sprites/prompts.js@@ -97,10 +97,16 @@ export function buildWalkVideoPrompt({ name, direction, chromaKey }) {/*** Stage-2 prompt: derive one directional anchor from the attached frozen- * main reference.+ * main reference. `correctionPrompt` is optional free-text the user adds when+ * re-rolling a candidate that came out wrong (e.g. "no pocket on the right+ * sleeve") — appended as an explicit, high-priority correction so the re-roll+ * diverges from the previous render instead of reproducing the same mistake.*/-export function buildAnchorPrompt({ name, direction, chromaKey }) {+export function buildAnchorPrompt({ name, direction, chromaKey, correctionPrompt }) {const facing = REFERENCE_FACING[direction] || direction;+ const correction = (typeof correctionPrompt === 'string' && correctionPrompt.trim())+ ? ` Important correction — apply this over the attached reference: ${correctionPrompt.trim()}`+ : '';return (`Redraw the attached ${name} character as one `+ `full-body figure in a neutral standing pose, ${facing}. Keep the exact same `@@ -108,5 +114,6 @@ export function buildAnchorPrompt({ name, direction, chromaKey }) {+ 'same anatomical side as the attached reference. Flat, non-isometric view; a '+ `single centered figure; plain flat ${keyColorPhrase(chromaKey)} background; no labels, no `+ 'grid lines, no wireframe or guide colors. Return exactly one PNG.'+ + correction);}diff --git a/server/services/sprites/prompts.test.js b/server/services/sprites/prompts.test.jsindex e5178ae365..e73d6cb3d8 100644--- a/server/services/sprites/prompts.test.js+++ b/server/services/sprites/prompts.test.js@@ -68,4 +68,21 @@ describe('buildAnchorPrompt', () => {expect(p).toContain('magenta (#FF00FF) background');expect(p).toContain('attached Scout character');});++ it('appends a trimmed correction clause when provided', () => {+ const p = buildAnchorPrompt({+ name: 'Scout', direction: 'north-east', chromaKey: '#FF00FF',+ correctionPrompt: ' no pocket on the right sleeve ',+ });+ expect(p).toContain('Important correction — apply this over the attached reference: no pocket on the right sleeve');+ // The correction rides at the end so it reads as an override, not a base clause.+ expect(p.trimEnd().endsWith('no pocket on the right sleeve')).toBe(true);+ });++ it('omits the correction clause for blank/absent input', () => {+ const base = buildAnchorPrompt({ name: 'Scout', direction: 'east', chromaKey: '#FF00FF' });+ const blank = buildAnchorPrompt({ name: 'Scout', direction: 'east', chromaKey: '#FF00FF', correctionPrompt: ' ' });+ expect(base).not.toContain('Important correction');+ expect(blank).toBe(base);+ });});diff --git a/server/services/sprites/reference.js b/server/services/sprites/reference.jsindex 3ab4b741ff..8a8f076ab5 100644--- a/server/services/sprites/reference.js+++ b/server/services/sprites/reference.js@@ -233,6 +233,7 @@ async function startReferenceGenerationImpl(recordId, body, upload = null) {let anchorId;let direction;let designReferencePath;+ let correctionPrompt;if (target === 'main') {if (manifest.mainReference.locked) {@@ -292,7 +293,10 @@ async function startReferenceGenerationImpl(recordId, body, upload = null) {if (anchor?.status === 'locked') {throw new ServerError(`Anchor ${anchorId} is locked — locked anchors are immutable`, { status: 409, code: 'REFERENCE_LOCKED' });}- prompt = buildAnchorPrompt({ name: record.name, direction, chromaKey: genKey });+ // Optional user correction re-appended on every re-roll — diverges the+ // render from the previous candidate rather than reproducing its mistakes.+ correctionPrompt = typeof body.correctionPrompt === 'string' ? body.correctionPrompt.trim() : '';+ prompt = buildAnchorPrompt({ name: record.name, direction, chromaKey: genKey, correctionPrompt });initImagePath = resolveSpriteAssetPath(recordId, manifest.mainReference.path);if (!await pathExists(initImagePath)) {throw new ServerError('Locked main reference file is missing on disk', { status: 500, code: 'MAIN_REFERENCE_MISSING' });@@ -322,6 +326,7 @@ async function startReferenceGenerationImpl(recordId, body, upload = null) {spriteRef: {recordId, target, direction, anchorId, chromaKey: genKey, mode, model: effectiveModel,...(target === 'main' && body.designPrompt ? { designPrompt: body.designPrompt } : {}),+ ...(correctionPrompt ? { correctionPrompt } : {}),...(designReferencePath ? { designReferencePath } : {}),},};@@ -468,6 +473,7 @@ export async function attachReferenceCandidate(ctx) {prompt: ctx.job?.params?.prompt || null,jobId: ctx.jobId || null,...(ctx.designPrompt ? { designPrompt: ctx.designPrompt } : {}),+ ...(ctx.correctionPrompt ? { correctionPrompt: ctx.correctionPrompt } : {}),...(ctx.designReferencePath ? { designReferencePath: ctx.designReferencePath } : {}),generatedAt: new Date().toISOString(),candidatePath: relPath,diff --git a/server/services/sprites/reference.test.js b/server/services/sprites/reference.test.jsindex 3ecf7c2df1..c71fc1c424 100644--- a/server/services/sprites/reference.test.js+++ b/server/services/sprites/reference.test.js@@ -159,6 +159,27 @@ describe('startReferenceGeneration', () => {expect(call.params.prompt).toContain('magenta (#FF00FF)'); // green char kept magenta});+ it('threads a correction prompt into the anchor prompt and provenance tag', async () => {+ const id = newId();+ await createCharacter(id);+ await lockMain(id);+ await startReferenceGeneration(id, { target: 'north-east', correctionPrompt: ' no pocket on the right sleeve ' });+ const call = enqueueJob.mock.calls[0][0];+ expect(call.params.prompt).toContain('Important correction — apply this over the attached reference: no pocket on the right sleeve');+ // Trimmed and carried on the tag so the completion hook's sidecar records it.+ expect(call.params.spriteRef.correctionPrompt).toBe('no pocket on the right sleeve');+ });++ it('omits the correction from the tag when blank', async () => {+ const id = newId();+ await createCharacter(id);+ await lockMain(id);+ await startReferenceGeneration(id, { target: 'east', correctionPrompt: ' ' });+ const call = enqueueJob.mock.calls[0][0];+ expect(call.params.prompt).not.toContain('Important correction');+ expect(call.params.spriteRef).not.toHaveProperty('correctionPrompt');+ });+it('409s generation for a locked target', async () => {const id = newId();await createCharacter(id);