feat(web): self person Ich badge + profile photo with crop dialog (spec 057) #1150

Merged
chris merged 2 commits from feat/057-self-person-frontend into main 2026-10-12 21:28:52 +02:00
Owner

Summary (spec 057, frontend lane S057T005–T006)

API client (apps/web/src/lib/api/self-person.ts, mirrors discovery.ts style)

  • getSelfPerson(), claimSelfPerson(classInstanceId), unclaimSelfPerson(), setSelfPersonPhoto(mediaItemId, {x,y,size}), selfPersonPhotoUrl(size, version?)
  • helpers: claimConflictDisplayName(error) (409 holder name, flat body or ProblemDetail detail JSON), isClaimConflict(error), withPhotoCacheBust(url, version)
  • person detail types gain selfPersonClaim?: { state: 'none'|'self'|'other', claimedByDisplayName? } on both ClassInstanceBrowseView (the list read path the person page actually loads) and PersonDetailView (getPersonDetail), optional/defensive for older API builds.

Person detail page (DiscoveryInstanceDetail.svelte)

  • "Ich" badge next to the person name in the banner header and in the condensed sticky bar when state=self.
  • Claim toggle in the top-bar ⋮ actions menu, right after Rename/Set thumbnail/Choose face: "Als Ich markieren" → "Als Ich markiert (entfernen)"; state=other renders a disabled entry "Bereits von {claimedByDisplayName} als Ich markiert".
  • Claim state resolution: uses the embedded selfPersonClaim if the API sends it (list row or getPersonDetail); otherwise falls back to GET /profile/self-person (derives self/none). Hidden until resolved — never a guessed action.
  • 409 → flips into the disabled holder state + German error toast; other failures → describeApiError toast.

Profile page (/profile, Konto tab)

  • New SelfPersonSection card ("Ich" / "Mein Personenprofil"): avatar with fallback chain profile photo → representative thumbnail → initials, person name + "Ich" chip, link to /discovery/domains/people/instances/{id}, actions "Person auswählen/ändern", "Profilbild ändern", "Verknüpfung entfernen".
  • Person picker: getAllPeople() mapped into the existing PersonTargetPicker component; 409 shows the hint inline in the picker and refreshes the list.
  • Photo picker: getPersonDetail(selfPerson).media filtered to photos → tile grid (skeleton, empty state, "Weitere Fotos anzeigen").
  • Crop dialog (SelfPersonCropDialog): square viewport = the crop frame, cover-fit image, drag to pan (pointer + touch, touch-action: none), wheel/slider/keyboard (+/-, arrows) to zoom about the center, rule-of-thirds guides + emerald corner brackets, live circular preview of the final avatar, German hints, Escape/Abbrechen/Schließen to close, busy state + inline save error (400/422), "Anderes Foto" back action.
  • Avatar in the Konto/Identity block reuses the same fallback chain (SelfPersonAvatar).

Crop math (apps/web/src/lib/utils/selfPersonCrop.ts) is pure + unit-tested (15 cases): cover scale, clamping, center-stable zoom, normalized crop output.

Contract notes for the backend/worker lanes

  • Endpoints called exactly as pinned: GET/PUT/DELETE /api/profile/self-person, PUT /api/profile/self-person/photo {mediaItemId, crop}, GET /api/profile/self-person/photo?size=256.
  • Crop normalization convention (please confirm): x = left / imageWidth, y = top / imageHeight, size = squareSide / imageWidth (width-anchored: worker does side_px = size * width, left = x * width, top = y * height). The UI only ever emits size ≤ min(W,H)/W, so the square always fits. If the worker instead anchors size to min(width, height), tell me — it's a one-line change in computeCrop.
  • selfPersonClaim is read from whichever endpoint carries it; the person page works today with either the class-instance list payload or getPersonDetail (it falls back to the other automatically), and degrades to none if neither sends it yet.
  • Photo URL: the UI appends ?v=<timestamp> after a re-crop (cache bust) — the extra query param must be ignored by the photo endpoint (Spring binds only what it knows).
  • The profile photo may 404 for a moment while worker-media renders the new generation; the avatar then falls back to the representative thumbnail, then initials (no error loop).

Validation (apps/web)

  • npm run check → 0 errors, 21 warnings in 7 files — all warnings pre-existing in untouched files (baseline before my change was the same 21; my files contribute none).
  • npm run test:unit → 151 tests passed (21 files), includes the new selfPersonCrop.spec.ts (15) and self-person.spec.ts (9).
  • npm run build → success (vite + adapter-node), exit 0.
  • Rebased onto latest origin/main before push; check/tests/build re-run green afterwards.

Scope: only apps/web. No API/worker changes, no KNOWN_ISSUES.md edit, not merged.

