fix: a2ui is much closer to bDS parity than before
This commit is contained in:
@@ -370,28 +370,41 @@
|
||||
.chat-surface-chart-heatmap {
|
||||
display: grid;
|
||||
gap: 2px;
|
||||
font-size: 10px;
|
||||
font-size: 11px;
|
||||
}
|
||||
|
||||
.chat-surface-chart-heatmap-col-label,
|
||||
.chat-surface-chart-heatmap-row-label {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: 2px 4px;
|
||||
color: var(--vscode-descriptionForeground);
|
||||
.chat-surface-chart-heatmap-corner {
|
||||
/* empty top-left cell */
|
||||
}
|
||||
|
||||
.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 {
|
||||
aspect-ratio: 1;
|
||||
min-width: 14px;
|
||||
min-height: 14px;
|
||||
border-radius: 2px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
min-height: 24px;
|
||||
padding: 4px 2px;
|
||||
border-radius: 2px;
|
||||
font-size: 10px;
|
||||
font-weight: 500;
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
|
||||
|
||||
@@ -738,21 +738,7 @@ defmodule BDS.Desktop.ShellLive.ChatEditor do
|
||||
|
||||
<% "heatmap" -> %>
|
||||
<% heat = BDS.Desktop.ShellLive.ChatEditor.ChartView.heatmap(@surface.series) %>
|
||||
<%= 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 %>
|
||||
<%= if heat.rows != [] do %>
|
||||
<div class="chat-surface-chart-heatmap" style={"grid-template-columns: auto repeat(#{heat.column_count}, 1fr)"}>
|
||||
<span class="chat-surface-chart-heatmap-corner"></span>
|
||||
<%= for col <- heat.columns do %>
|
||||
|
||||
@@ -104,7 +104,7 @@ defmodule BDS.Desktop.ShellLive.ChatEditor.ToolSurfaces do
|
||||
id: surface_id,
|
||||
type: "chart",
|
||||
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,
|
||||
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
@@ -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
|
||||
Reference in New Issue
Block a user