Skip to content

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

fail the aspect-ratio phrase closed on a sub-pixel canvas, and name a missing deck clause

[._.]/ Adam Eivy7c2d16189c8c
diff --git a/server/lib/aspectRatio.js b/server/lib/aspectRatio.js
index c867fcaaff..fe652a201c 100644
--- a/server/lib/aspectRatio.js
+++ b/server/lib/aspectRatio.js
@@ -64,8 +64,13 @@ export function aspectRatioTerms(width, height, { maxTerm = DEFAULT_MAX_TERM } =
// extreme banner like 4096x64); fall back to the exact reduced ratio rather
// than reporting nothing.
if (best.width < 1 || best.height < 1) {
- const divisor = greatestCommonDivisor(Math.round(width), Math.round(height));
- return { width: Math.round(width) / divisor, height: Math.round(height) / divisor };
+ const roundedWidth = Math.round(width);
+ const roundedHeight = Math.round(height);
+ // A sub-pixel edge rounds to zero, and `0:0` would be reported as a SQUARE —
+ // a phrase that is not merely unhelpful but false. Nothing describable here.
+ if (roundedWidth < 1 || roundedHeight < 1) return null;
+ const divisor = greatestCommonDivisor(roundedWidth, roundedHeight);
+ return { width: roundedWidth / divisor, height: roundedHeight / divisor };
}
return best;
}
diff --git a/server/lib/aspectRatio.test.js b/server/lib/aspectRatio.test.js
index f6dd2861a3..9e93b8aafe 100644
--- a/server/lib/aspectRatio.test.js
+++ b/server/lib/aspectRatio.test.js
@@ -28,6 +28,15 @@ describe('aspectRatioTerms', () => {
expect(aspectRatioTerms(4096, 64)).toEqual({ width: 64, height: 1 });
});
+ it('returns null rather than 0:0 when a sub-pixel edge has no describable ratio', () => {
+ // The fallback rounds to whole pixels, so a canvas narrower than half a pixel
+ // rounded to zero on both edges and reported `0:0` — which aspectRatioPhrase
+ // then called a SQUARE. Wrong is worse than silent for a phrase that goes
+ // into a render prompt.
+ expect(aspectRatioTerms(0.3, 0.01)).toBeNull();
+ expect(aspectRatioPhrase(0.3, 0.01)).toBe('');
+ });
+
it('returns null for a canvas that cannot be described', () => {
expect(aspectRatioTerms(0, 1536)).toBeNull();
expect(aspectRatioTerms(1024, 0)).toBeNull();
diff --git a/server/lib/deckTemplates.js b/server/lib/deckTemplates.js
index 9beff67abc..9d30f576ce 100644
--- a/server/lib/deckTemplates.js
+++ b/server/lib/deckTemplates.js
@@ -77,8 +77,14 @@ const layoutClauseFor = {
export const DEFAULT_LAYOUT_PROMPT = Object.freeze(Object.fromEntries(
DECK_KINDS.map((kind) => {
+ // Loud at import rather than silent at render: a kind with no clause used to
+ // resolve to `undefined` here and reach `services/decks.js`, whose
+ // `|| ''` fallback would mint every card of that deck with NO shared layout
+ // at all — a whole deck rendered wrong before anyone noticed the gap.
+ const clause = layoutClauseFor[kind];
+ if (!clause) throw new Error(`Deck kind ${kind} has no DEFAULT_LAYOUT_PROMPT clause`);
const size = DECK_CARD_SIZE_BY_KIND[kind] || DECK_CARD_SIZE;
- return [kind, layoutClauseFor[kind](aspectRatioPhrase(size.width, size.height))];
+ return [kind, clause(aspectRatioPhrase(size.width, size.height))];
}),
));