Skip to main content

Module canvas

Module canvas 

Source
Expand description

A run drawn as connected steps on a canvas.

This is the shape an agent’s work takes when it stops being a list: steps as cards, connections as paths, and the failures that sent work back drawn as the loops they are rather than flattened into the forward order.

The division of labour is the same one the rest of the library keeps. The caller owns the run, the positions and the actions; the canvas owns the backdrop, the card, the path geometry and the states. There is no layout algorithm here on purpose: where a step belongs is a claim about the run, and a component that placed steps itself would be making that claim on every host’s behalf.

use gpui_kit::prelude::*;

let graph = NodeGraph::new("run.12")
    .node(
        GraphNode::new("run.12.plan", "Plan")
            .state(NodeState::Succeeded)
            .metric("tokens", "4.1k")
            .metric("took", "2.4s"),
        0.0,
        0.0,
    )
    .node(
        GraphNode::new("run.12.apply", "Apply")
            .state(NodeState::Failed)
            .action("write src/main.rs")
            .diff(Diff::new(24, 3)),
        280.0,
        0.0,
    )
    .edge(GraphEdge::new("run.12.plan", "run.12.apply"))
    .edge(GraphEdge::new("run.12.apply", "run.12.plan").feedback());

Structs§

Diff
How much a step changed, in lines.
GraphEdge
A controlled connection between two graph nodes.
GraphEndpoint
A caller-owned node and port identity used by connection proposals.
GraphNode
A step of a run, as a card on the canvas.
GraphPort
A typed connection point on a GraphNode.
GraphViewport
Caller-owned pan and zoom values for a NodeGraph.
NodeGraph
A run drawn as connected steps.
NodeMetric
One figure a step reports about itself, such as a token count or an elapsed time. Both halves are the caller’s words.
Placed
A node and where its top left corner sits, in canvas coordinates.

Enums§

EdgeKind
The routing treatment of an edge.
GraphState
What the canvas can currently say about itself.
NodeGraphEvent
A proposed controlled graph change.
NodeState
How a step ended, or that it has not.
PortDirection
Whether a port receives or produces data.
PortSide
The side of a node on which a port is placed.

Constants§

NODE_WIDTH
The default width of a node, in pixels.