## Summary (spec 057, frontend lane S057T005–T006) **API client** (`apps/web/src/lib/api/self-person.ts`, mirrors `discovery.ts` style) - `getSelfPerson()`, `claimSelfPerson(classInstanceId)`, `unclaimSelfPerson()`, `setSelfPersonPhoto(mediaItemId, {x,y,size})`, `selfPersonPhotoUrl(size, version?)` - helpers: `claimConflictDisplayName(error)` (409 holder name, flat body or ProblemDetail `detail` JSON), `isClaimConflict(error)`, `withPhotoCacheBust(url, version)` - person detail types gain `selfPersonClaim?: { state: 'none'|'self'|'other', claimedByDisplayName? }` on **both** `ClassInstanceBrowseView` (the list read path the person page actually loads) and `PersonDetailView` (`getPersonDetail`), optional/defensive for older API builds. **Person detail page** (`DiscoveryInstanceDetail.svelte`) - "Ich" badge next to the person name in the banner header and in the condensed sticky bar when `state=self`. - Claim toggle in the top-bar ⋮ actions menu, right after Rename/Set thumbnail/Choose face: **"Als Ich markieren"** → **"Als Ich markiert (entfernen)"**; `state=other` renders a disabled entry **"Bereits von {claimedByDisplayName} als Ich markiert"**. - Claim state resolution: uses the embedded `selfPersonClaim` if the API sends it (list row or `getPersonDetail`); otherwise falls back to `GET /profile/self-person` (derives `self`/`none`). Hidden until resolved — never a guessed action. - 409 → flips into the disabled holder state + German error toast; other failures → `describeApiError` toast. **Profile page** (`/profile`, Konto tab) - New `SelfPersonSection` card ("Ich" / "Mein Personenprofil"): avatar with fallback chain **profile photo → representative thumbnail → initials**, person name + "Ich" chip, link to `/discovery/domains/people/instances/{id}`, actions "Person auswählen/ändern", "Profilbild ändern", "Verknüpfung entfernen". - Person picker: `getAllPeople()` mapped into the existing `PersonTargetPicker` component; 409 shows the hint inline in the picker and refreshes the list. - Photo picker: `getPersonDetail(selfPerson).media` filtered to photos → tile grid (skeleton, empty state, "Weitere Fotos anzeigen"). - **Crop dialog** (`SelfPersonCropDialog`): square viewport = the crop frame, cover-fit image, drag to pan (pointer + touch, `touch-action: none`), wheel/slider/keyboard (+/-, arrows) to zoom about the center, rule-of-thirds guides + emerald corner brackets, **live circular preview** of the final avatar, German hints, Escape/Abbrechen/Schließen to close, busy state + inline save error (400/422), "Anderes Foto" back action. - Avatar in the Konto/Identity block reuses the same fallback chain (`SelfPersonAvatar`). **Crop math** (`apps/web/src/lib/utils/selfPersonCrop.ts`) is pure + unit-tested (15 cases): cover scale, clamping, center-stable zoom, normalized crop output. ## Contract notes for the backend/worker lanes - Endpoints called exactly as pinned: `GET/PUT/DELETE /api/profile/self-person`, `PUT /api/profile/self-person/photo {mediaItemId, crop}`, `GET /api/profile/self-person/photo?size=256`. - **Crop normalization convention (please confirm):** `x = left / imageWidth`, `y = top / imageHeight`, `size = squareSide / imageWidth` (width-anchored: worker does `side_px = size * width`, `left = x * width`, `top = y * height`). The UI only ever emits `size ≤ min(W,H)/W`, so the square always fits. If the worker instead anchors `size` to `min(width, height)`, tell me — it's a one-line change in `computeCrop`. - `selfPersonClaim` is read from whichever endpoint carries it; the person page works today with **either** the class-instance list payload **or** `getPersonDetail` (it falls back to the other automatically), and degrades to `none` if neither sends it yet. - Photo URL: the UI appends `?v=<timestamp>` after a re-crop (cache bust) — the extra query param must be ignored by the photo endpoint (Spring binds only what it knows). - The profile photo may 404 for a moment while worker-media renders the new generation; the avatar then falls back to the representative thumbnail, then initials (no error loop). ## Validation (apps/web) - `npm run check` → **0 errors, 21 warnings in 7 files** — all warnings pre-existing in untouched files (baseline before my change was the same 21; my files contribute none). - `npm run test:unit` → **151 tests passed (21 files)**, includes the new `selfPersonCrop.spec.ts` (15) and `self-person.spec.ts` (9). - `npm run build` → **success** (vite + adapter-node), exit 0. - Rebased onto latest `origin/main` before push; check/tests/build re-run green afterwards. Scope: only `apps/web`. No API/worker changes, no KNOWN_ISSUES.md edit, not merged.
feat(web): self person Ich badge + profile photo with crop dialog (spec 057)
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 / Build postgres image (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 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 5m58s
b1b91e60c0
- API client src/lib/api/self-person.ts: getSelfPerson, claimSelfPerson,
  unclaimSelfPerson, setSelfPersonPhoto, selfPersonPhotoUrl + 409 helper
- Person detail types gain selfPersonClaim (ClassInstanceBrowseView,
  PersonDetailView) with defensive fallback via getPersonDetail/getSelfPerson
- DiscoveryInstanceDetail: 'Ich' badge next to the person name (header +
  sticky bar) and 'Als Ich markieren' / 'Als Ich markiert (entfernen)' in the
  page actions menu; state=other renders disabled with 'Bereits von X als Ich
  markiert'; 409 handled via toast + state flip
- Profile: SelfPersonSection (avatar fallback chain profile photo ->
  representative thumbnail -> initials), person picker, photo picker over the
  self person's gallery, and the square crop dialog (pan/zoom, live circular
  preview, keyboard + touch), avatar in the Konto/Identity block
- Pure crop math in src/lib/utils/selfPersonCrop.ts + unit specs
chris force-pushed feat/057-self-person-frontend from b1b91e60c0
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 / Build postgres image (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 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 5m58s
to e0332e683b
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 3s
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 11m36s
2026-10-12 20:18:54 +02:00
Compare
ci: retrigger scoped PR tests after flaky timeout
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 10m34s
b3174a4eaf
chris force-pushed feat/057-self-person-frontend from b3174a4eaf
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 10m34s
to b18dae283b
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 3s
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 13m17s
2026-10-12 21:13:25 +02:00
Compare
chris merged commit 319a254f73 into main 2026-10-12 21:28:52 +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!1150
No description provided.