fix: a2ui is much closer to bDS parity than before

This commit is contained in:
2026-05-31 14:32:15 +02:00
parent a33131ddea
commit 040b5db37b
6 changed files with 16206 additions and 41 deletions

View File

@@ -370,28 +370,41 @@
.chat-surface-chart-heatmap { .chat-surface-chart-heatmap {
display: grid; display: grid;
gap: 2px; gap: 2px;
font-size: 10px; font-size: 11px;
} }
.chat-surface-chart-heatmap-col-label, .chat-surface-chart-heatmap-corner {
.chat-surface-chart-heatmap-row-label { /* empty top-left cell */
display: flex;
align-items: center;
padding: 2px 4px;
color: var(--vscode-descriptionForeground);
} }
.chat-surface-chart-heatmap-col-label { .chat-surface-chart-heatmap-col-label {
justify-content: center; text-align: center;
opacity: 0.7;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.chat-surface-chart-heatmap-row-label {
text-align: right;
padding-right: 4px;
opacity: 0.7;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
max-width: 80px;
} }
.chat-surface-chart-heatmap-cell { .chat-surface-chart-heatmap-cell {
aspect-ratio: 1;
min-width: 14px;
min-height: 14px;
border-radius: 2px;
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
min-height: 24px; font-size: 10px;
padding: 4px 2px; font-weight: 500;
border-radius: 2px;
font-variant-numeric: tabular-nums; font-variant-numeric: tabular-nums;
} }

View File

@@ -738,21 +738,7 @@ defmodule BDS.Desktop.ShellLive.ChatEditor do
<% "heatmap" -> %> <% "heatmap" -> %>
<% heat = BDS.Desktop.ShellLive.ChatEditor.ChartView.heatmap(@surface.series) %> <% heat = BDS.Desktop.ShellLive.ChatEditor.ChartView.heatmap(@surface.series) %>
<%= if heat.rows == [] do %> <%= if heat.rows != [] do %>
<div class="chat-surface-chart-list">
<%= for series <- @surface.series do %>
<div class="chat-surface-chart-row">
<div class="chat-surface-chart-meta">
<span><%= series.label %></span>
<span><%= series.value %></span>
</div>
<div class="chat-surface-chart-bar">
<span style={"width: #{chart_width(@surface.max_value, series.value)}%"}></span>
</div>
</div>
<% end %>
</div>
<% else %>
<div class="chat-surface-chart-heatmap" style={"grid-template-columns: auto repeat(#{heat.column_count}, 1fr)"}> <div class="chat-surface-chart-heatmap" style={"grid-template-columns: auto repeat(#{heat.column_count}, 1fr)"}>
<span class="chat-surface-chart-heatmap-corner"></span> <span class="chat-surface-chart-heatmap-corner"></span>
<%= for col <- heat.columns do %> <%= for col <- heat.columns do %>

View File

@@ -104,7 +104,7 @@ defmodule BDS.Desktop.ShellLive.ChatEditor.ToolSurfaces do
id: surface_id, id: surface_id,
type: "chart", type: "chart",
title: map_value(arguments, "title"), title: map_value(arguments, "title"),
chart_type: map_value(arguments, "chart_type", "bar"), chart_type: map_value(arguments, "chartType") || map_value(arguments, "chart_type", "bar"),
series: series, series: series,
max_value: Enum.max([0 | Enum.map(series, & &1.value)]) max_value: Enum.max([0 | Enum.map(series, & &1.value)])
} }

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,60 @@
defmodule BDS.Desktop.ShellLive.ChatEditor.ToolSurfacesTest do
use ExUnit.Case, async: true
alias BDS.Desktop.ShellLive.ChatEditor.ToolSurfaces
describe "build_render_surface/3 for render_chart" do
test "reads chartType in camelCase (as LLM sends it)" do
tool_call = %{
name: "render_chart",
arguments: %{
"chartType" => "heatmap",
"title" => "Posts per Month",
"series" => [
%{"label" => "2024", "value" => 0, "segments" => [
%{"label" => "Jan", "value" => 5},
%{"label" => "Feb", "value" => 8}
]}
]
}
}
surface = ToolSurfaces.build_render_surface(tool_call, "test-heatmap-0", %{})
assert surface.type == "chart"
assert surface.chart_type == "heatmap"
end
test "reads chart_type in snake_case (legacy form)" do
tool_call = %{
name: "render_chart",
arguments: %{"chart_type" => "pie", "series" => []}
}
surface = ToolSurfaces.build_render_surface(tool_call, "test-pie-0", %{})
assert surface.chart_type == "pie"
end
test "defaults to bar when chartType field is missing" do
tool_call = %{
name: "render_chart",
arguments: %{"title" => "No type", "series" => []}
}
surface = ToolSurfaces.build_render_surface(tool_call, "test-bar-0", %{})
assert surface.chart_type == "bar"
end
test "handles all chart types via camelCase" do
for chart_type <- ["bar", "stacked-bar", "line", "area", "pie", "donut", "heatmap"] do
tool_call = %{
name: "render_chart",
arguments: %{"chartType" => chart_type, "series" => []}
}
surface = ToolSurfaces.build_render_surface(tool_call, "test-#{chart_type}-0", %{})
assert surface.chart_type == chart_type,
"Expected chart_type #{inspect(chart_type)}, got #{inspect(surface.chart_type)}"
end
end
end
end