fix(web): stale sibling cards degrade quietly, dialog quality % on ambiguous, honest conflict count #1056

Merged
chris merged 1 commit from fix/web-stale-sibling-cards into main 2026-10-07 07:27:21 +02:00
Owner

Two layers against stale sibling cards (pending duplicates minted before the API mint-guard in #1055), plus two copy/consistency fixes.

1. Silent re-sync after every successful decision

DomainSuggestionsCarousel.svelte gains resyncCandidates(), called first from afterDecision() (so it covers every decide path: accept, reject, stash, disband, merge-into-existing, merge picker, merge-card actions):

  • server is the source of truth — a decision can auto-reject an overlap sibling server-side (overlapRejections → markCandidateDecidedIfPending), and the sibling then disappears without user action;
  • removal-only, no flicker: no loading flag (no skeleton), no list reset, existing cards never remount, scroller position untouched;
  • guarded by requestId (owned by loadAll) so a concurrent full reload always wins; a failed re-sync never disturbs the working set.

2. Stale decision failures degrade quietly

handleDecisionConflict → handleStaleDecisionFailure. Besides the existing 409 code: "candidate_changed", a 400 whose detail is a candidate not-found ("Pending class-instance candidate not found" / "Class-instance candidate not found for current owner") now means "this card no longer exists":

  • card dropped, dialog/picker closed, soft notice "This suggestion was outdated — list refreshed", list re-synced;
  • no error toast/alert for a decision the owner effectively already got;
  • every other 400/409 stays a visible error — pinned by the existing "other 409s" / "non-conflict 400" tests.

3. Detail dialog omits the quality % on ambiguous cards

Same rule and same reasoning comment as the card (the figure describes only the closest match and would contradict the "may include more than one person" copy).

4. Honest multi-person count

conflictingPersonIds includes the suggested target (ADR 0101), so the count now subtracts it only when the target id is actually present (never below 0), and the wording drops the overstated claim:

  • "N other named people also matched at least one photo in this group" (card and dialog);
  • singular: "Another named person also matched at least one photo in this group."

Tests

4 new Playwright tests + 2 extended in apps/web/tests/discovery-review.spec.ts:

  • overlap sibling decided server-side → refetch drops it, no error;
  • decide → 400 not-found → card removed + soft notice, no error toast;
  • dialog hides % on ambiguous card;
  • conflictingPersonIds with 3 ids incl. target → "2 other named people…" (+ no-target card: 1 → "Another…", 3 → "3 other…").

All 6 fail without the component fix (verified by stashing it), pass with it.

Verification: npm run check → 0 errors; full npm test (Playwright, desktop + mobile) → 810 passed / 0 failed (1 unrelated flaky in embedding-map.spec.ts, passed on retry); npm run test:unit (vitest) → 66/66.

Web-only — no version bump (same as #1054), no API/spec/KNOWN_ISSUES changes. Not merged; needs review.

Two layers against **stale sibling cards** (pending duplicates minted before the API mint-guard in #1055), plus two copy/consistency fixes. ## 1. Silent re-sync after every successful decision `DomainSuggestionsCarousel.svelte` gains `resyncCandidates()`, called first from `afterDecision()` (so it covers *every* decide path: accept, reject, stash, disband, merge-into-existing, merge picker, merge-card actions): - server is the source of truth — a decision can auto-reject an **overlap sibling** server-side (`overlapRejections` → `markCandidateDecidedIfPending`), and the sibling then disappears without user action; - **removal-only, no flicker**: no `loading` flag (no skeleton), no list reset, existing cards never remount, scroller position untouched; - guarded by `requestId` (owned by `loadAll`) so a concurrent full reload always wins; a failed re-sync never disturbs the working set. ## 2. Stale decision failures degrade quietly `handleDecisionConflict` → `handleStaleDecisionFailure`. Besides the existing 409 `code: "candidate_changed"`, a **400 whose detail is a candidate not-found** ("Pending class-instance candidate not found" / "Class-instance candidate not found for current owner") now means "this card no longer exists": - card dropped, dialog/picker closed, soft notice *"This suggestion was outdated — list refreshed"*, list re-synced; - **no error toast/alert** for a decision the owner effectively already got; - every other 400/409 stays a visible error — pinned by the existing "other 409s" / "non-conflict 400" tests. ## 3. Detail dialog omits the quality % on ambiguous cards Same rule and same reasoning comment as the card (the figure describes only the closest match and would contradict the *"may include more than one person"* copy). ## 4. Honest multi-person count `conflictingPersonIds` **includes the suggested target** (ADR 0101), so the count now subtracts it only when the target id is actually present (never below 0), and the wording drops the overstated claim: - *"N other named people also matched at least one photo in this group"* (card **and** dialog); - singular: *"Another named person also matched at least one photo in this group."* ## Tests 4 new Playwright tests + 2 extended in `apps/web/tests/discovery-review.spec.ts`: - overlap sibling decided server-side → refetch drops it, no error; - decide → 400 not-found → card removed + soft notice, no error toast; - dialog hides % on ambiguous card; - `conflictingPersonIds` with 3 ids incl. target → "2 other named people…" (+ no-target card: 1 → "Another…", 3 → "3 other…"). All 6 fail without the component fix (verified by stashing it), pass with it. **Verification:** `npm run check` → 0 errors; full `npm test` (Playwright, desktop + mobile) → **810 passed / 0 failed** (1 unrelated flaky in `embedding-map.spec.ts`, passed on retry); `npm run test:unit` (vitest) → **66/66**. Web-only — no version bump (same as #1054), no API/spec/KNOWN_ISSUES changes. Not merged; needs review.
fix(web): stale sibling cards degrade gracefully + honest ambiguous copy
All checks were successful
Build and Deploy / Run scoped PR tests (push) Successful in 6m7s
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
7a57da4f5d
- After every successful decision the carousel now silently re-syncs the
  pending list (removal-only, no skeleton flash, existing cards stay
  mounted) so a sibling the API auto-decided server-side (overlap
  rejection of a pre-mint-guard duplicate) disappears without user action.
- Decision failure 400 "... candidate not found" is handled like the
  existing 409 candidate_changed: card dropped, soft "outdated" notice,
  list re-sync — never an error toast for a card that no longer exists.
  Every other 400/409 stays a visible error.
- Detail dialog omits the quality % on ambiguous cards, same rule and
  reasoning comment as the card (the figure only describes the closest
  match and contradicts the "may include more than one person" copy).
- conflictingPersonIds includes the suggested target (ADR 0101): count
  others as length - 1 only when the target id is present (never < 0),
  and reword to "…also matched at least one photo in this group" in both
  card and dialog.

Playwright: 4 new tests + 2 extended; vitest untouched and green.
chris merged commit 26635fa647 into main 2026-10-07 07:27:21 +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!1056
No description provided.