feat(ui): relationships sidebar panel + schema data (#21, ADR-0046 DB2/DB4)

The left column now stacks a Tables panel over a Relationships panel.
Each relationship renders as three narrow lines — its name, then the
endpoints broken at the arrow (Customers.id -> / indented
Orders.customer_id) — ellipsized past the inner width. The panel is
content-sized within [5 rows ("(none)" when empty), half the column];
the Tables panel keeps the rest (>=3 rows). Phase C adds focus+scroll
for content beyond the cap (clipped for now).

Data path: a new worker Request::ReadAllRelationships +
Database::read_all_relationships returns full RelationshipSchema
records; the runtime posts them via a RelationshipsRefreshed event
alongside the schema-cache refresh, and the App holds them in a new
`relationships` field.

ADR deviation (recorded in ADR-0046 DB2 + index): DB2 specified this
data on SchemaCache; it lives on the App instead — SchemaCache is
walker/completion-facing and needs only relationship names (untouched),
while the full records are UI-only, so App is the cleaner home and it
avoids editing ~23 SchemaCache literals. No behavioural difference.

Tests: panel-height bounds, the three-line render, the empty "(none)"
case, a snapshot, read_all_relationships end-to-end (real DB via the
m:n junction), and the event->field handler.
This commit is contained in:
claude@clouddev1
2026-06-10 18:44:27 +00:00
parent 386627a262
commit 94825d0f36
12 changed files with 324 additions and 26 deletions
+7
View File
@@ -1079,6 +1079,13 @@ async fn refresh_schema_cache(
) {
let cache = build_schema_cache(database).await;
let _ = event_tx.send(AppEvent::SchemaCacheRefreshed(cache)).await;
// ADR-0046 DB2: full relationship records for the sidebar panel.
// Best-effort — a failed read leaves the panel empty.
if let Ok(relationships) = database.read_all_relationships().await {
let _ = event_tx
.send(AppEvent::RelationshipsRefreshed(relationships))
.await;
}
}
/// Build a `SchemaCache` snapshot from the live database.