Components / agent
AgentActivityLine builder
The localized execution sentence and its non-colour status mark.
A builder is RenderOnce. Construct and mount it in one expression.
use gpui_kit::agent::AgentActivityLine;
Reviewed in agent-avatar.
Construct
new(ident: impl Into<Ident>, execution: AgentExecutionState) -> Self
Options
Chain onto the value.
tint(tint: Hsla) -> Self
Example · agent-avatar
fn agent_avatar(_window: &mut Window, cx: &mut App) -> AnyElement {
let theme = cx.theme().clone();
let identity = |id: &'static str, name: &'static str, presence: AgentPresence| {
AgentSnapshot::new(AgentDescriptor::new(id, name).role("Repository research"))
.presence(presence)
};
let executions = [
(
"active",
AgentExecutionState::Active(AgentActivity::UsingTool("repository search".into())),
),
(
"waiting",
AgentExecutionState::Waiting(WaitReason::Approval),
),
(
"succeeded",
AgentExecutionState::Completed(AgentOutcome::Succeeded),
),
(
"failed",
AgentExecutionState::Completed(AgentOutcome::Failed(
"the verifier could not reach the test host".into(),
)),
),
(
"refused",
AgentExecutionState::Completed(AgentOutcome::Refused(
"this workspace requires approval".into(),
)),
),
];
stack(&theme)
.child(caption(
&theme,
"Presence is a separate mark, so it does not compete with the identity tint",
))
.child(
row(&theme)
.items_center()
.gap_token(&theme, Space::Md)
.child(AgentAvatar::new(
"scene.agent-avatar.online",
identity("nova", "Nova", AgentPresence::Online),
))
.child(AgentAvatar::new(
"scene.agent-avatar.away",
identity("sage", "Sage", AgentPresence::Away),
))
.child(AgentAvatar::new(
"scene.agent-avatar.offline",
identity("bolt", "Bolt", AgentPresence::Offline),
))
.child(
AgentAvatar::new(
"scene.agent-avatar.tinted",
identity("atlas", "Atlas", AgentPresence::Online),
)
.tint(identity_tint(&theme, "agent.external")),
),
)
.child(caption(&theme, "Sizes"))
.child(
row(&theme)
.items_center()
.gap_token(&theme, Space::Md)
.child(
AgentAvatar::new(
"scene.agent-avatar.small",
identity("nova", "Nova", AgentPresence::Online),
)
.size(20.0),
)
.child(AgentAvatar::new(
"scene.agent-avatar.default",
identity("nova", "Nova", AgentPresence::Online),
))
.child(
AgentAvatar::new(
"scene.agent-avatar.large",
identity("nova", "Nova", AgentPresence::Online),
)
.size(44.0),
),
)
.child(caption(
&theme,
"The execution sentence, which carries a non-colour mark because \
colour alone is not a report",
))
.child(
div()
.column()
.gap_token(&theme, Space::Sm)
.children(executions.map(|(id, execution)| {
AgentActivityLine::new(format!("scene.agent-avatar.line.{id}"), execution)
.into_any_element()
})),
)
.into_any_element()
}