GPUI Box GitHub

Components / agent

AgentCard builder

A complete summary of one agent and its current caller-owned task.

A builder is RenderOnce. Construct and mount it in one expression.

use gpui_kit::agent::AgentCard;

Reviewed in agent-roster.

Construct
new(ident: impl Into<Ident>, agent: AgentSnapshot) -> Self
Options

Chain onto the value.

task_label(label: impl Into<SharedString>) -> Self
image(image: impl Into<SharedString>) -> Self
image_source(image: gpui::ImageSource) -> Self
tint(tint: Hsla) -> Self
selected(selected: bool) -> Self
on_action(handler: impl Fn(AgentUiAction, &mut Window, &mut App) + 'static) -> Self
Example · agent-roster
fn agent_roster(_window: &mut Window, cx: &mut App) -> AnyElement {
    let theme = cx.theme().clone();
    let direction = cx.layout_direction();
    let run = scene_agent_run();
    let root = run
        .agents
        .first()
        .cloned()
        .expect("the canonical multi-agent scene has a root agent");

    stack(&theme)
        .w(px(720.0))
        .child(
            div()
                .row_reading(direction)
                .items_center()
                .justify_between()
                .child(
                    div()
                        .column()
                        .gap_token(&theme, Space::Xs)
                        .child(
                            div()
                                .type_scale(&theme, TypeScale::Title)
                                .text_tone(&theme, TextTone::Primary)
                                .child("Release review"),
                        )
                        .child(AgentActivityLine::new(
                            "scene.agent-roster.run-state",
                            run.execution.clone(),
                        )),
                )
                .child(
                    AgentGroup::new("scene.agent-roster.group", run.agents.clone()).max_visible(3),
                ),
        )
        .child(
            AgentCard::new("scene.agent-roster.root", root)
                .task_label("Synthesis")
                .selected(true)
                .on_action(|_, _, _| {}),
        )
        .child(
            div()
                .row_reading(direction)
                .items_start()
                .gap_token(&theme, Space::Lg)
                .child(
                    div().w(px(420.0)).child(
                        AgentRoster::from_run("scene.agent-roster.list", &run)
                            .selected("researcher")
                            .visible_rows(4)
                            .on_action(|_, _, _| {}),
                    ),
                )
                .child(
                    div().w(px(270.0)).child(
                        SubagentTree::new("scene.agent-roster.tree", run)
                            .expanded(["orchestrator".into(), "researcher".into()])
                            .selected("researcher")
                            .visible_rows(4)
                            .on_toggle(|_, _, _, _| {})
                            .on_action(|_, _, _| {}),
                    ),
                ),
        )
        .into_any_element()
}

Source: crates/gpui-kit/src/agent/presentation.rs