prev/next A2UI surface and better dismissal
This commit is contained in:
@@ -10,7 +10,7 @@ impl App {
|
||||
let mut markdown = HashMap::new();
|
||||
let mut editors = HashMap::new();
|
||||
let mut filters = HashSet::new();
|
||||
for surface in self.a2ui.surfaces() {
|
||||
if let Some(surface) = self.displayed_a2ui_store().active_surface() {
|
||||
collect_renderer_state(
|
||||
surface,
|
||||
"root",
|
||||
@@ -44,12 +44,10 @@ impl App {
|
||||
.retain(|key, _| filters.contains(key));
|
||||
}
|
||||
|
||||
pub(super) fn a2ui_surfaces(&self, message_id: i32) -> Element<'_, Message> {
|
||||
let mut surfaces = column![].spacing(10);
|
||||
for surface in self.a2ui.surfaces_for_message(message_id) {
|
||||
surfaces = surfaces.push(self.a2ui_surface(surface));
|
||||
}
|
||||
surfaces.into()
|
||||
pub(super) fn displayed_a2ui_surface(&self) -> Option<Element<'_, Message>> {
|
||||
self.displayed_a2ui_store()
|
||||
.active_surface()
|
||||
.map(|surface| self.a2ui_surface(surface))
|
||||
}
|
||||
|
||||
fn a2ui_surface<'a>(&'a self, surface: &'a Surface) -> Element<'a, Message> {
|
||||
@@ -66,19 +64,44 @@ impl App {
|
||||
.color(muted_text())
|
||||
.into()
|
||||
};
|
||||
let dismiss = action_button(text("Dismiss").size(11)).padding([5, 9]);
|
||||
let dismiss = if self.generating || self.a2ui_history_index.is_some() {
|
||||
dismiss
|
||||
} else {
|
||||
dismiss.on_press(Message::RequestA2uiDismiss(surface.id.clone()))
|
||||
};
|
||||
let previous = action_button(icon(ICON_ARROW_LEFT, 15)).padding(5);
|
||||
let previous = if self.has_previous_a2ui_surface() {
|
||||
previous.on_press(Message::A2uiPreviousSurface)
|
||||
} else {
|
||||
previous
|
||||
};
|
||||
let next = action_button(icon(ICON_ARROW_RIGHT, 15)).padding(5);
|
||||
let next = if self.has_next_a2ui_surface() {
|
||||
next.on_press(Message::A2uiNextSurface)
|
||||
} else {
|
||||
next
|
||||
};
|
||||
container(
|
||||
column![
|
||||
row![
|
||||
previous,
|
||||
next,
|
||||
text(agent).size(10).color(muted_text()),
|
||||
Space::new().width(Length::Fill),
|
||||
text(&surface.id).size(10).color(muted_text()),
|
||||
],
|
||||
content,
|
||||
dismiss,
|
||||
]
|
||||
.spacing(8)
|
||||
.align_y(Alignment::Center),
|
||||
scrollable(content).height(Length::Fill),
|
||||
]
|
||||
.height(Length::Fill)
|
||||
.spacing(10),
|
||||
)
|
||||
.padding(14)
|
||||
.width(Length::Fill)
|
||||
.height(Length::Fill)
|
||||
.style(preference_group_style)
|
||||
.into()
|
||||
}
|
||||
@@ -856,7 +879,7 @@ impl App {
|
||||
|
||||
pub(super) fn a2ui_modal_panel(&self) -> Option<Element<'_, Message>> {
|
||||
let (surface_id, component_id) = self.a2ui_modals.iter().next()?;
|
||||
let surface = self.a2ui.surface(surface_id)?;
|
||||
let surface = self.displayed_a2ui_store().surface(surface_id)?;
|
||||
let component = surface.components.get(component_id)?.as_object()?;
|
||||
let content_id = component.get("content")?.as_str()?;
|
||||
let content =
|
||||
|
||||
Reference in New Issue
Block a user