GPUI Box GitHub

Components / agent

FeedbackRating builder

A helpful / not-helpful control with optional host-owned reason tags.

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

use gpui_kit::agent::FeedbackRating;

Reviewed in feedback-rating.

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

Chain onto the value.

vote(vote: Option<FeedbackVote>) -> Self
tags(tags: impl IntoIterator<Item = (impl Into<SharedString>, impl Into<SharedString>)>) -> Self
current_tag(tag: impl Into<SharedString>) -> Self
on_vote(handler: impl Fn(FeedbackVote, &mut Window, &mut App) + 'static) -> Self
on_tag(handler: impl Fn(SharedString, &mut Window, &mut App) + 'static) -> Self
Reports

The variants of the event it emits. It never applies the change itself.

  • Voted
  • Tagged
Example · feedback-rating
fn feedback_rating(_window: &mut Window, cx: &mut App) -> AnyElement {
    let theme = cx.theme().clone();
    stack(&theme)
        .w(px(420.0))
        .child(caption(
            &theme,
            "vote and reason tags are host-owned; a disabled control installs no handler",
        ))
        .child(
            FeedbackRating::new("scene.feedback.ready")
                .vote(Some(FeedbackVote::Up))
                .tags([("accurate", "Accurate"), ("incomplete", "Incomplete")])
                .current_tag("accurate")
                .on_vote(|_, _, _| {})
                .on_tag(|_, _, _| {}),
        )
        .child(FeedbackRating::new("scene.feedback.idle").on_vote(|_, _, _| {}))
        .child(FeedbackRating::new("scene.feedback.disabled").disabled(true))
        .into_any_element()
}

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