Skip to content

fix(book): every image frame shows a different photo - #62

Merged
patriksimms merged 2 commits into
mainfrom
feat/distribute-photos-across-frames
Aug 19, 2026
Merged

fix(book): every image frame shows a different photo#62
patriksimms merged 2 commits into
mainfrom
feat/distribute-photos-across-frames

Conversation

@patriksimms

@patriksimms patriksimms commented Aug 18, 2026

Copy link
Copy Markdown
Owner

Problem

As an organizer I want each image frame in a layout to show a different contributor photo, so a page with three frames tells a story instead of printing the same photo three times.

Every frame bound to a question rendered images[0], in three separately derived places. On top of that, preflight compared the photo count against a single element's slots, so an image frame on a question that allows two uploads raised a blocking gallery-overflow problem and stopped the export outright.

Solution

One shared assignment function (src/domain/photo-assignment.ts) maps a response's photos to the frames bound to each question, in visual reading order (top to bottom, then left to right, element id as final tiebreak). Preview, PDF export, and preflight all read from it, so a preflight warning always describes the photo that actually prints, and the mapping is stable across regenerations and relayering.

A gallery consumes its slots as one contiguous block at its position in that order.

Photo/slot mismatches in either direction now raise one non-blocking, question-scoped photo-slot-mismatch page problem instead of blocking export, and the layout editor flags a slot count that does not match a question's maximum image count while the layout is being designed.

Closes #60

Notes for review

  • The first commit is a CI fix, not part of the feature. verify has failed on main since ddd2194: the RustFS bind mounts create .local/ as root, after which the workflow user cannot create .local/icc. Running setup:icc before docker compose up restores it. Without it this branch could not reach a green gate.
  • gallery-overflow stays accepted by the persisted-book validator so books written before the rename remain loadable and re-saveable; nothing produces it any more.
  • A frame that stays empty now raises a warning even when the contributor uploaded no photos for an optional question. That follows the issue directly and surfaces blank frames during review, but it does make optional photo questions noisier on the review screen.
  • The layout parity baselines were regenerated: the fixture binds an image frame and a gallery frame to the same question, so it now demonstrates the distribution.

Validation

bun run verify locally (format, lint, typecheck, 231 unit tests, 21 Playwright tests, build, compose checks) and green CI on 37f7fd7.

Before and after screenshots are attached to #60.


Delivered by Claude Opus 5 (1M context) in Claude Code.

@patriksimms
patriksimms force-pushed the feat/distribute-photos-across-frames branch from 11afa29 to 5c24033 Compare August 18, 2026 21:48
Summary:
- run setup:icc before docker compose so the runner still owns .local

Rationale:
- the RustFS bind mounts create .local as root, after which the workflow user
  can no longer create .local/icc, failing every run since ddd2194

Tests:
- CI

AI-Assisted: true
AI-Agent: claude-code
AI-Model: anthropic/claude-opus-5
AI-Assisted-By: Codex
Summary:
- distribute a response's photos across the frames bound to each question,
  in visual reading order, from one shared assignment function
- read preview, PDF export, and preflight from that single assignment
- replace the blocking gallery-overflow problem with a non-blocking,
  question-scoped photo-slot-mismatch problem covering under- and overflow
- warn in the layout editor when a question's slot count does not match its
  configured maximum image count

Rationale:
- every frame bound to a question rendered images[0], so a layout with three
  image frames printed the same photo three times
- preflight compared the photo count against a single element's slots, so an
  image frame on a two-upload question blocked export outright
- deriving preview, export, and preflight from one function keeps a reported
  problem describing the photo that actually prints

Tests:
- bun run verify

Closes #60

AI-Assisted: true
AI-Agent: claude-code
AI-Model: anthropic/claude-opus-5
AI-Assisted-By: Codex
@patriksimms
patriksimms force-pushed the feat/distribute-photos-across-frames branch from cc5e5ce to 37f7fd7 Compare August 18, 2026 21:56
@patriksimms
patriksimms marked this pull request as ready for review August 18, 2026 22:00
@patriksimms
patriksimms merged commit af40134 into main Aug 19, 2026
2 checks passed
@patriksimms
patriksimms deleted the feat/distribute-photos-across-frames branch August 19, 2026 07:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Distribute uploaded photos across all image frames on a page

1 participant