Repository navigation
Description
Overview
The Relationships entry-point button in GenericSchemaForm renders unconditionally for every node with a schema, regardless of whether that schema actually declares any typed relationships. Clicking it on a schema with none opens the relationship viewer modal only to show "no typed relationships." This was a known, explicitly-accepted gap from #1918's initial review — flagged as "unavoidable without a pre-query, acceptable" at the time — but should be tightened now that real relationships are starting to be modeled (project ↔ task — see #1999, which adds that relationship and is a prerequisite for meaningfully testing this fix), making the always-visible button noise on every other type.
Problem Statement
packages/desktop-app/src/lib/components/schema/generic-schema-form.svelte:244-252:
<!-- Relationships entry point (read-only viewer, issue #1918) -->
<button
type="button"
class="..."
onclick={() => (showRelationships = true)}
>
<WaypointsIcon class="h-4 w-4" />
<span>Relationships</span>
</button>This button has no visibility guard at all — contrast with the fields Collapsible immediately above it, which is correctly gated on {#if schema.fields.length > 0} (line 127). The Relationships button renders for every node whose schema loads successfully, whether or not schema.relationships is non-empty, or whether any other schema declares an inbound relationship targeting this type (RelationshipCache::get_inbound_relationships, per #1918's bi-directional design).
This was surfaced and explicitly deferred during #1918's code review: "the trigger renders for every schema node even when the node has zero typed relationships (opens → 'no typed relationships'); unavoidable without a pre-query, acceptable." That tradeoff should be revisited now — as real relationships get modeled, an unconditional button on every other type becomes more noticeable UI clutter rather than a rare edge case.
No schema currently has any relationships defined (confirmed live, [] on every schema in the database), so today this bug is invisible — every click on the button shows the empty state. #1999 adds the first real relationship (project ↔ task), which is what makes this gate meaningfully testable — until #1999 lands, there is no schema with a relationship to verify the button correctly stays visible for, only schemas to verify it correctly disappears for.
Proposed Solution
Gate the Relationships button on whether relationships actually exist for this node's type. The pre-query the original review called "unavoidable" is exactly what's needed now: check whether the schema declares any outbound relationships, OR whether RelationshipCache::get_inbound_relationships(nodeType) returns anything for this type, before rendering the button. Since schemaFormLoader/schema is already loaded before this component renders (the fields-gate above already reads schema.fields), the outbound half is likely a cheap local check (schema.relationships.length > 0) with no extra round-trip; the inbound half may need a query similar to what RelationshipViewerModal itself already performs on open — reuse that existing query/cache lookup rather than duplicating it, ideally hoisting it to run once (e.g. on schema load) rather than per-render.
Acceptance Criteria
- Opening a
projectnode (once Fix project/task schema field descriptions and add the missing project-task relationship #1999's relationship exists) shows the Relationships button - Opening a
tasknode (once Fix project/task schema field descriptions and add the missing project-task relationship #1999's relationship exists) shows the Relationships button, reflecting the inbound side - A schema/node with genuinely no relationships in either direction (outbound declared or inbound targeting it) does NOT show the Relationships button
- No new test failures (
bun run test:all) - Code passes
bun run quality:fix
Technical Specifications
Reference Files
packages/desktop-app/src/lib/components/schema/generic-schema-form.svelte:244-252— the ungated Relationships buttonpackages/core/src/services/relationship_cache.rs:128—get_inbound_relationships, the existing mechanism for the inbound-side checkpackages/desktop-app/src/lib/components/relationships/relationship-viewer-modal.svelte— the modal's own query/load logic on open; reuse rather than duplicate for the pre-render gate
Non-Goals
- Does not define the
project↔taskrelationship itself — that's Fix project/task schema field descriptions and add the missing project-task relationship #1999's scope, and is a prerequisite for meaningfully testing this fix (this issue's own acceptance criteria depend on Fix project/task schema field descriptions and add the missing project-task relationship #1999's relationship existing). - Does not change
#1998's scope (properties-form rendering gate) — this is specifically about the Relationships button's own visibility condition, a separate gate in the same file.
Related Issues
- Relationship viewer: view and manage typed relationships between nodes #1918 (relationship viewer — where this gap was originally identified and explicitly deferred)
- Fix project/task schema field descriptions and add the missing project-task relationship #1999 (adds the
project↔taskrelationship this issue's fix needs to be testable against — should land first or alongside) - isCustomSchemaType conflates "is core" with "has a dedicated frontend integration" across 4 call sites #1998 (related but distinct: gates whether the properties form renders for
project, not the Relationships button)
Activity
mstomar125 commentedon Aug 10, 2026
Resolved by PR #2017 (merged, main
5beb8579).The Relationships trigger in
GenericSchemaFormis now gated: it renders only when the node's type actually has a typed relationship. The gate runs the viewer's own load (loadNodeRelationshipsView) once per node and shows the button iff it yields any declared group; default hidden, fail-open on a load error.Getting AC2 right surfaced a real backend asymmetry:
get_node_relationshipsemitted empty outbound declared groups but dropped empty inbound ones, so ataskwith no linked project (itsprojectlink is a derived inbound of #1999's project→task) would have hidden the button. Fixed by making the inbound branch symmetric — declared groups are now returned on both sides even when empty — which also lets the viewer add the first inbound edge from the target side. Covered by a newget_node_relationshipstest plus the frontend gate test; independent review APPROVE.