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: show full playing-card and tarot art in deck thumbnails
[._.]/ Adam Eivy13c413efda62
diff --git a/client/src/components/decks/DeckCardDrawer.jsx b/client/src/components/decks/DeckCardDrawer.jsxindex c0f116c174..58dccf7b5b 100644--- a/client/src/components/decks/DeckCardDrawer.jsx+++ b/client/src/components/decks/DeckCardDrawer.jsx@@ -1,7 +1,7 @@import { useEffect, useState } from 'react';import { Copy, Link2, Loader2, Sparkles, Star, Trash2 } from 'lucide-react';import Drawer from '../Drawer';-import { composeCardRenderPrompt } from '../../lib/decks';+import { composeCardRenderPrompt, deckCardAspectStyle } from '../../lib/decks';import { copyToClipboard } from '../../lib/clipboard';const INPUT_CLASS = 'w-full bg-port-bg border border-port-border rounded-lg px-3 py-2 text-sm text-white focus:outline-none focus:border-port-accent';@@ -96,7 +96,12 @@ export default function DeckCardDrawer({ deck, card, open, inFlight, onClose, onreturn (<li key={filename} className="space-y-1"><button type="button" onClick={() => onPreview(filename)} className="block w-full" title={`Open v${versionNum} preview`}>- <img src={`/data/images/${encodeURIComponent(filename)}`} alt={`${card.name} v${versionNum} render`} className={`aspect-[2/3] w-full object-cover border ${isPrimary ? 'border-port-accent' : 'border-port-border'}`} />+ <img+ src={`/data/images/${encodeURIComponent(filename)}`}+ alt={`${card.name} v${versionNum} render`}+ style={deckCardAspectStyle(deck)}+ className={`w-full object-contain bg-port-bg border ${isPrimary ? 'border-port-accent' : 'border-port-border'}`}+ /></button><div className="flex items-center justify-between gap-1 text-[11px]"><span className="font-mono text-gray-400">v{versionNum}</span>diff --git a/client/src/components/decks/DeckCardDrawer.test.jsx b/client/src/components/decks/DeckCardDrawer.test.jsxindex 3f0e467f16..27d4d6951a 100644--- a/client/src/components/decks/DeckCardDrawer.test.jsx+++ b/client/src/components/decks/DeckCardDrawer.test.jsx@@ -5,6 +5,7 @@ import DeckCardDrawer from './DeckCardDrawer';const deck = {id: 'd1',kind: 'tarot',+ cardSize: { width: 888, height: 1536 },layoutPrompt: 'Full tarot card, framed border',influences: { embrace: ['copperplate engraving'], avoid: ['blurry'] },};@@ -69,11 +70,17 @@ describe('DeckCardDrawer render prompt', () => {setActiveBtn.click();expect(onSave).toHaveBeenCalledWith({ primaryImageRef: 'fool-v1.png' });- // Thumbnails should not have rounded corners cutting off card art+ // Thumbnails should not have rounded corners cutting off card art, and+ // must use the deck's own trim (not a 2:3 cover box) so the banner stays+ // in frame.const imgs = screen.getAllByRole('img');expect(imgs.length).toBe(2);imgs.forEach((img) => {expect(img.className).not.toMatch(/\brounded\b/);+ expect(img.className).toMatch(/\bobject-contain\b/);+ expect(img.className).not.toMatch(/\bobject-cover\b/);+ expect(img.className).not.toMatch(/aspect-\[2\/3\]/);+ expect(img.style.aspectRatio).toBe('888 / 1536');});});});diff --git a/client/src/components/decks/DeckCardGrid.jsx b/client/src/components/decks/DeckCardGrid.jsxindex 47fc8c2664..3d55589c5f 100644--- a/client/src/components/decks/DeckCardGrid.jsx+++ b/client/src/components/decks/DeckCardGrid.jsx@@ -2,7 +2,7 @@ import { useMemo, useState } from 'react';import { AlertTriangle, Check, ChevronLeft, ChevronRight, Hourglass, Link2, PencilLine, Play, RefreshCw, Star } from 'lucide-react';import EntryThumbSlot from '../universe/EntryThumbSlot';import Pill from '../ui/Pill';-import { CARD_STATUS, cardInFlightJobId, cardStatus, deckCompletion } from '../../lib/decks';+import { CARD_STATUS, cardInFlightJobId, cardStatus, deckCardSize, deckCompletion } from '../../lib/decks';// One badge per card state, named for what the user can DO next rather than for// the internal status word: "ready" alone did not answer "does this card have a@@ -60,6 +60,7 @@ export default function DeckCardGrid({return { key, label: cards[0].groupLabel || key, cards, counts, needPrompt: counts.total - counts.prompted };});}, [deck.cards]);+ const cardSize = deckCardSize(deck);return (<div className="space-y-6">@@ -95,6 +96,8 @@ export default function DeckCardGrid({<li key={card.id} className="flex h-full flex-col items-center gap-1.5 rounded-lg border border-port-border bg-port-card p-2"><EntryThumbSlotsize="xl"+ fluid+ aspectRatio={cardSize}rounded={false}inFlightJobId={inFlight}imageRefs={card.imageRefs}diff --git a/client/src/components/decks/DeckCardGrid.test.jsx b/client/src/components/decks/DeckCardGrid.test.jsxindex 97cc292a9e..85e59cd150 100644--- a/client/src/components/decks/DeckCardGrid.test.jsx+++ b/client/src/components/decks/DeckCardGrid.test.jsx@@ -14,6 +14,8 @@ const card = (id, group, extra = {}) => ({});const deck = {id: 'd1',+ kind: 'playing',+ cardSize: { width: 1096, height: 1536 },cards: [card('a', 'major', { prompt: 'a fool' }),card('b', 'major', { prompt: 'a magician', imageRefs: ['b.png'], primaryImageRef: 'b.png', canonRef: { kind: 'character', id: 'c1', name: 'Alice' } }),@@ -168,4 +170,27 @@ describe('DeckCardGrid', () => {fireEvent.click(nextBtn);expect(screen.getByText('v2/3')).toBeInTheDocument();});++ it('sizes a playing-card thumb to 5:7 and contains the art so the index is not cropped', () => {+ renderGrid();+ const img = screen.getByRole('img', { name: 'Card b' });+ expect(img.className).toMatch(/\bobject-contain\b/);+ expect(img.className).not.toMatch(/\bobject-cover\b/);+ expect(img.closest('.overflow-hidden')?.style.aspectRatio).toBe('1096 / 1536');+ });++ it('sizes a tarot thumb to 11:19 so the title banner is not cropped', () => {+ const tarotDeck = {+ id: 'd1',+ kind: 'tarot',+ cardSize: { width: 888, height: 1536 },+ cards: [+ card('f', 'major', { prompt: 'the fool', imageRefs: ['fool.png'], primaryImageRef: 'fool.png' }),+ ],+ };+ renderGrid({ deck: tarotDeck });+ const img = screen.getByRole('img', { name: 'Card f' });+ expect(img.className).toMatch(/\bobject-contain\b/);+ expect(img.closest('.overflow-hidden')?.style.aspectRatio).toBe('888 / 1536');+ });});diff --git a/client/src/components/decks/DeckStylePanel.jsx b/client/src/components/decks/DeckStylePanel.jsxindex af2bcbb76a..a1ccdc0bdf 100644--- a/client/src/components/decks/DeckStylePanel.jsx+++ b/client/src/components/decks/DeckStylePanel.jsx@@ -3,7 +3,7 @@ import { ImagePlus, Trash2 } from 'lucide-react';import InfluenceChipsInput from '../universeBuilder/InfluenceChipsInput';import DeckSampleModal from './DeckSampleModal';import useFieldDraft from '../../hooks/useFieldDraft';-import { DECK_KIND_LABELS } from '../../lib/decks';+import { DECK_KIND_LABELS, deckCardAspectStyle } from '../../lib/decks';const INPUT_CLASS = 'w-full bg-port-bg border border-port-border rounded-lg px-3 py-2 text-sm text-white focus:outline-none focus:border-port-accent';@@ -89,7 +89,8 @@ export default function DeckStylePanel({ deck, universes, onPatch, onDeckReplace<imgsrc={`/data/images/${encodeURIComponent(sample.imageRef || '')}`}alt={sample.title}- className="h-24 w-16 shrink-0 rounded object-cover bg-port-bg"+ style={deckCardAspectStyle(deck)}+ className="w-16 shrink-0 rounded object-contain bg-port-bg"/><div className="min-w-0 flex-1"><div className="flex items-start justify-between gap-2">diff --git a/client/src/components/universe/EntryThumbSlot.jsx b/client/src/components/universe/EntryThumbSlot.jsxindex f81fcd550c..d9031bcd68 100644--- a/client/src/components/universe/EntryThumbSlot.jsx+++ b/client/src/components/universe/EntryThumbSlot.jsx@@ -32,6 +32,33 @@ const THUMB_DIMENSIONS = {sheet: 'w-20 h-30 xl:w-40 xl:h-60',};+// Width-only tokens used when the host supplies a canvas (`aspectRatio`) so+// height comes from that ratio instead of the 2:3 `h-*` above. Playing cards+// are 5:7 and tarot 11:19; a 2:3 `object-cover` box crops their edges.+const THUMB_WIDTH = {+ sm: 'w-12',+ lg: 'w-16',+ xl: 'w-40',+ sheet: 'w-20 xl:w-40',+};++const isPositiveEdge = (value) => Number.isFinite(value) && value > 0;++function thumbFrameProps(size, aspectRatio, { fluid = false } = {}) {+ const valid = isPositiveEdge(aspectRatio?.width) && isPositiveEdge(aspectRatio?.height);+ if (!valid) {+ return {+ className: `${THUMB_DIMENSIONS[size] || THUMB_DIMENSIONS.sm} shrink-0`,+ style: undefined,+ };+ }+ const widthClass = fluid ? 'w-full' : (THUMB_WIDTH[size] || THUMB_WIDTH.sm);+ return {+ className: `${widthClass} shrink-0`,+ style: { aspectRatio: `${aspectRatio.width} / ${aspectRatio.height}` },+ };+}+export default function EntryThumbSlot({inFlightJobId = null,imageRefs = null,@@ -76,6 +103,14 @@ export default function EntryThumbSlot({// 1024x1536 universe renders so the slot doesn't crop the subject.size = 'sm',rounded = true,+ // Optional canvas `{ width, height }`. When set, the slot's box uses that+ // ratio (instead of the size token's 2:3 height) and the image `object-contain`s+ // so a playing-card or tarot trim is not cropped by the default portrait box.+ aspectRatio = null,+ // Stretch to the host's width. Only applies together with `aspectRatio` —+ // without a ratio, a `w-full` box has no height. Used by the deck grid so+ // each card fills its tile at the deck's own trim.+ fluid = false,}) {// MediaJobThumb fires this from an effect keyed on `[effectiveStatus, onStatus]`,// so it must not be a fresh arrow per render or it re-fires on every parent@@ -97,8 +132,9 @@ export default function EntryThumbSlot({// host would have to reserve the height itself to stop the row jumping when// a render starts and again when it finishes.const pendingSize = size === 'xl' ? 'lg' : size === 'lg' ? 'sm' : 'xs';+ const pendingBox = thumbFrameProps(size, aspectRatio, { fluid });return (- <div className={`${THUMB_DIMENSIONS[size] || THUMB_DIMENSIONS.sm} shrink-0 flex items-center justify-center`}>+ <div className={`${pendingBox.className} flex items-center justify-center`} style={pendingBox.style}><MediaJobThumbjobId={inFlightJobId}label={alt}@@ -135,6 +171,8 @@ export default function EntryThumbSlot({onClick={onPreview}size={size}rounded={rounded}+ aspectRatio={aspectRatio}+ fluid={fluid}/>);}@@ -142,7 +180,7 @@ export default function EntryThumbSlot({// (48x80 / 64x96 / 160x240) matches the 2:3 aspect of typical universe// renders so the row reserves the same vertical space as WalkBackThumb's// completed image, eliminating row jitter across the three states.- const dim = THUMB_DIMENSIONS[size] || THUMB_DIMENSIONS.sm;+ const emptyBox = thumbFrameProps(size, aspectRatio, { fluid });const iconSize = size === 'xl' ? 32 : size === 'lg' ? 18 : 14;const hint = canRender && onRender ? emptyHint : disabledHint;return (@@ -151,7 +189,8 @@ export default function EntryThumbSlot({onClick={() => onRender?.()}disabled={!onRender || !canRender}title={hint} aria-label={hint}- className={`${dim} shrink-0 flex items-center justify-center ${rounded ? 'rounded' : ''} border border-dashed border-port-border bg-port-bg/40 text-gray-500 hover:border-port-accent/50 hover:text-port-accent hover:bg-port-accent/5 disabled:opacity-40 disabled:cursor-not-allowed disabled:hover:border-port-border disabled:hover:text-gray-500 disabled:hover:bg-port-bg/40 transition-colors`}+ style={emptyBox.style}+ className={`${emptyBox.className} flex items-center justify-center ${rounded ? 'rounded' : ''} border border-dashed border-port-border bg-port-bg/40 text-gray-500 hover:border-port-accent/50 hover:text-port-accent hover:bg-port-accent/5 disabled:opacity-40 disabled:cursor-not-allowed disabled:hover:border-port-border disabled:hover:text-gray-500 disabled:hover:bg-port-bg/40 transition-colors`}><EmptyIcon size={iconSize} /></button>@@ -163,7 +202,10 @@ export default function EntryThumbSlot({// (stale gallery file → walk back through prior renders → collapse). Mirrors// `EntryCardThumbnail` in `EntryCard.jsx`; intentionally kept in sync — visual// drift would defeat the point of a shared slot.-function WalkBackThumb({ filename, alt, onClick, isPrimary = false, fallbackRefs = null, size = 'sm', rounded = true }) {+function WalkBackThumb({+ filename, alt, onClick, isPrimary = false, fallbackRefs = null, size = 'sm', rounded = true,+ aspectRatio = null, fluid = false,+}) {const candidates = [];if (filename) candidates.push(filename);if (Array.isArray(fallbackRefs)) {@@ -177,26 +219,35 @@ function WalkBackThumb({ filename, alt, onClick, isPrimary = false, fallbackRefsconst candidateKey = candidates.join('|');const [idx, setIdx] = useState(0);useEffect(() => { setIdx(0); }, [candidateKey]);- const dim = THUMB_DIMENSIONS[size] || THUMB_DIMENSIONS.sm;+ const box = thumbFrameProps(size, aspectRatio, { fluid });if (!candidates.length || idx >= candidates.length) {// All candidates failed to load — collapse to empty (no render button// here; the user can re-render from the action column).- return <div className={`${dim} shrink-0 ${rounded ? 'rounded' : ''} border border-port-border bg-port-bg/40`} />;+ return (+ <div+ className={`${box.className} ${rounded ? 'rounded' : ''} border border-port-border bg-port-bg/40`}+ style={box.style}+ />+ );}const currentFilename = candidates[idx];+ const contain = isPositiveEdge(aspectRatio?.width) && isPositiveEdge(aspectRatio?.height);const img = (<imgsrc={`/data/images/${currentFilename}`}alt={alt || currentFilename}- className="w-full h-full object-cover"+ className={`w-full h-full ${contain ? 'object-contain' : 'object-cover'}`}loading="lazy"onError={() => setIdx((n) => n + 1)}/>);const frame = (- <div className={`relative ${dim} shrink-0 ${rounded ? 'rounded' : ''} overflow-hidden border ${- isPrimary ? 'border-port-accent' : 'border-port-border'- }`}>+ <div+ className={`relative ${box.className} ${rounded ? 'rounded' : ''} overflow-hidden border bg-port-bg ${+ isPrimary ? 'border-port-accent' : 'border-port-border'+ }`}+ style={box.style}+ >{img}{isPrimary ? (<span@@ -215,7 +266,7 @@ function WalkBackThumb({ filename, alt, onClick, isPrimary = false, fallbackRefsonClick={() => onClick(currentFilename)}title={`Preview ${alt || currentFilename}`}aria-label={`Preview ${alt || currentFilename}`}- className="p-0 bg-transparent border-0 cursor-zoom-in"+ className={`p-0 bg-transparent border-0 cursor-zoom-in ${fluid ? 'w-full' : ''}`}>{frame}</button>diff --git a/client/src/components/universe/EntryThumbSlot.test.jsx b/client/src/components/universe/EntryThumbSlot.test.jsxindex 3db68b4da5..407ee72f67 100644--- a/client/src/components/universe/EntryThumbSlot.test.jsx+++ b/client/src/components/universe/EntryThumbSlot.test.jsx@@ -125,6 +125,39 @@ describe('EntryThumbSlot — three-state thumbnail', () => {expect(frame?.className).not.toMatch(/\brounded\b/);});+ it('sizes the slot to a supplied canvas and contains the image instead of covering', () => {+ const { container } = render(+ <EntryThumbSlot+ imageRefs={['two-of-spades.png']}+ alt="Two of Spades"+ size="xl"+ fluid+ aspectRatio={{ width: 1096, height: 1536 }}+ rounded={false}+ />,+ );+ const img = screen.getByRole('img', { name: 'Two of Spades' });+ expect(img.className).toMatch(/\bobject-contain\b/);+ expect(img.className).not.toMatch(/\bobject-cover\b/);+ const frame = container.querySelector('.overflow-hidden');+ expect(frame?.style.aspectRatio).toBe('1096 / 1536');+ expect(frame?.className).toMatch(/\bw-full\b/);+ expect(frame?.className).not.toMatch(/\bh-60\b/);+ });++ it('keeps the 2:3 cover box when no canvas is supplied', () => {+ const { container } = render(+ <EntryThumbSlot+ imageRefs={['canon.png']}+ alt="Canon"+ size="xl"+ />,+ );+ const img = screen.getByRole('img', { name: 'Canon' });+ expect(img.className).toMatch(/\bobject-cover\b/);+ expect(container.querySelector('.overflow-hidden')?.className).toMatch(/\bh-60\b/);+ });+it('renders displayedImageRef when specified among imageRefs', () => {render(<EntryThumbSlotdiff --git a/client/src/hooks/useDeckRenderTarget.js b/client/src/hooks/useDeckRenderTarget.jsindex de8b2f932a..2c0e7daaab 100644--- a/client/src/hooks/useDeckRenderTarget.js+++ b/client/src/hooks/useDeckRenderTarget.js@@ -1,6 +1,6 @@import useImageRenderSettings from './useImageRenderSettings';import useLocalImageRuntime from './useLocalImageRuntime';-import { DECK_CARD_SIZE } from '../lib/decks';+import { deckCardSize } from '../lib/decks';import { IMAGE_GEN_MODE, IMAGE_RUNTIME_READINESS, RENDER_TARGET, modeLabel } from '../lib/imageGenBackends';/**@@ -18,7 +18,7 @@ import { IMAGE_GEN_MODE, IMAGE_RUNTIME_READINESS, RENDER_TARGET, modeLabel } fro*/export default function useDeckRenderTarget(deck) {const { imageCfg, backends } = useImageRenderSettings({ record: deck, target: RENDER_TARGET.DECK });- const size = deck?.cardSize || DECK_CARD_SIZE;+ const size = deckCardSize(deck);// `backends` is empty until the settings fetch lands, and until then imageCfg// is the UNRESOLVED placeholder (local + the install default) — probing on// that asks about the wrong model, and about a local runtime a cloud-pinneddiff --git a/client/src/lib/README.md b/client/src/lib/README.mdindex d088b6fded..9a0c4050fa 100644--- a/client/src/lib/README.md+++ b/client/src/lib/README.md@@ -88,7 +88,7 @@ grep -i "what you want to do" client/src/lib/README.md| `wrImageDefaults.js` | Writers Room per-scene image-gen defaults + style discriminators. || `imageGenBackends.js` | Icon metadata, `deriveAvailableBackends`, and `imageGenReadiness(status)` — a compatibility-safe `ready` / `unavailable` / `unknown` read of image-gen status responses; re-exports everything from `imageGenModes.js` so consumers keep one import site. || `imageGenModes.js` | Node-safe image/video backend constants + pure helpers. Re-exports the backend / render-target / lane alphabets from the server leaves `server/lib/generationModes.js` + `server/lib/renderTargets.js` (see its header for why nothing is copied); adds the Settings rows (`RENDER_TARGET_OPTIONS`), `applyRecordRenderPin` (fold a record's `imageMode`/`imageModelId` pin over a settings-derived cfg), `isCloudCliMode`/`isCloudVideoMode`, `modeLabel`, `mediaJobLane` (a projected media job's scheduler lane, re-derived for responses predating the server's `executionLane` field), and the cloud/model-override/i2i capability mirrors of the server service specs. Imported by the server-side parity suite — must stay importable without client packages. |-| `decks.js` | Deck alphabet, card roster/status/completion rules and render-prompt composition — re-exported from `server/lib/deckTemplates.js` (one definition, no client copy). |+| `decks.js` | Deck alphabet, card roster/status/completion rules, render-prompt composition, and `deckCardSize` / `deckCardAspectStyle` (thumbnail box from the deck's trim) — re-exported from `server/lib/deckTemplates.js` (one definition, no client copy). || `imageGenDefaults.js` | Shared `DEFAULT_NEGATIVE_PROMPT` used by the Image Gen form and quick-submit entry points. Mirrors server-side default. || `imageGenResolutions.js` | Shared resolution presets for image generation. || `imageTo3dReasons.js` | Client mirror of the image-to-3D unavailable-reason labels in `server/services/imageTo3d/targets.js`: `UNAVAILABLE_REASONS` (reason code → user-facing label), `UNAVAILABLE_REASON_FALLBACK`, and `unavailableReasonLabel(code, fallback?)`, plus `isTargetReady(target)` — the shared readiness predicate (`installed` is tri-state: `null` = a hosted lane with no install concept, ready as soon as it is available). Use these anywhere a target's `unavailableReason` or readiness is rendered — never re-declare the codes or re-derive readiness from `target.installed` truthiness. Parity + code coverage enforced by `server/services/imageTo3d/unavailableReasons.parity.test.js`. |diff --git a/client/src/lib/decks.js b/client/src/lib/decks.jsindex 9f1b898a19..c462f4ba6f 100644--- a/client/src/lib/decks.js+++ b/client/src/lib/decks.js@@ -15,5 +15,7 @@ export {cardInFlightJobId,cardStatus,composeCardRenderPrompt,+ deckCardAspectStyle,+ deckCardSize,deckCompletion,} from '../../../server/lib/deckTemplates.js';diff --git a/client/src/lib/imageGenResolutions.js b/client/src/lib/imageGenResolutions.jsindex 1a1f5df7e3..6a4205848d 100644--- a/client/src/lib/imageGenResolutions.js+++ b/client/src/lib/imageGenResolutions.js@@ -38,8 +38,8 @@ export const RESOLUTIONS = [{ label: '1988×3056 (comic page — hi-res, full bleed)', w: 1988, h: 3056, compatible: ['codex'] },// Poker/tarot card trims at true physical ratio (2.5"×3.5" = 5:7 and// 2.75"×4.75" respectively), sized to a 300dpi print resolution and a 2x- // hi-res doubling. Distinct from the Decks feature's DECK_CARD_SIZE- // (deckTemplates.js, a rounded 2:3 render frame shared by both card kinds)+ // hi-res doubling. Distinct from the Decks feature's per-kind DECK_CARD_SIZE_BY_KIND+ // (deckTemplates.js, 5:7 poker / 11:19 tarot at a 1536 long edge)// — these are for a standalone card-shaped image outside the deck workflow.// Codex-only: the ratios are too specialty for the local runners' trained// aspect windows.diff --git a/server/lib/README.md b/server/lib/README.mdindex 0640335eed..854fef35aa 100644--- a/server/lib/README.md+++ b/server/lib/README.md@@ -656,5 +656,5 @@ pm` default, `NPM_CONFIG_PREFIX`, nvm/Volta) installed `codex` successfully and| `auditQuality.js` | Category discovery strategies, assessment prompt and strict schema, sentinel parsing, and freshness-aware app quality aggregation with deterministic latest-per-category selection across peers. || `mindToolRecipes.js` | Closed recipe schemas, current semantic-contract validation, and safe JSON field binding resolution. |-| `deckTemplates.js` | Decks (playing cards / tarot): kind alphabet, per-kind card roster (`deckCardRoster`), shared layout clause, render prompt composition (`composeCardRenderPrompt`), per-card status and `deckCompletion`. Pure — re-exported by `client/src/lib/decks.js`. |+| `deckTemplates.js` | Decks (playing cards / tarot): kind alphabet, per-kind card roster (`deckCardRoster`), shared layout clause, render prompt composition (`composeCardRenderPrompt`), per-card status and `deckCompletion`, plus `deckCardSize` / `deckCardAspectStyle` (persisted trim → thumbnail box). Pure — re-exported by `client/src/lib/decks.js`. || `deckValidation.js` | Zod schemas + limits for the `/api/decks` routes (create/update deck, card patch, sample analysis, prompt generation, render). |diff --git a/server/lib/deckTemplates.js b/server/lib/deckTemplates.jsindex 9d30f576ce..2a9d253932 100644--- a/server/lib/deckTemplates.js+++ b/server/lib/deckTemplates.js@@ -39,15 +39,39 @@ export const DECK_CARD_SIZE_MAX = 4096;// Per-kind default card size, at each kind's true physical trim ratio rather// than the generic 2:3 fallback above — poker cards are 2.5"×3.5" (5:7),// tarot cards are 2.75"×4.75" (11:19). Both hold the same 1536 long edge as-// the generic default so render cost/detail stays comparable; `EntryThumbSlot`-// renders with `object-cover`, so the modest difference from 2:3 crops fine-// rather than distorting. A deck's own `cardSize` (persisted per-deck, see-// `services/decks.js`) always wins — this is only the value new decks mint.+// the generic default so render cost/detail stays comparable. Thumbnails size+// their slot to this ratio and contain the image (`deckCardSize` /+// `deckCardAspectStyle`) so the rank, index, title banner and decorative+// border stay in frame — a 2:3 `object-cover` box crops playing cards on the+// sides and tarot cards top/bottom. A deck's own `cardSize` (persisted+// per-deck, see `services/decks.js`) always wins — this is only the value+// new decks mint.export const DECK_CARD_SIZE_BY_KIND = Object.freeze({[DECK_KIND.PLAYING]: Object.freeze({ width: 1096, height: 1536 }),[DECK_KIND.TAROT]: Object.freeze({ width: 888, height: 1536 }),});+const isPositiveEdge = (value) => Number.isFinite(value) && value > 0;++/**+ * The canvas a deck's cards actually render at: the persisted `cardSize` when+ * both edges are positive, otherwise that kind's trim, otherwise the 2:3+ * fallback. One read so the grid, drawer, sample thumbs and render-target+ * summary cannot disagree about the box.+ */+export function deckCardSize(deck) {+ const width = Number(deck?.cardSize?.width);+ const height = Number(deck?.cardSize?.height);+ if (isPositiveEdge(width) && isPositiveEdge(height)) return { width, height };+ return { ...(DECK_CARD_SIZE_BY_KIND[deck?.kind] || DECK_CARD_SIZE) };+}++/** Inline `style.aspectRatio` for a card thumbnail, derived from `deckCardSize`. */+export function deckCardAspectStyle(deck) {+ const { width, height } = deckCardSize(deck);+ return { aspectRatio: `${width} / ${height}` };+}+// The one card every deck has that is not a face: the shared back design.export const DECK_BACK_KEY = 'back';diff --git a/server/lib/deckTemplates.test.js b/server/lib/deckTemplates.test.jsindex 795086e7e1..b76605cf42 100644--- a/server/lib/deckTemplates.test.js+++ b/server/lib/deckTemplates.test.js@@ -1,7 +1,7 @@import { describe, it, expect } from 'vitest';import {- CARD_STATUS, DECK_BACK_KEY, DECK_CARD_SIZE_BY_KIND, DECK_KIND, DECK_KINDS, DEFAULT_LAYOUT_PROMPT,- cardStatus, composeCardRenderPrompt, deckCardRoster, deckCompletion,+ CARD_STATUS, DECK_BACK_KEY, DECK_CARD_SIZE, DECK_CARD_SIZE_BY_KIND, DECK_KIND, DECK_KINDS, DEFAULT_LAYOUT_PROMPT,+ cardStatus, composeCardRenderPrompt, deckCardAspectStyle, deckCardRoster, deckCardSize, deckCompletion,} from './deckTemplates.js';import { aspectRatioPhrase } from './aspectRatio.js';@@ -81,6 +81,31 @@ describe('cardStatus + deckCompletion', () => {});});+describe('deckCardSize', () => {+ it('prefers the persisted canvas over the kind default', () => {+ expect(deckCardSize({ kind: DECK_KIND.PLAYING, cardSize: { width: 800, height: 1200 } }))+ .toEqual({ width: 800, height: 1200 });+ });++ it('falls back to each kind\'s true trim, not the generic 2:3 box', () => {+ expect(deckCardSize({ kind: DECK_KIND.PLAYING })).toEqual(DECK_CARD_SIZE_BY_KIND[DECK_KIND.PLAYING]);+ expect(deckCardSize({ kind: DECK_KIND.TAROT })).toEqual(DECK_CARD_SIZE_BY_KIND[DECK_KIND.TAROT]);+ expect(deckCardSize({})).toEqual(DECK_CARD_SIZE);+ });++ it('ignores a half-set or non-positive cardSize rather than inventing a ratio', () => {+ expect(deckCardSize({ kind: DECK_KIND.TAROT, cardSize: { width: 800 } }))+ .toEqual(DECK_CARD_SIZE_BY_KIND[DECK_KIND.TAROT]);+ expect(deckCardSize({ kind: DECK_KIND.PLAYING, cardSize: { width: 0, height: 1536 } }))+ .toEqual(DECK_CARD_SIZE_BY_KIND[DECK_KIND.PLAYING]);+ });++ it('exposes the CSS aspect-ratio the thumbnail box must use', () => {+ expect(deckCardAspectStyle({ kind: DECK_KIND.PLAYING }).aspectRatio).toBe('1096 / 1536');+ expect(deckCardAspectStyle({ kind: DECK_KIND.TAROT }).aspectRatio).toBe('888 / 1536');+ });+});+describe('DEFAULT_LAYOUT_PROMPT', () => {it('states the framing its own canvas actually renders at', () => {// The defect this pins: both clauses said "2:3 portrait" while the per-kind