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:
@@ -837,6 +837,13 @@ enum Request {
|
||||
source: crate::dsl::grammar::IdentSource,
|
||||
reply: oneshot::Sender<Result<Vec<String>, DbError>>,
|
||||
},
|
||||
/// All relationships as full schema records (name, parent/child
|
||||
/// tables + columns, referential actions). Feeds the sidebar
|
||||
/// relationships panel (ADR-0046 DB2); the walker only needs the
|
||||
/// names, which `ListNamesFor` already provides.
|
||||
ReadAllRelationships {
|
||||
reply: oneshot::Sender<Result<Vec<RelationshipSchema>, DbError>>,
|
||||
},
|
||||
/// Restore the most recent undo snapshot (ADR-0006 Amendment 1).
|
||||
/// Replies with the metadata of the command that was undone, or
|
||||
/// `None` if there is nothing to undo (or undo is disabled).
|
||||
@@ -1787,6 +1794,14 @@ impl Database {
|
||||
recv.await.map_err(|_| DbError::WorkerGone)?
|
||||
}
|
||||
|
||||
/// All relationships as full schema records, for the sidebar
|
||||
/// relationships panel (ADR-0046 DB2).
|
||||
pub async fn read_all_relationships(&self) -> Result<Vec<RelationshipSchema>, DbError> {
|
||||
let (reply, recv) = oneshot::channel();
|
||||
self.send(Request::ReadAllRelationships { reply }).await?;
|
||||
recv.await.map_err(|_| DbError::WorkerGone)?
|
||||
}
|
||||
|
||||
/// Restore the most recent undo snapshot (ADR-0006 Amendment 1).
|
||||
/// `Ok(Some(meta))` reports the command that was undone;
|
||||
/// `Ok(None)` means nothing to undo (or undo is disabled).
|
||||
@@ -2774,6 +2789,9 @@ fn handle_request(
|
||||
let result = do_list_names_for(conn, source);
|
||||
let _ = reply.send(result);
|
||||
}
|
||||
Request::ReadAllRelationships { reply } => {
|
||||
let _ = reply.send(read_all_relationships(conn));
|
||||
}
|
||||
// Undo/redo/peek/batch are intercepted in `worker_loop` (they
|
||||
// need `&mut conn` or persistent batch state) and never reach
|
||||
// here. Listed explicitly so a new variant still forces a
|
||||
|
||||
Reference in New Issue
Block a user