Components / agent
OfferingCatalog builder
A searchable, kind-filterable catalog of offerings from multiple servers.
A builder is RenderOnce. Construct and mount it in one expression.
use gpui_kit::agent::OfferingCatalog;
Reviewed in offering-catalog.
Construct
new(ident: impl Into<Ident>) -> Self
Options
Chain onto the value.
source(source: OfferingSource) -> Self
sources(sources: impl IntoIterator<Item = OfferingSource>) -> Self
query(query: impl Into<SharedString>) -> Self
kinds(kinds: impl IntoIterator<Item = OfferingKind>) -> Self
selected(identity: OfferingIdentity) -> Self
on_activate(handler: impl Fn(OfferingIdentity, &mut Window, &mut App) + 'static) -> Self
Example · offering-catalog
fn offering_catalog(_window: &mut Window, cx: &mut App) -> AnyElement {
let theme = cx.theme().clone();
let workspace = OfferingSource::new(
"workspace",
"Workspace tools",
OfferingSourceState::Ready(vec![
SearchableOffering::new(
Offering::tool("read", "Read a file")
.summary("Returns the contents of one file")
.qualifier("path, max_bytes"),
"read file contents path workspace",
),
SearchableOffering::new(
Offering::skill("review", "Review a change")
.summary("Reads a diff and reports what it finds"),
"review change diff findings",
),
]),
);
let archive = OfferingSource::new(
"archive",
"Archive tools",
OfferingSourceState::Stale {
offerings: vec![
SearchableOffering::new(
Offering::tool("read", "Read a file").summary("Reads one archived file"),
"read archived file contents",
),
SearchableOffering::new(
Offering::resource("changelog", "Changelog").qualifier("archive:/CHANGELOG.md"),
"changelog changes release history",
),
],
reason: "Archive refresh failed; showing the last verified results.".into(),
},
);
stack(&theme)
.w(px(560.0))
.child(
OfferingCatalog::new("scene.offering-catalog")
.sources([workspace, archive])
.selected(OfferingIdentity::new("workspace", "read"))
.on_activate(|_, _, _| {}),
)
.into_any_element()
}