fix: A2UI now behaves better

This commit is contained in:
2026-05-01 23:15:04 +02:00
parent 64a5eb525d
commit c495a2ed0a
7 changed files with 163 additions and 12 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" data-expanded={Map.get(@surface, :expanded?, false)} 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={surface_expanded_attr(@surface)} 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>
@@ -566,6 +566,10 @@ defmodule BDS.Desktop.ShellLive.ChatEditor do
defp surface_icon("tabs"), do: ""
defp surface_icon(_type), do: ""
defp surface_expanded_attr(surface) do
if Map.get(surface, :expanded?, false), do: "true", else: "false"
end
defp surface_title(surface) do
cond do
present?(Map.get(surface, :title)) -> Map.get(surface, :title)

View File

@@ -99,16 +99,15 @@
<%= if message.role == :assistant do %>
<div class="chat-message-text"><%= markdown_html(message.content || "") %></div>
<%= for surface <- message.inline_surfaces do %>
<.chat_surface surface={surface} />
<% end %>
<% else %>
<div class="chat-message-text chat-user-message-text" data-testid="chat-user-message-text"><%= message.content || "" %></div>
<% end %>
</div>
</div>
<%= for surface <- message.inline_surfaces do %>
<.chat_surface surface={surface} />
<% end %>
<% end %>
<%= if @chat_editor.is_streaming and (@chat_editor.streaming_content != "" or @chat_editor.streaming_tool_markers != []) do %>
@@ -124,12 +123,11 @@
<%= if @chat_editor.streaming_content != "" do %>
<div class="chat-message-text"><%= markdown_html(@chat_editor.streaming_content) %></div>
<% end %>
<%= for surface <- @chat_editor.streaming_inline_surfaces do %>
<.chat_surface surface={surface} />
<% end %>
</div>
</div>
<%= for surface <- @chat_editor.streaming_inline_surfaces do %>
<.chat_surface surface={surface} />
<% end %>
<% end %>
<%= if @chat_editor.is_streaming and @chat_editor.streaming_content == "" and @chat_editor.streaming_tool_markers == [] do %>