Skip to content

Surface the person._possible_duplicate marker in the desktop UI - #2125

Merged
mstomar125 merged 2 commits into
mainfrom
issue-2116-duplicate-marker-ui
Aug 18, 2026
Merged

mstomar125 merged 2 commits into
mainfrom
issue-2116-duplicate-marker-ui

Conversation

@mstomar125

Copy link
Copy Markdown
Contributor

Summary

Closes #2116. Completes the desktop half of the ADR-065 §4 convergence duplicate indicator, left open by core#1734/#2115: NodeService::mark_possible_duplicates (merged today in #2115) and nodespace-sync's pulled-write handler already stamp properties.person._possible_duplicate = true on both colliding nodes when a duplicate slips past creation-time suggestion and converges via sync — but nothing read or displayed that marker anywhere in the desktop app. It was write-only.

This PR adds a minimal, non-blocking UI surface for it, reusing #2115's adopt-existing pattern rather than building new merge machinery.

What's in this PR

1. Backend read accessor

NodeService::is_possible_duplicate(&Node) -> bool (packages/core/src/services/node_service/schema.rs) — a pure, synchronous read-side counterpart to mark_possible_duplicates, reading the same properties.<node_type>._possible_duplicate path via the same core_schemas::POSSIBLE_DUPLICATE_FIELD constant the writer uses, so the two can never disagree on the marker's location. Generic across node types by construction, matching the writer. The existing person_duplicate_convergence_test.rs suite's local marker() helper now delegates to this accessor (so all 5 existing convergence tests double as coverage), plus a new dedicated test for the accessor's default-false cases (missing field, explicit false) and its end-to-end agreement with mark_possible_duplicates's actual write.

2. Frontend accessor

lib/utils/possible-duplicate.ts — isPossibleDuplicate(node), the frontend's equivalent single source of truth. No new RPC needed: node.properties already reaches the frontend unfiltered on every existing read path (getNode, queryNodes, a findDuplicateFor match, …) — nothing in core/daemon/desktop-app strips local_only/system-managed properties before serialization. This utility replaces what would otherwise be scattered raw node.properties.person._possible_duplicate reads with one tested accessor.

3. Property panel badge (person-schema-form.svelte)

A small "Possible duplicate — click to review" badge appears when the node being viewed/edited is flagged. Clicking it re-runs the exact same findDuplicateFor('person', 'email', …) lookup and reuses the exact same adopt-existing Alert (Use existing / Keep as new) the creation-time suggestion from #2115 already has — literally the same state and functions, not a parallel implementation. The badge and the Alert are mutually exclusive in the DOM (no UI stacking).

4. Inline node view badge (possible-duplicate-badge.svelte)

A new self-contained component mirroring the existing RecoveredItemsBadge pattern (same inline-pill-with-popover structure, same --color-warning design language), wired into base-node.svelte next to RecoveredItemsBadge. Renders nothing unless the node is a person currently flagged, so it's inert for every other node type and every unflagged person. Its own compact popover offers the same Use existing / Dismiss choice, backed by the same backendAdapter.findDuplicateFor + navigateToNodeInOtherPane calls as the property panel — same backend, same non-destructive action, independent (necessarily — it's a different DOM context) small implementation.

Both surfaces are informational and non-modal only: neither can block editing the node it's attached to, and dismissing only closes the local popover — the marker itself is never cleared server-side (no dismiss-persistence or admin-merge mechanism is in scope, per the parent ADR's explicit non-goals).

Explicitly out of scope (per ADR-065, unchanged)

  • Admin-driven merge (re-pointing mentions/member_of edges, tombstoning, sync-echo handling).
  • Any mechanism that could turn a marked duplicate into a blocking state, or that clears the marker.

Test plan

  • cargo test -p nodespace-core --lib --tests — 1154+ passed across all core test binaries, 0 failed
  • cargo test -p nodespace-daemon --lib — 147 passed, 0 failed
  • cargo test -p nodespace-app --lib — 61 passed, 0 failed
  • cargo clippy --all-targets -- -D warnings -D clippy::unused-async — clean, whole workspace
  • cargo fmt --all applied
  • Frontend: bun run test, cold cache — 4724 passed across 218 files, 0 failed (includes 31 new tests: badge visibility/hidden states, click-to-recheck reusing the existing Alert, Use existing/Dismiss behavior, accessor edge cases)
  • svelte-check / tsc --noEmit — 0 errors
  • eslint — clean
  • bun run quality:fix — clean
  • Pre-push gate re-ran the full suite — green

🤖 Generated with Claude Code

