Components / display
FailurePanel builder
A panel that states what went wrong instead of what it was going to show.
A builder is RenderOnce. Construct and mount it in one expression.
use gpui_kit::display::failure_panel::FailurePanel;
Reviewed in failure-panel.
Construct
new(ident: impl Into<Ident>, reason: impl Into<SharedString>) -> Self
from_result<T, E: std::fmt::Display>(ident: impl Into<Ident>, result: &Result<T, E>) -> Option<Self>
Options
Chain onto the value.
title(title: impl Into<SharedString>) -> Self
detail(detail: impl Into<SharedString>) -> Self
attempts(attempts: usize) -> Self
retrying(retrying: bool) -> Self
on_retry(handler: impl Fn(&mut Window, &mut App) + 'static) -> Self
Example · failure-panel
fn failure_panel(_window: &mut Window, cx: &mut App) -> AnyElement {
let theme = cx.theme().clone();
// A failure, not a refusal. Retrying a refusal would only be refused
// again, so the retry here is offered against something that can succeed
// on a second attempt; refusals are shown by ToolCall instead.
let failed: Result<(), &str> = Err("The runs service did not respond.");
stack(&theme)
.w(px(560.0))
.child(caption(
&theme,
"the host's own words, kept on screen; the retry belongs to the host",
))
.children(
FailurePanel::from_result("scene.failure.query", &failed).map(|panel| {
panel
.title("Runs")
.detail("The connection timed out after 30 seconds.")
.attempts(3)
.on_retry(|_, _| {})
}),
)
.into_any_element()
}