feat(web): zoomed face tiles render the spec-052 scope-crop asset, CSS-zoom fallback #1058
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/face-scope-crop-web"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Spec 052, task
S052T003(web consumption). Web-only — no version bump.What
Wherever a zoomed face-region view renders today (whole photo
?size=512+scopeCropFit), the ref now first asks for the pre-composed scope crop andrenders it 1:1:
DomainSuggestionsCarousel.svelte,the
refTileMedia/candidate-face-zoompaths from #1054): a ref with aboundingBox(+ media item + face annotation id) requests/api/media/{mediaItemId}/faces/{faceAnnotationId}/thumbnail?size=512&crop=scopeand renders it with
object-fit: coveronly — no transform, no object-positionslice shift.
DiscoveryInstanceDetail.svelte, the twocandidate-scope-croprender sites, now onecandidateZoomMediasnippet): same1:1 rendering, face annotation id taken from the candidate's first
face_annotationref (the same refrepresentativeBboxis resolved fromserver-side).
Fallback (deploy order does not matter)
The scope attempt is a plain
<img>— deliberately notThumbnailImage, so amissing asset never enters the derived-asset retry loop (10 × 6 s cache-busted
probes). On
error(404 / older API build) the URL is recorded in a componentSvelteSet, and that tile and every other surface showing the same face(card tile + dialog crop) re-renders through the existing whole-photo
derived/thumbnail?size=512+scopeCropFitpath. The failure is remembered, sothe dialog never re-asks for a known-missing asset (one 404 total).
Box-less refs and the legacy
scope-lane rendering are untouched.Shared URL builder:
src/lib/utils/scopeAsset.ts(faceScopeThumbnailUrl).Tests
apps/web/tests/discovery-review.spec.tstransform; box-less refs keep the face crop — card and dialog assert
size=512&crop=scope,data-scope-asset="true", notransform:, zero?size=512whole-photo requests, zero tight-face-crop requests, box-lesssibling unchanged.
zoom on tile and dialog —
crop=scopemocked 404 → card + dialog render?size=512withtransform:, exactly one scope request (recordedfailure reused by the dialog).
apps/web/tests/discovery-instance-tentative.spec.tsscope crop — exact
srcwithsize=512&crop=scope,naturalWidth > 0, notransform, zero whole-photo requests.
asset is missing — 404 →
scale(transform + whole photo fetched.Verification
npm run check→ 0 errors (22 warnings, unchanged from baseline).npm test(full Playwright suite, desktop + mobile) → 815 passed, 23skipped, 0 failed.
Bookkeeping
KNOWN_ISSUES.md→[ISSUE-107] low open area:web(blurry zoomed face tiles,being fixed by these assets)
[spec:052].S052T003pending → done (committed in this PR).Note for the API lane
Spec S3 says
crop=scopefalls back to the tight face crop when the scopeasset is absent, while this lane's contract says 404 → fall back. The web
handles both: 404 → CSS-zoom fallback (tested); a 200 tight crop is rendered 1:1
(sharp, but without the context margin). Worth confirming which one the API
implements.
Carousel card tiles, carousel detail-dialog crops and the people-page "Vis område" cards now ask for the pre-composed scope crop (`faces/{faceId}/thumbnail?size=512&crop=scope`) whenever the ref carries a boundingBox, and render it 1:1 (object-fit: cover, no transform, no slice shift) — the asset already frames bbox + context, so tiles stop CSS-zooming a 512px whole photo (ISSUE-107). Fallback is per-URL and immediate: a plain <img> (not ThumbnailImage, so a 404 never enters the derived-asset retry loop) records the failure in a reactive set shared by card and dialog, and every surface showing that face re-renders through the existing whole-photo ?size=512 + scopeCropFit path — worker/API/web deploy order does not matter. Box-less refs and the legacy `scope` lane are untouched. Tests: scope request + no-transform render (card + dialog), 404 fallback (card + dialog, one failed request only), box-less ref unchanged, people-page Vis område scope asset + its 404 fallback. [ISSUE-107] logged, S052T003 done.297e1a2ea5a3c0b07fe6