Completes the desktop half of the convergence duplicate indicator
(ADR-065 §4) left open by core#1734/#2115: mark_possible_duplicates
already stamps properties.person._possible_duplicate on sync
convergence, but nothing read or displayed it — a flagged duplicate
was only visible via raw node.properties.

- NodeService::is_possible_duplicate(&Node) -> bool: pure read-side
  counterpart to mark_possible_duplicates, reading the same
  properties.<node_type>._possible_duplicate path via the same
  POSSIBLE_DUPLICATE_FIELD constant so the two can never disagree.
  Generic across node types by construction. Covered by a new test
  (default-false cases: missing field, explicit false) plus the
  existing convergence test suite, whose local marker() helper now
  delegates to this accessor instead of re-deriving the property path.

- lib/utils/possible-duplicate.ts: the frontend's equivalent accessor
  (isPossibleDuplicate), since node.properties already reaches the
  frontend unfiltered on every existing read path — no new RPC needed.

- person-schema-form.svelte (the person property panel): a small
  "Possible duplicate — click to review" badge appears when the node
  is flagged. Clicking it re-runs the exact same find_duplicate_for
  lookup and reuses the exact same adopt-existing Alert (Use
  existing / Keep as new) the creation-time suggestion from #2115
  already has — no parallel resolution UI.

- possible-duplicate-badge.svelte: a self-contained inline-node-view
  indicator (mirrors the existing RecoveredItemsBadge pattern), wired
  into base-node.svelte next to it. Renders nothing unless the node is
  a flagged person, so it's inert everywhere else. Own compact
  popover offers the same Use existing / Dismiss choice via the same
  backend lookup and non-destructive navigate action.

Both surfaces are purely informational and non-modal: neither can
block editing the node, and dismissing only closes the local popover
— the marker itself is never cleared, since admin-driven merge/dismiss
machinery is explicitly out of scope per the parent ADR.

Closes #2116

Co-Authored-By: Claude <[email protected]>
An independent adversarial review of PR #2125 (no blockers, but three
real non-blocking findings) flagged:

- possible-duplicate-badge.svelte's runCheck() had no staleness guard,
  unlike person-schema-form.svelte's checkForDuplicate. Rapid
  open/close/reopen of the popover could start two overlapping
  lookups; whichever resolved last won regardless of start order.
  Fixed with a monotonic generation counter (mirrors the existing
  guard's intent, but keyed on start order rather than value equality
  so it also covers same-value overlapping calls); also guards the
  `checking` flag so a superseded call's `finally` can't flip it back
  on while a newer check is still in flight.

- The same class of gap existed in person-schema-form.svelte itself:
  checkForDuplicate's staleness guard compared the checked value
  by string equality, which cannot distinguish two overlapping calls
  for the SAME value (e.g. a blur-triggered check racing a
  badge-triggered recheck). Replaced with the same generation-counter
  approach: only the most recently STARTED check may ever write
  duplicateMatch, regardless of resolution order.

- recheckPossibleDuplicate() (the badge's click handler) was a silent
  no-op when the recheck found no live collision — since the marker is
  permanent (nothing clears it), a recheck finding nothing is an
  expected, not exceptional, outcome and needs to be visible. Added a
  "No conflicting person found right now." message, cleared on the
  next edit or recheck attempt.

Five new regression tests cover the generation-counter fix in both
components and the no-match feedback path.

Co-Authored-By: Claude <[email protected]>
@mstomar125

Copy link
Copy Markdown
Contributor Author

An independent adversarial review verdict: APPROVE, zero blockers. It flagged 3 real non-blocking findings, addressed in the follow-up commit:

  1. Missing staleness guard in possible-duplicate-badge.svelte's runCheck() — rapid open/close/reopen of the popover could start overlapping lookups where whichever resolved last won, regardless of start order. Fixed with a monotonic generation counter (also guards the checking flag so a superseded call's finally can't flip it back on mid-flight).
  2. The same class of race in person-schema-form.svelte's checkForDuplicate — its by-value staleness guard (checkedForEmail !== value) can't distinguish two overlapping calls for the same value (a blur check racing a badge recheck). Replaced with the same generation-counter approach.
  3. Silent no-op when a badge-triggered recheck finds no live collision — since the marker is permanent (nothing clears it), that's an expected outcome, not exceptional. Added a "No conflicting person found right now." message.

Also added the missing defensive-backstop test the review noted (possible-duplicate-badge.test.ts never-adopt-self case) plus regression tests for the generation-counter fix in both components.

Remaining findings (defensible code duplication between the two badge implementations, and pre-existing RecoveredItemsBadge-class a11y gaps not introduced by this PR) were left as-is per the reviewer's own assessment.

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.

Surface the person._possible_duplicate convergence marker in the desktop UI

1 participant