Repository navigation
Gate the Relationships trigger on the type having typed relationships - #2017
Conversation
The Relationships entry point in GenericSchemaForm rendered unconditionally, so clicking it on a schema with no typed relationships opened the viewer only to say "no typed relationships" — noise on every type that has none. Gate the button on whether the node's type actually has a relationship. The viewer's own load (loadNodeRelationshipsView) already resolves both sides — outbound declared on this schema and inbound declared by another schema targeting this type — into one group per relationship, so run it once per node and show the button iff it yields any group. Default hidden; fail open on a load error so a transient failure never hides a real feature. Now testable against a real relationship since #1999 added project -> task. Closes #2007. Co-Authored-By: Claude <[email protected]>
The visibility gate hid the Relationships button on a type reached only via a derived inbound relationship with no edges yet — e.g. a task with no linked project — because get_node_relationships dropped empty inbound groups while emitting empty outbound ones. That asymmetry made the gate edge-level on the inbound side but declaration-level on the outbound side, so a fresh unlinked task failed the "shows the button" acceptance criterion. Make the inbound branch symmetric with the outbound branch: emit the declared group even with zero edges. This fixes the gate for the inbound side and also lets the viewer add the first inbound edge from the target's side. Adds a get_node_relationships test asserting both empty declared groups (in + out) are present. Severity: 🔴 addressed (AC2). Reviewer: pragmatic-code-review on PR #2017. Co-Authored-By: Claude <[email protected]>
Pragmatic Code Review — Initial ReviewIndependent review against #2007's ACs. The mechanism, 🔴 AC2 not met (empty-inbound case). The gate reuses the viewer load ( 🟡 Test blind spot. The three gate tests mock 🟢 $effect guard correct (once per nodeId, stale-async-safe); fail-open-on-error is the right call; no CLAUDE.md violations. Verdict: REQUEST CHANGES — AC2 is a genuine gap, not a nit. |
/address-review🔴 AC2 (empty-inbound) — ADDRESSED. Fixed the root cause in the backend rather than papering over it in the gate: made 🟡 Test blind spot — ADDRESSED. Added Validation: full Re-Review DecisionDecision: RE-REVIEW NEEDED — a backend semantics change (empty inbound groups now emitted for every type with an inbound declaration) + a new test. Running |
The function doc still said inbound groups are returned only with an edge; both sides now return declared groups even when empty. Doc-only. Co-Authored-By: Claude <[email protected]>
Pragmatic Code Review — Re-Review (delta
|
Summary
The Relationships entry point in
GenericSchemaFormrendered unconditionally, so clicking it on a schema with no typed relationships opened the viewer only to show "no typed relationships" — noise on every type that has none. This gap was explicitly deferred in #1918's review; #1999 (project→task) now gives a real relationship to test the gate against. Closes #2007.Change
Gate the button on whether the node's type actually has a typed relationship. The viewer's own load (
loadNodeRelationshipsView) already resolves both sides — outbound declared on this schema and inbound declared by another schema targeting this type — into one group per relationship, so the gate runs that load once per node and shows the button iff it yields any group.packages/desktop-app/src/lib/components/schema/generic-schema-form.svelte:{#if hasRelationships}around the trigger; a$effectrunsloadNodeRelationshipsView(nodeId)once per node. Default hidden; fail open on a load error so a transient failure never hides a real feature.Note: the check reuses the viewer's load rather than reading
schema.relationships— the frontendSchemaNodetype carries norelationshipsfield (post-#2008 the wire carries declarations underproperties.relationships), so the resolved view is the single source of truth for both directions.Tests
New
generic-schema-form-relationships-gate.test.ts— 3 cases: has-relationships → shown, none → hidden, load-error → fail-open shown.Isolation note: the test spies on the real
sharedNodeStore.getNode(restored per-test) rather thanvi.mock-ing that module — under vitest'sforkspool a module mock of the shared singleton leaks into other suites in the same fork (it brokenavigation-service's ancestor walk). Full frontend suite green (192 files / 4450 tests); eslint + svelte-check clean; pre-push gate passed.🤖 Generated with Claude Code