GPUI Box GitHub

Components / content

MessageList builder

A conversation.

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

use gpui_kit::content::MessageList;

Reviewed in conversation conversation-growing.

Construct
new(ident: impl Into<Ident>, messages: impl IntoIterator<Item = Message>) -> Self
Options

Chain onto the value.

visible_rows(rows: usize) -> Self
body_lines(lines: usize) -> Self
grows_to_fit() -> Self
group_consecutive(group: bool) -> Self
on_retry(handler: impl Fn(SharedString, &mut Window, &mut App) + 'static) -> Self
on_markdown(handler: impl Fn(SharedString, &MarkdownEvent, &mut Window, &mut App) + 'static) -> Self
Example · conversation
fn conversation(_window: &mut Window, cx: &mut App) -> AnyElement {
    let theme = cx.theme().clone();
    stack(&theme)
        .w(px(560.0))
        .child(
            MessageList::new("scene.conversation.thread", scene_thread(&theme))
                .group_consecutive(true)
                .body_lines(2)
                .on_retry(|_, _, _| {})
                .on_markdown(|_, _, _, _| {}),
        )
        .child(
            Divider::new()
                .id("scene.conversation.rule")
                .label("Scrolled away from the newest message"),
        )
        .child(
            // A viewport shorter than the thread opens at its top, so the
            // messages below it have never been on screen and the list says
            // how many there are rather than letting them be discovered.
            MessageList::new("scene.conversation.behind", scene_thread(&theme))
                .visible_rows(2)
                .body_lines(2)
                .on_retry(|_, _, _| {}),
        )
        .into_any_element()
}

Source: crates/gpui-kit/src/content/message_list.rs