Skip to content

Filter already-linked targets on every relationship-picker entry path - #2456

Closed
mstomar125 wants to merge 2 commits into
mainfrom
issue-2434-picker-already-linked
Closed

mstomar125 wants to merge 2 commits into
mainfrom
issue-2434-picker-already-linked

Conversation

@mstomar125

Copy link
Copy Markdown
Contributor

Summary

Fixes #2434. The relationship viewer's target picker filtered out already-linked nodes from search results, but the paste-a-UUID branch bypassed that filter entirely — pasting the id of an already-linked node offered a live "Use ID" button whose Add silently no-opped (the daemon's create_relationship is correctly idempotent for an existing edge, so nothing observable happened).

Changes

  • relationship-grouping.ts: added linkedTargetIds / isTargetLinked / filterUnlinkedTargets as the single source of truth for "already linked into this group" — used by both entry paths into the picker.
  • relationship-viewer-modal.svelte:
    • The pasted-UUID branch now checks isTargetLinked before offering "Use ID" — an already-linked id shows explanatory text instead of a live Add button.
    • The search path now tracks whether a search returned raw matches that were all filtered out as already-linked (addAllLinked), and shows "All matching <type> are already linked." in that case, distinct from "No matches." for a search that genuinely found nothing.
  • The daemon's idempotent create_relationship behavior is unchanged — this is a UI-only fix, per the issue.

Test plan

  • 5 new unit tests for linkedTargetIds / isTargetLinked / filterUnlinkedTargets, each individually mutation-tested (broke the real implementation, confirmed the test failed, restored, confirmed it passed again)
  • bun run test:all — no new failures (233 test files / 4905 tests pass; Rust suite green)
  • bun run quality:fix — clean (eslint/svelte-check/tsc/cargo fmt/clippy all pass)

🤖 Generated with Claude Code

mstomar125 and others added 2 commits September 8, 2026 10:26
The paste-a-UUID branch in the relationship viewer's target picker bypassed
the existing-target filter that search results already went through, so
pasting an already-linked node's id offered a live "Use ID" button whose
Add silently no-opped against the daemon's idempotent create_relationship.

Add linkedTargetIds/isTargetLinked/filterUnlinkedTargets to
relationship-grouping.ts as the one source of truth for "already linked",
used by both the search-results filter and the pasted-id check. A pasted
id that's already linked now renders explanatory text instead of an Add
button, and a search whose matches are all already-linked now says so in
language distinct from a genuine "No matches."

Co-Authored-By: Claude <[email protected]>
Address review: UUID_RE (the paste-a-uuid check) accepts a pasted id in
any case, but linkedTargetIds/isTargetLinked/filterUnlinkedTargets did an
exact string comparison against the group's (canonical, lowercase) row
ids. A differently-cased paste of an already-linked node's id therefore
still offered a live "Use ID" Add — the exact silent no-op #2434 reports,
just triggered by case variance instead of an exact re-paste.

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

Copy link
Copy Markdown
Contributor Author

Closing without merging: #2432 (the two-pane relationship panel redesign) merged into `main` after this branch was cut, and it rewrote `relationship-viewer-modal.svelte` end to end — including removing the paste-a-UUID picker path entirely (the target picker is now search-only). That's the exact code path this PR's fix targeted, so this branch no longer applies (`gh pr view` reports `CONFLICTING`).

The good news: #2432's rewrite already carries forward the spirit of #2434 — its own `runSearch` filters already-linked targets from search results, and it already distinguishes "No matches — every result is already linked." from a plain "No matches." So the paste-UUID-specific bug this issue described can no longer happen (there's no paste-UUID affordance left to trigger it).

I did find one real remaining gap in the merged code: the "all linked vs genuinely no matches" message is keyed off group.rows.length > 0 (does this relationship already have ANY edge) rather than off whether this search's own raw results were non-empty before filtering — so a genuinely-empty search on a relationship that already has other linked rows would misreport "every result is already linked" instead of "No matches." Filing a follow-up PR against current main to fix that precisely, using the same linkedTargetIds/isTargetLinked/filterUnlinkedTargets single-source-of-truth helpers this PR added to relationship-grouping.ts (unaffected by #2432, so they carry forward cleanly).

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.

Pasting an already-linked node's ID offers an Add that silently does nothing

1 participant