Skip to content

Relationships trigger shows even when a schema has no typed relationships defined #2007

Closed

Description

@malibio

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

Technical Specifications

Reference Files

  • packages/desktop-app/src/lib/components/schema/generic-schema-form.svelte:244-252 — the ungated Relationships button
  • packages/core/src/services/relationship_cache.rs:128 — get_inbound_relationships, the existing mechanism for the inbound-side check
  • packages/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

Related Issues

Activity

  1. added
    bug
    on Aug 7, 2026
  2. mstomar125 commented on Aug 10, 2026

    @mstomar125
    Contributor

    Resolved by PR #2017 (merged, main 5beb8579).

    The Relationships trigger in GenericSchemaForm is 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_relationships emitted empty outbound declared groups but dropped empty inbound ones, so a task with no linked project (its project link 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 new get_node_relationships test plus the frontend gate test; independent review APPROVE.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugui

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions