feat(web): zoom suggestion-carousel tiles onto the ref's boundingBox #1054

Merged
chris merged 2 commits from feat/carousel-face-zoom-web into main 2026-10-07 06:17:48 +02:00
Owner

What

Adds the boundingBox zoom lane to the suggestions carousel (apps/web only), giving suggestion tiles the same face-framing result as the people page's "Vis område" toggle.

The carousel already had a zoom lane driven by the scope enrichment (ScopedInstanceThumbnail + bboxCropStyle, 1:1 pixels, no upscale). This PR adds the parallel lane contracted on the camelCase boundingBox field, using scopeCropFit — the exact pattern DiscoveryInstanceDetail uses for "Vis område".

Behaviour

Ref carries boundingBox (and a media item):

  • The tile renders the whole photo at /api/media/{mediaItemId}/derived/thumbnail?size=512.
  • The wrapper gets a scopeCropFit transform (tileAspect = 1, allowSliceShift: true) that frames the face; object-position comes from the same fit, object-cover is kept.
  • Aspect ratio is measured off the rendered <img> (naturalWidth/Height into a SvelteMap), so the tile renders untransformed until the first load — no flash of a wrong crop.
  • group-hover:scale-105 is dropped on these tiles so the hover scale cannot fight the bbox transform. loading="lazy", alt texts and the rest of the card markup are untouched.

Ref without boundingBox (or with an unusable box / no media item):

  • Exactly today's rendering, in the existing order: scope zoom → face crop → derived thumbnail → "No preview". The parser is defensive: boundingBox or bounding_box, non-numeric/zero/negative values → treated as absent.

