fix: fixed TD-01 and TD-25

This commit is contained in:
2026-06-11 12:13:14 +02:00
parent e6a2055e18
commit 21b11ef87e
21 changed files with 826 additions and 69 deletions

View File

@@ -1027,9 +1027,8 @@ defmodule BDS.Desktop.ShellLive.ChatEditor do
defp present?(value) when is_binary(value), do: String.trim(value) != ""
defp present?(value), do: not is_nil(value)
defp format_error(%{kind: :endpoint_not_configured}),
do: dgettext("ui", "Configure an API key in Settings to enable AI chat.")
# :endpoint_not_configured is handled by its own case clause before this is
# reached; the chat surface already shows the configuration hint.
defp format_error(reason), do: inspect(reason)
defp parse_integer(value) when is_integer(value), do: value

View File

@@ -189,6 +189,8 @@ defmodule BDS.Desktop.ShellLive.ChatEditor.MessageBuild do
|> mark_surfaces_expanded(assigns)
end
# Only called from pending_user_message/2, which already narrows the
# request to %{message: binary}.
defp persisted_user_message_for_request?(messages, %{message: message} = request)
when is_binary(message) do
messages
@@ -198,8 +200,6 @@ defmodule BDS.Desktop.ShellLive.ChatEditor.MessageBuild do
end)
end
defp persisted_user_message_for_request?(_messages, _request), do: false
defp persisted_assistant_content_for_request?(messages, request, content)
when is_binary(content) and content != "" do
messages

View File

@@ -1356,7 +1356,7 @@ defmodule BDS.Desktop.ShellLive.ImportEditor do
class="taxonomy-mapping-input"
type="text"
name="mapped_to"
value={Map.get(@edit || %{}, :value, Map.get(item, :mapped_to) || "") || ""}
value={Map.get(@edit, :value, Map.get(item, :mapped_to) || "") || ""}
placeholder={dgettext("ui", "Map to...")}
list={"taxonomy-suggestions-#{@type}"}
autocomplete="off"

View File

@@ -294,12 +294,11 @@ defmodule BDS.Desktop.ShellLive.PanelRenderer do
defp short_commit_hash(hash) when is_binary(hash), do: String.slice(hash, 0, 7)
defp short_commit_hash(_hash), do: "-------"
# Only called inside the template's `is_number(task.progress)` guard.
defp progress_percent(progress) when is_number(progress) do
rounded = progress |> Kernel.*(100) |> Float.round(0) |> trunc()
"#{rounded}%"
end
defp progress_percent(_), do: ""
defp present?(value), do: value not in [nil, ""]
end

View File

@@ -114,9 +114,7 @@ defmodule BDS.Desktop.ShellLive.PostEditor.ListValues do
end
end
defp normalize_color(nil), do: nil
defp normalize_color(""), do: nil
# nil is handled by tag_chip_style/1 before this is reached.
defp normalize_color("#" <> rest = color) when byte_size(rest) == 6 do
if String.match?(rest, ~r/\A[0-9a-fA-F]{6}\z/), do: color, else: nil
end

View File

@@ -25,8 +25,8 @@ defmodule BDS.Desktop.ShellLive.SettingsEditor.AISettings do
model_disables_reasoning?(
get_model_preference(:chat) || Map.get(online_endpoint || %{}, :model, "")
),
"online_title_model" => get_model_preference(:title),
"online_image_analysis_model" => get_model_preference(:image_analysis),
"online_title_model" => get_model_preference(:title) || "",
"online_image_analysis_model" => get_model_preference(:image_analysis) || "",
"online_chat_images" => model_supports_images?(get_model_preference(:image_analysis)),
"offline_url" => Map.get(airplane_endpoint || %{}, :url, ""),
"offline_api_key" => Map.get(airplane_endpoint || %{}, :api_key, ""),
@@ -42,8 +42,8 @@ defmodule BDS.Desktop.ShellLive.SettingsEditor.AISettings do
model_disables_reasoning?(
get_model_preference(:airplane_chat) || Map.get(airplane_endpoint || %{}, :model, "")
),
"offline_title_model" => get_model_preference(:airplane_title),
"offline_image_analysis_model" => get_model_preference(:airplane_image_analysis),
"offline_title_model" => get_model_preference(:airplane_title) || "",
"offline_image_analysis_model" => get_model_preference(:airplane_image_analysis) || "",
"offline_chat_images" =>
model_supports_images?(get_model_preference(:airplane_image_analysis)),
"system_prompt" => EditorSettings.get_global_setting("ai.system_prompt") || ""
@@ -225,10 +225,12 @@ defmodule BDS.Desktop.ShellLive.SettingsEditor.AISettings do
}
end
# Returns nil when no preference is stored so `||` fallbacks to the
# endpoint's model actually fire.
defp get_model_preference(key) do
case AI.get_model_preference(key) do
{:ok, value} -> value || ""
_other -> ""
{:ok, value} when is_binary(value) and value != "" -> value
_other -> nil
end
end