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
address review (codex): preserve alpha-shaped sprite content
[._.]/ Adam Eivy43a86f2538d2
diff --git a/server/lib/imageFrameStats.js b/server/lib/imageFrameStats.jsindex b7cae3c423..0ab1f05b1e 100644--- a/server/lib/imageFrameStats.js+++ b/server/lib/imageFrameStats.js@@ -114,16 +114,26 @@ export async function describeFrameStats(input) {if (alpha.max === 0) return result(false, FRAME_REASON.FULLY_TRANSPARENT, perChannel);}+ // A transparent sprite can carry its entire silhouette in alpha while its+ // RGB channels remain a single color (for example, a black figure). That+ // alpha variance is content, unlike a fully opaque alpha channel, which is+ // just the normal PNG case and must not rescue a flat fill.+ const alpha = metadata.hasAlpha ? perChannel[perChannel.length - 1] : null;+ const alphaCarriesContent = Boolean(+ alpha && !stats.isOpaque && alpha.max > alpha.min && alpha.stdev >= SOLID_FILL_STDEV_EPSILON,+ );+// Only the colour channels decide "flat" — a fully-OPAQUE alpha channel is- // itself flat by definition and would otherwise veto every normal PNG.+ // itself flat by definition and would otherwise veto every normal PNG. A+ // non-opaque alpha silhouette is the one deliberate exception.const colour = metadata.hasAlpha ? perChannel.slice(0, -1) : perChannel;- if (colour.length && colour.every((c) => c.stdev < SOLID_FILL_STDEV_EPSILON)) {+ if (!alphaCarriesContent && colour.length && colour.every((c) => c.stdev < SOLID_FILL_STDEV_EPSILON)) {return result(false, FRAME_REASON.SOLID_FILL, perChannel);}// sharp reports entropy only when it could compute one; a missing value is// not evidence of emptiness, so it falls through to `ok: true`.- if (typeof stats.entropy === 'number' && stats.entropy < NEAR_EMPTY_ENTROPY_FLOOR) {+ if (!alphaCarriesContent && typeof stats.entropy === 'number' && stats.entropy < NEAR_EMPTY_ENTROPY_FLOOR) {return result(false, FRAME_REASON.NEAR_EMPTY, perChannel);}diff --git a/server/lib/imageFrameStats.test.js b/server/lib/imageFrameStats.test.jsindex c80955fd9c..11f7ceec16 100644--- a/server/lib/imageFrameStats.test.js+++ b/server/lib/imageFrameStats.test.js@@ -95,6 +95,16 @@ describe('describeFrameStats', () => {expect(stats.ok).toBe(true);});+ it('ACCEPTS a silhouette whose visual content is carried by alpha', async () => {+ const buf = await fromPixels((x, y) => {+ const inSubject = x >= 20 && x < 44 && y >= 20 && y < 44;+ return [0, 0, 0, inSubject ? 255 : 0];+ }, { channels: 4 });+ const stats = await describeFrameStats(buf);+ expect(stats.ok).toBe(true);+ expect(isDegenerateFrame(stats)).toBe(false);+ });+it('rejects a near-empty frame whose single stray pixel leaves entropy at the floor', async () => {const buf = await fromPixels((x, y) => (x === 0 && y === 0 ? [255, 255, 255] : [0, 0, 0]));const stats = await describeFrameStats(buf);