Skip to main content

gpui_kit/canvas/
mod.rs

1//! A run drawn as connected steps on a canvas.
2//!
3//! This is the shape an agent's work takes when it stops being a list: steps
4//! as cards, connections as paths, and the failures that sent work back drawn
5//! as the loops they are rather than flattened into the forward order.
6//!
7//! The division of labour is the same one the rest of the library keeps. The
8//! caller owns the run, the positions and the actions; the canvas owns the
9//! backdrop, the card, the path geometry and the states. There is no layout
10//! algorithm here on purpose: where a step belongs is a claim about the run,
11//! and a component that placed steps itself would be making that claim on
12//! every host's behalf.
13//!
14//! ```no_run
15//! use gpui_kit::prelude::*;
16//!
17//! let graph = NodeGraph::new("run.12")
18//!     .node(
19//!         GraphNode::new("run.12.plan", "Plan")
20//!             .state(NodeState::Succeeded)
21//!             .metric("tokens", "4.1k")
22//!             .metric("took", "2.4s"),
23//!         0.0,
24//!         0.0,
25//!     )
26//!     .node(
27//!         GraphNode::new("run.12.apply", "Apply")
28//!             .state(NodeState::Failed)
29//!             .action("write src/main.rs")
30//!             .diff(Diff::new(24, 3)),
31//!         280.0,
32//!         0.0,
33//!     )
34//!     .edge(GraphEdge::new("run.12.plan", "run.12.apply"))
35//!     .edge(GraphEdge::new("run.12.apply", "run.12.plan").feedback());
36//! ```
37
38mod edge;
39mod graph;
40mod node;
41
42pub use edge::{EdgeKind, GraphEdge, GraphEndpoint, PortSide};
43pub use graph::{GraphState, GraphViewport, NodeGraph, NodeGraphEvent, Placed};
44pub use node::{Diff, GraphNode, GraphPort, NODE_WIDTH, NodeMetric, NodeState, PortDirection};