fix: A2UI surfaces

This commit is contained in:
2026-05-01 22:41:10 +02:00
parent a5193240ad
commit 11df11dbdb
4 changed files with 87 additions and 7 deletions

View File

@@ -352,7 +352,7 @@ defmodule BDS.Desktop.ShellLive.ChatEditor do
@spec chat_surface(term()) :: term()
def chat_surface(assigns) do
~H"""
<details id={@surface.id} class={["chat-inline-surface", "chat-inline-surface-#{@surface.type}"]} data-testid="chat-inline-surface" open={Map.get(@surface, :expanded?, false)}>
<details id={@surface.id} class={["chat-inline-surface", "chat-inline-surface-#{@surface.type}"]} data-testid="chat-inline-surface" data-expanded={Map.get(@surface, :expanded?, false)} open={Map.get(@surface, :expanded?, false)}>
<summary class="chat-inline-surface-header">
<span class="chat-inline-surface-icon"><%= surface_icon(@surface.type) %></span>
<span class="chat-inline-surface-title"><%= surface_title(@surface) %></span>

View File

@@ -100,7 +100,7 @@ defmodule BDS.Desktop.ShellLive.ChatEditor.MessageBuild do
tool_markers: tool_markers,
inline_surfaces:
ToolSurfaces.build_render_surfaces(tool_markers, message.id, assigns)
|> mark_latest_surface_expanded(assigns),
|> mark_surfaces_expanded(assigns),
tool_surfaces: []
}
end
@@ -125,15 +125,14 @@ defmodule BDS.Desktop.ShellLive.ChatEditor.MessageBuild do
}
end
defp mark_latest_surface_expanded([], _assigns), do: []
defp mark_surfaces_expanded([], _assigns), do: []
defp mark_latest_surface_expanded(surfaces, assigns) do
defp mark_surfaces_expanded(surfaces, assigns) do
dismissed = Map.get(assigns, :chat_editor_dismissed_surfaces, MapSet.new())
surfaces
|> Enum.reject(&MapSet.member?(dismissed, &1.id))
|> Enum.with_index()
|> Enum.map(fn {surface, index} -> Map.put(surface, :expanded?, index == length(surfaces) - 1) end)
|> Enum.map(&Map.put(&1, :expanded?, true))
end
defp pending_user_message(_messages, nil), do: nil
@@ -157,7 +156,7 @@ defmodule BDS.Desktop.ShellLive.ChatEditor.MessageBuild do
request
|> ToolTracking.tool_markers_from_events()
|> ToolSurfaces.build_render_surfaces("streaming-#{conversation_id}", assigns)
|> mark_latest_surface_expanded(assigns)
|> mark_surfaces_expanded(assigns)
end
defp translated(text, bindings \\ %{}),