Components / agent
ArtifactPreview builder
A titled pane for a generated artifact.
A builder is RenderOnce. Construct and mount it in one expression.
use gpui_kit::agent::ArtifactPreview;
Reviewed in artifact-preview.
Construct
new(ident: impl Into<Ident>, title: impl Into<SharedString>) -> Self
Options
Chain onto the value.
kind(kind: ArtifactKind) -> Self
language(language: Language) -> Self
body(body: impl Into<SharedString>) -> Self
state(state: ArtifactPreviewState) -> Self
Example · artifact-preview
fn artifact_preview(_window: &mut Window, cx: &mut App) -> AnyElement {
let theme = cx.theme().clone();
stack(&theme)
.w(px(480.0))
.child(caption(
&theme,
"a generated artifact is shown as the kind it is; a refusal stays a refusal",
))
.child(
ArtifactPreview::new("scene.artifact.ready", "patch.rs")
.kind(ArtifactKind::Code)
.language(Language::Rust)
.body(
"/// Whether the run may be published.\n\
fn ready(state: &State) -> bool {\n \
state.checks == 12 && !state.blocked\n\
}",
)
.state(ArtifactPreviewState::Ready),
)
.child(
ArtifactPreview::new("scene.artifact.loading", "notes.md")
.state(ArtifactPreviewState::Loading),
)
.child(
ArtifactPreview::new("scene.artifact.empty", "notes.md")
.state(ArtifactPreviewState::Empty),
)
.child(
ArtifactPreview::new("scene.artifact.unavailable", "notes.md").state(
ArtifactPreviewState::Unavailable("The artifact host is offline.".into()),
),
)
.child(
ArtifactPreview::new("scene.artifact.error", "notes.md").state(
ArtifactPreviewState::Error("The artifact parser rejected this result.".into()),
),
)
.into_any_element()
}