Skip to content

Schema-Driven Relationship UI Components #710

Closed as not planned
Closed as not planned

Description

@malibio

Schema-Driven Relationship UI Components

Overview

Implement UI components in the schema-driven property system (BaseNode) to render, create, and manage relationships defined in schema nodes.

Background

Backend Status (Issue #703): ✅ Complete

  • Relationships can be defined in schema nodes
  • Edge tables are generated via DDL
  • CRUD API exists for managing relationships
  • Data model supports cardinality, direction, edge fields

Frontend Status: ❌ Missing

  • Schema-driven UI renders regular fields (text, number, enum, etc.)
  • No UI components exist for relationship fields
  • Users cannot view or interact with relationships through the property UI

Example Scenario

Given this schema definition:

{
  "id": "task",
  "fields": [
    { "name": "status", "type": "enum", "values": ["open", "done"] }
  ],
  "relationships": [
    {
      "name": "assigned_to",
      "targetType": "person",
      "cardinality": "many"
    }
  ]
}

Current behavior:

  • ✅ status field renders as dropdown with enum values
  • ❌ assigned_to relationship has no UI representation

Desired behavior:

  • ✅ status field renders as dropdown with enum values
  • ✅ assigned_to relationship renders with:
    • Display of currently assigned people
    • UI to add new assignments (search/dropdown)
    • UI to remove assignments

Requirements

1. Display Existing Relationships

  • Show all current relationships for a node
  • Handle both one and many cardinality
  • Display related node content/title
  • Show edge field data (e.g., "assigned on 2025-01-15")

2. Create New Relationships

  • Provide search/autocomplete for target nodes
  • Filter by target type from schema definition
  • Respect cardinality constraints (prevent multiple for "one")
  • Support adding edge field data during creation

3. Edit/Remove Relationships

  • Allow removing existing relationships
  • Support editing edge field data
  • Confirm destructive actions

4. UI Patterns to Consider

  • Cardinality "one": Dropdown or autocomplete (single selection)
  • Cardinality "many": Multi-select with search, tag-style display
  • Edge fields: Inline form or modal for additional data
  • Reverse relationships: Display only (not editable from this side)

Implementation Phases

Phase 1: Read-Only Display

  • Render existing relationships in property UI
  • Handle both cardinality types
  • Show related node basic info

Phase 2: Basic CRUD

  • Add UI to create new relationships
  • Add UI to remove relationships
  • Simple dropdown/search for target selection

Phase 3: Advanced Features

  • Edge field editing
  • Reverse relationship display
  • Validation and error handling
  • Optimistic UI updates

Technical Notes

Schema-Driven UI Location:

  • BaseNode component renders properties based on schema
  • SchemaPropertyForm or similar component handles field rendering
  • Need new relationship-specific renderer component

API Integration:

State Management:

  • Integrate with existing node state and reactivity
  • Handle optimistic updates for better UX
  • Sync with backend on success/failure

Dependencies

Acceptance Criteria

  • Relationship fields render in BaseNode property UI
  • Users can view existing relationships
  • Users can create new relationships via search/dropdown
  • Users can remove existing relationships
  • Cardinality constraints are enforced in UI
  • Edge fields can be added during relationship creation
  • UI updates reactively when relationships change
  • Works for both "one" and "many" cardinality
  • Comprehensive tests for relationship UI components

Related Issues

Notes

Until this issue is resolved, the DDL generation for relationships is commented out in node_service.rs to avoid creating edge tables that users cannot interact with through the UI.

Activity

  1. malibio commented on Jul 5, 2026

    @malibio
    CollaboratorAuthor

    Architecture-review note: this assumes the edge-table DDL generator, which is being deleted as dead SurrealDB code (#1496 — the SQLite store discards that DDL). Re-scope this against the current SQLite/graph-edge model when picked up.

  2. malibio commented on Aug 3, 2026

    @malibio
    CollaboratorAuthor

    Closing as superseded by #1918 (Relationship viewer: view and manage typed relationships between nodes).

    #1918 covers the same goal — surfacing schema-declared typed relationships in the UI — but is scoped against the current SQLite/graph-edge model rather than the SurrealDB one, with verified references:

    • relationship edge table — packages/core/src/db/schema.sql:43
    • SchemaRelationship (name, target_type, direction, cardinality, reverse_name, edge_fields) — packages/nodespace-types/src/schema.rs:122
    • CRUD ops — packages/core/src/ops/rel_ops.rs
    • RelationshipCache — packages/core/src/services/relationship_cache.rs

    It also identifies gaps this issue did not: there is no Tauri command surface for schema-declared relationships (commands/nodes.rs exposes mention commands only), so the frontend cannot reach rel_ops at all; and cardinality is stored and cached but never enforced on any write path.

    The July note on this issue already flagged the blocker: this spec assumes the edge-table DDL generator that was deleted as dead SurrealDB code in #1496. Rather than re-scope it, the work continues in #1918.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions