gpui-kit GitHub

Scenes

tool-call

Builds Card ToolCallCard

tool-call in the dark theme
studio-dark
tool-call in the light theme
studio-light

The code that drew it

A still frame holds a repeating animation at its first frame and a one-shot at its last, because a still of a moving thing is not reproducible. Run the gallery to review motion.

fn tool_call(_window: &mut Window, cx: &mut App) -> AnyElement {
    let theme = cx.theme().clone();
    div()
        .flex()
        .gap(px(theme.spacing.lg))
        .child(
            stack(&theme).w(px(460.0)).child(
            ToolCallCard::new("scene.tool.pending", "workspace.search")
                .arguments(scene_arguments())
                .state(ToolCallState::PendingApproval),
        )
        .child(
            ToolCallCard::new("scene.tool.running", "workspace.index")
                .arguments("{ \"root\": \"crates\" }")
                .state(ToolCallState::Running)
                .elapsed("4.2 s"),
        )
        .child(
            ToolCallCard::new("scene.tool.succeeded", "workspace.read")
                .arguments("{ \"path\": \"README.md\" }")
                .state(ToolCallState::succeeded(
                    ToolBody::new(
                        "# gpui-kit\n\nProduct-neutral components.\n\nEvery word is replaceable.",
                    )
                    .max_lines(2),
                ))
                .elapsed("0.3 s"),
        )
        .child(
            ToolCallCard::new("scene.tool.silent", "workspace.touch")
                .arguments("{ \"path\": \"notes.md\" }")
                .state(ToolCallState::succeeded_silently())
                .elapsed("0.1 s"),
        ),
        )
        .child(
            stack(&theme)
                .w(px(460.0))
                .child(
                    ToolCallCard::new("scene.tool.failed", "workspace.write")
                        .arguments("{ \"path\": \"/read-only/notes.md\" }")
                        .state(ToolCallState::failed(
                            "The file system reported that the path is read only.",
                        ))
                        .elapsed("0.2 s")
                        .on_retry(|_, _| {}),
                )
                // A refusal reads as a decision: it is not the failure above
                // it, and not the silent success in the other column.
                .child(
                    ToolCallCard::new("scene.tool.refused", "shell.run")
                        .arguments("{ \"command\": \"rm -rf build\" }")
                        .state(ToolCallState::refused(
                            "This workspace does not allow shell commands.",
                        )),
                ),
        )
        .into_any_element()
}