Safe to ship in any API order — the PR it pairs with (apps/api #1053) has already merged and mirrors scope into boundingBox; this UI only feature-detects.

Changes

  • apps/web/src/lib/api/discovery.ts — typed optional boundingBox on ClassInstanceCandidateOccurrenceRef.
  • apps/web/src/lib/components/DomainSuggestionsCarousel.svelte — refBoundingBox parser, refFullPhotoUrl, fit lane on refPreview, measured-aspect SvelteMap, and a shared refTileMedia snippet so card tiles and detail-dialog crops render identically.
  • apps/web/tests/discovery-review.spec.ts — two new specs: box present (transform wrapper + ?size=512 src, no face-crop request, dialog parity) and malformed box (falls back to the unchanged face crop).

Verification

  • npm run check — 0 errors (22 pre-existing warnings, none in touched files)
  • npm run test:unit — 66/66 passed
  • npm test — 801 passed, 0 failed, 23 skipped; 2 flaky (plant-assignment.spec.ts hover/amber-border, pre-existing, passed on retry)
  • tests/discovery-review.spec.ts full run — 122/122 passed
## What Adds the `boundingBox` zoom lane to the suggestions carousel (apps/web only), giving suggestion tiles the same face-framing result as the people page's **"Vis område"** toggle. The carousel already had a zoom lane driven by the `scope` enrichment (`ScopedInstanceThumbnail` + `bboxCropStyle`, 1:1 pixels, no upscale). This PR adds the parallel lane contracted on the camelCase `boundingBox` field, using `scopeCropFit` — the exact pattern `DiscoveryInstanceDetail` uses for "Vis område". ## Behaviour **Ref carries `boundingBox` (and a media item):** - The tile renders the **whole photo** at `/api/media/{mediaItemId}/derived/thumbnail?size=512`. - The wrapper gets a `scopeCropFit` transform (`tileAspect = 1`, `allowSliceShift: true`) that frames the face; `object-position` comes from the same fit, `object-cover` is kept. - Aspect ratio is measured off the rendered `<img>` (`naturalWidth/Height` into a `SvelteMap`), so the tile renders **untransformed until the first load** — no flash of a wrong crop. - `group-hover:scale-105` is dropped on these tiles so the hover scale cannot fight the bbox transform. `loading="lazy"`, alt texts and the rest of the card markup are untouched. **Ref without `boundingBox` (or with an unusable box / no media item):** - Exactly today's rendering, in the existing order: `scope` zoom → face crop → derived thumbnail → "No preview". The parser is defensive: `boundingBox` *or* `bounding_box`, non-numeric/zero/negative values → treated as absent. Safe to ship in **any API order** — the PR it pairs with (apps/api #1053) has already merged and mirrors `scope` into `boundingBox`; this UI only feature-detects. ## Changes - `apps/web/src/lib/api/discovery.ts` — typed optional `boundingBox` on `ClassInstanceCandidateOccurrenceRef`. - `apps/web/src/lib/components/DomainSuggestionsCarousel.svelte` — `refBoundingBox` parser, `refFullPhotoUrl`, `fit` lane on `refPreview`, measured-aspect `SvelteMap`, and a shared `refTileMedia` snippet so card tiles and detail-dialog crops render identically. - `apps/web/tests/discovery-review.spec.ts` — two new specs: box present (transform wrapper + `?size=512` src, no face-crop request, dialog parity) and malformed box (falls back to the unchanged face crop). ## Verification - `npm run check` — 0 errors (22 pre-existing warnings, none in touched files) - `npm run test:unit` — 66/66 passed - `npm test` — **801 passed**, 0 failed, 23 skipped; 2 flaky (`plant-assignment.spec.ts` hover/amber-border, pre-existing, passed on retry) - `tests/discovery-review.spec.ts` full run — 122/122 passed
feat(web): zoom suggestion-carousel tiles onto the ref's boundingBox
Some checks failed
Wiki Sync / Sync wiki from docs (push) Has been skipped
Build and Deploy / Detect changed services and test scopes (push) Successful in 2s
Build and Deploy / Android unit tests and debug APK (push) Has been skipped
Build and Deploy / Smoke API and media worker (push) Has been skipped
Build and Deploy / Smoke web (push) Has been skipped
Build and Deploy / Smoke ML worker (push) Has been skipped
Build and Deploy / Smoke people worker (push) Has been skipped
Build and Deploy / Build postgres image (push) Has been skipped
Build and Deploy / Build plants worker image (push) Has been skipped
Build and Deploy / Build converter worker image (push) Has been skipped
Build and Deploy / Deploy postgres (push) Has been skipped
Build and Deploy / Build API image (push) Has been skipped
Build and Deploy / Build media worker image (push) Has been skipped
Build and Deploy / Build ML worker image (push) Has been skipped
Build and Deploy / Build people worker image (push) Has been skipped
Build and Deploy / Build web image (push) Has been skipped
Build and Deploy / Deploy API (push) Has been skipped
Build and Deploy / Deploy web (push) Has been skipped
Build and Deploy / Deploy media worker (push) Has been skipped
Build and Deploy / Deploy ML worker (push) Has been skipped
Build and Deploy / Deploy plants worker (push) Has been skipped
Build and Deploy / Deploy people worker (push) Has been skipped
Build and Deploy / Deploy converter worker (push) Has been skipped
Build and Deploy / Clean Docker build artifacts (push) Has been skipped
Build and Deploy / Run scoped PR tests (push) Failing after 2m40s
06c803a09b
The suggestions carousel already zooms tiles via the `scope` enrichment
(ScopedInstanceThumbnail + bboxCropStyle, 1:1 pixels, no upscale). This adds
the parallel lane the API now ships: refs may carry their own `boundingBox`
(normalized [0,1] face box, camelCase contract field) and, when they do, the
tile renders the WHOLE photo at derived/thumbnail?size=512 and zooms it onto
the box with scopeCropFit — the same result as the people page's "Vis område"
toggle.

- discovery.ts: typed optional `boundingBox` on
  ClassInstanceCandidateOccurrenceRef, documented as additive + safe to deploy
  in any API order.
- DomainSuggestionsCarousel.svelte: defensive `refBoundingBox` parser
  (feature-detects boundingBox/bounding_box, rejects malformed or non-positive
  shapes), `refFullPhotoUrl`, and a `fit` lane on refPreview that wins only
  when a box AND a media item resolve. A shared `refTileMedia` snippet renders
  both lanes so card tiles and detail-dialog crops stay identical.
  Aspect is measured off the rendered <img> into a SvelteMap, so the wrapper
  stays untransformed until first load; object-cover is kept and
  group-hover:scale-105 is dropped on zoomed tiles so it cannot fight the
  transform.
- Absent/unusable box → today's rendering exactly: scope zoom → face crop →
  derived → "No preview". No toggle, no new deps, lazy loading and alt texts
  unchanged.

Tests: two new Playwright specs in discovery-review.spec.ts — box present
(transform wrapper + ?size=512 src, no face-crop request, dialog parity) and
malformed box (falls back to the unchanged face crop).
test(web): fix merge-suggestion route glob so carousel face-zoom specs run hermetically
All checks were successful
Wiki Sync / Sync wiki from docs (push) Has been skipped
Build and Deploy / Detect changed services and test scopes (push) Successful in 2s
Build and Deploy / Android unit tests and debug APK (push) Has been skipped
Build and Deploy / Smoke API and media worker (push) Has been skipped
Build and Deploy / Smoke web (push) Has been skipped
Build and Deploy / Smoke ML worker (push) Has been skipped
Build and Deploy / Smoke people worker (push) Has been skipped
Build and Deploy / Build postgres image (push) Has been skipped
Build and Deploy / Build plants worker image (push) Has been skipped
Build and Deploy / Build converter worker image (push) Has been skipped
Build and Deploy / Deploy postgres (push) Has been skipped
Build and Deploy / Build API image (push) Has been skipped
Build and Deploy / Build media worker image (push) Has been skipped
Build and Deploy / Build ML worker image (push) Has been skipped
Build and Deploy / Build people worker image (push) Has been skipped
Build and Deploy / Build web image (push) Has been skipped
Build and Deploy / Deploy API (push) Has been skipped
Build and Deploy / Deploy web (push) Has been skipped
Build and Deploy / Deploy media worker (push) Has been skipped
Build and Deploy / Deploy ML worker (push) Has been skipped
Build and Deploy / Deploy plants worker (push) Has been skipped
Build and Deploy / Deploy people worker (push) Has been skipped
Build and Deploy / Deploy converter worker (push) Has been skipped
Build and Deploy / Clean Docker build artifacts (push) Has been skipped
Build and Deploy / Run scoped PR tests (push) Successful in 3m47s
03ecc93112
Both new boundingBox specs registered the merge-suggestion mock as
`**/api/discovery/domains/people/merge-suggestion` — without the trailing
`**` that the other 52 occurrences in this file use. The real GET carries a
query string (`.../merge-suggestion?limit=1`), so the glob did not match and
the request fell through to the preview server, which proxies /api to
MEMORIES_API_INTERNAL_URL.

- Locally that upstream answers 404 → `loadMergeSuggestion` treats 404 as
  "no suggestion" and resolves null → the carousel renders → tests passed.
- In CI nothing is listening → `fetch failed` → HTTP 500 from hooks.server →
  `loadMergeSuggestion` only swallows 404/204, so it rethrows → `loadAll`'s
  catch clears `candidates`/`mergeSuggestion` → `hasContent()` is false →
  the Suggestions heading never renders → `toBeVisible()` times out at the
  exact reported lines (318 / 407).

Deterministic on every retry because it depends only on which upstream is
reachable, which is why it reproduced only in CI.

Fix: add the trailing `**` to both patterns (no product change — the
carousel behaving correctly on an API error is intended). Verified by
reproducing the failure with a dead upstream before the fix and getting
122/122 green under the same dead upstream after it.
chris merged commit 8603e4498e into main 2026-10-07 06:17:48 +02:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
chris/memories!1054
No description provided.