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: backfill custom atlas manifest counts (#3223)
[._.]/ Adam Eivy7650a3fdaf34
diff --git a/server/services/sprites/atlas.js b/server/services/sprites/atlas.jsindex ee232cbdfb..e35dc71c81 100644--- a/server/services/sprites/atlas.js+++ b/server/services/sprites/atlas.js@@ -680,6 +680,16 @@ const trackSetsUpToDate = (persisted, validated) => {return [...ids].every((id) => current[id] === expected[id]);};+const trackFrameCountFields = (validated, animationTracks) => Object.fromEntries(+ Object.values(animationTracks).flatMap((definition) => {+ const frameCount = validated.tracks[definition.id]?.frameCount;+ return Number.isInteger(frameCount) ? [[definition.contractFrameCountField, frameCount]] : [];+ }),+);++const trackFrameCountsUpToDate = (geometry, fields) => Object.entries(fields)+ .every(([field, frameCount]) => geometry?.[field] === frameCount);+export async function compileAtlasInTail(recordId, {geometry: geometryOverride,tracks: animationTracks = getEffectiveAnimationTracks(),@@ -692,6 +702,7 @@ export async function compileAtlasInTail(recordId, {await requireAnimatable(recordId);const geometry = mergeGeometry(geometryOverride);const validated = await validateForCompile(recordId, animationTracks);+ const frameCountFields = trackFrameCountFields(validated, animationTracks);const dir = spriteDir(recordId);// Columns/width follow the set's actual per-track frame counts, not the@@ -727,6 +738,7 @@ export async function compileAtlasInTail(recordId, {&& currentAtlasOnDisk&& trackSetsUpToDate(current, validated)&& compiledGridUpToDate(current.geometry, { ...geometry, columns, tracks })+ && trackFrameCountsUpToDate(current.geometry, frameCountFields)) {return { ...current, created: false };}@@ -781,7 +793,8 @@ export async function compileAtlasInTail(recordId, {const atlasSha256 = sha256Buffer(atlasBuffer);if (current && currentAtlasOnDisk && trackSetsUpToDate(current, validated)- && current.atlasSha256 === atlasSha256) {+ && current.atlasSha256 === atlasSha256+ && trackFrameCountsUpToDate(current.geometry, frameCountFields)) {return { ...current, created: false };}@@ -896,10 +909,7 @@ export async function compileAtlasInTail(recordId, {// Match every compiled track to the convenience field its registry row// declares. The duplicate walk assignment preserves the existing field// position, while seeded scanner/ambient rows keep their wire names.- ...Object.fromEntries(Object.values(animationTracks).flatMap((definition) => {- const frameCount = validated.tracks[definition.id]?.frameCount;- return Number.isInteger(frameCount) ? [[definition.contractFrameCountField, frameCount]] : [];- })),+ ...frameCountFields,},directions: rows.map((row) => ({direction: row.direction,diff --git a/server/services/sprites/atlas.test.js b/server/services/sprites/atlas.test.jsindex 06ed8f683e..36ffae56bd 100644--- a/server/services/sprites/atlas.test.js+++ b/server/services/sprites/atlas.test.js@@ -439,6 +439,21 @@ describe('compileAtlas', () => {expect(row.cells.filter((cell) => cell.column.startsWith('jetpack-'))).toHaveLength(3);}+ // A pre-#3223 pointer has the generic span but no top-level convenience+ // field. Recompile the immutable metadata into a new version even though+ // its atlas pixels and finalized track sets are unchanged.+ const pointerAbs = join(TEST_ROOT, 'sprites', id, 'runtime/current.json');+ const legacyPointer = JSON.parse(await readFile(pointerAbs, 'utf8'));+ delete legacyPointer.geometry.jetpackFrameCount;+ await writeFile(pointerAbs, JSON.stringify(legacyPointer));+ const backfilled = await compileAtlas(id, { tracks: customTracks });+ expect(backfilled.created).toBe(true);+ expect(backfilled.version).toBe(first.version + 1);+ const backfilledManifest = JSON.parse(+ await readFile(join(TEST_ROOT, 'sprites', id, backfilled.manifestPath), 'utf8'),+ );+ expect(backfilledManifest.geometry.jetpackFrameCount).toBe(3);+const unchanged = await compileAtlas(id, { tracks: customTracks });expect(unchanged.created).toBe(false);@@ -450,7 +465,7 @@ describe('compileAtlas', () => {await writeFile(setAbs, JSON.stringify({ ...set, note: 're-finalized' }));const changed = await compileAtlas(id, { tracks: customTracks });expect(changed.created).toBe(true);- expect(changed.version).toBe(first.version + 1);+ expect(changed.version).toBe(backfilled.version + 1);});it('compiles the 9×8 player atlas with full provenance and a current pointer', async () => {