fix: fixed behaviour of bundled app for decrypt and ai chat
This commit is contained in:
@@ -190,7 +190,7 @@ defmodule BDS.Desktop.MainWindow do
|
||||
end
|
||||
|
||||
defp config_dir do
|
||||
case :filename.basedir(:user_config, "bds") do
|
||||
case :filename.basedir(:user_config, "BDS2") do
|
||||
path when is_list(path) -> List.to_string(path)
|
||||
path -> path
|
||||
end
|
||||
|
||||
@@ -398,15 +398,6 @@ defmodule BDS.Desktop.ShellLive do
|
||||
def handle_event("overlay_confirm", params, socket),
|
||||
do: OverlayManager.handle_event("overlay_confirm", params, socket, overlay_callbacks())
|
||||
|
||||
def handle_event("overlay_select_gallery_image", params, socket),
|
||||
do:
|
||||
OverlayManager.handle_event(
|
||||
"overlay_select_gallery_image",
|
||||
params,
|
||||
socket,
|
||||
overlay_callbacks()
|
||||
)
|
||||
|
||||
def handle_event("overlay_close_lightbox", params, socket),
|
||||
do: OverlayManager.handle_event("overlay_close_lightbox", params, socket, overlay_callbacks())
|
||||
|
||||
|
||||
@@ -90,10 +90,12 @@ defmodule BDS.Desktop.ShellLive.ChatEditor do
|
||||
end
|
||||
|
||||
def handle_event("send_chat_editor_message", _params, socket) do
|
||||
Logger.info("CHAT send_chat_editor_message called, input=#{inspect(socket.assigns.input)}")
|
||||
{:noreply, do_send_message(socket)}
|
||||
end
|
||||
|
||||
def handle_event("abort_chat_editor_message", _params, socket) do
|
||||
Logger.info("CHAT abort_chat_editor_message called")
|
||||
{:noreply, do_abort_message(socket)}
|
||||
end
|
||||
|
||||
|
||||
@@ -154,7 +154,7 @@
|
||||
|
||||
<form class="chat-input-wrapper flex items-end gap-2" phx-change="change_chat_editor_input" phx-submit="send_chat_editor_message" phx-target={@myself}>
|
||||
<textarea class="chat-input chat-surface-input ui-textarea" name="message" rows="1" placeholder={dgettext("ui", "Type a message...")} disabled={@chat_editor.is_streaming}><%= @chat_editor.input %></textarea>
|
||||
<button class="chat-send-button ui-button ui-button-primary" data-testid="chat-send-button" type="button" phx-click="send_chat_editor_message" phx-target={@myself} disabled={@chat_editor.send_disabled?}>↑</button>
|
||||
<button class="chat-send-button ui-button ui-button-primary" data-testid="chat-send-button" type="button" phx-click="send_chat_editor_message" phx-target={@myself}>↑</button>
|
||||
</form>
|
||||
|
||||
<%= if @chat_editor.action_error do %>
|
||||
|
||||
@@ -9,8 +9,8 @@ defmodule BDS.Desktop.ShellLive.SettingsEditor.AISettings do
|
||||
|
||||
@spec ai_form(term()) :: term()
|
||||
def ai_form(assigns) do
|
||||
{:ok, online_endpoint} = AI.get_endpoint(:online)
|
||||
{:ok, airplane_endpoint} = AI.get_endpoint(:airplane)
|
||||
online_endpoint = safe_endpoint(:online)
|
||||
airplane_endpoint = safe_endpoint(:airplane)
|
||||
|
||||
%{
|
||||
"online_url" => Map.get(online_endpoint || %{}, :url, ""),
|
||||
@@ -168,6 +168,13 @@ defmodule BDS.Desktop.ShellLive.SettingsEditor.AISettings do
|
||||
end
|
||||
end
|
||||
|
||||
defp safe_endpoint(kind) do
|
||||
case AI.get_endpoint(kind) do
|
||||
{:ok, ep} -> ep
|
||||
_error -> nil
|
||||
end
|
||||
end
|
||||
|
||||
defp ai_attrs(assigns) do
|
||||
draft = Map.get(assigns, :settings_editor_ai_draft, %{})
|
||||
|
||||
|
||||
@@ -76,23 +76,48 @@ defmodule BDS.MacBundle.Dylibs do
|
||||
File.mkdir_p!(frameworks_dir)
|
||||
|
||||
with {:ok, {_seen, externals}} <- collect(nif_path, MapSet.new(), []) do
|
||||
copied =
|
||||
externals = Enum.reverse(externals)
|
||||
|
||||
{physical, logical_entries, _inode_map} =
|
||||
externals
|
||||
|> Enum.reverse()
|
||||
|> Enum.map(fn src ->
|
||||
|> Enum.reduce({[], [], %{}}, fn src, {phys_acc, log_acc, inode_map} ->
|
||||
dest = Path.join(frameworks_dir, Path.basename(src))
|
||||
File.cp!(src, dest)
|
||||
File.chmod!(dest, 0o644)
|
||||
{src, dest}
|
||||
|
||||
if File.exists?(dest) do
|
||||
{phys_acc, [{src, dest} | log_acc], inode_map}
|
||||
else
|
||||
ino = file_inode(src)
|
||||
|
||||
case Map.get(inode_map, ino) do
|
||||
nil ->
|
||||
File.cp!(src, dest)
|
||||
File.chmod!(dest, 0o644)
|
||||
{[{src, dest} | phys_acc], [{src, dest} | log_acc],
|
||||
Map.put(inode_map, ino, dest)}
|
||||
|
||||
existing_dest ->
|
||||
# Same inode already copied under a different name.
|
||||
# Point this logical entry to the physical copy.
|
||||
{phys_acc, [{src, existing_dest} | log_acc], inode_map}
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
copied = Enum.reverse(logical_entries)
|
||||
physical = Enum.reverse(physical)
|
||||
|
||||
with :ok <- rewrite(nif_path, copied, nif_loader_prefix),
|
||||
:ok <- rewrite_each(copied) do
|
||||
{:ok, Enum.map(copied, &elem(&1, 1))}
|
||||
:ok <- rewrite_each(physical) do
|
||||
{:ok, Enum.map(physical, &elem(&1, 1))}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
defp file_inode(path) do
|
||||
stat = File.stat!(path)
|
||||
{stat.major_device, stat.inode}
|
||||
end
|
||||
|
||||
# Depth-first transitive collection of external dependency paths. Returns
|
||||
# `{:ok, {seen, acc}}` where `acc` is the reverse-discovery-order path list.
|
||||
defp collect(binary, seen, acc) do
|
||||
@@ -100,16 +125,17 @@ defmodule BDS.MacBundle.Dylibs do
|
||||
{:ok, deps} ->
|
||||
deps
|
||||
|> Enum.filter(&external?/1)
|
||||
|> Enum.reject(&MapSet.member?(seen, &1))
|
||||
|> Enum.reduce_while({:ok, {seen, acc}}, fn dep, {:ok, {seen_acc, list_acc}} ->
|
||||
seen_acc = MapSet.put(seen_acc, dep)
|
||||
|
||||
case collect(dep, seen_acc, [dep | list_acc]) do
|
||||
{:ok, _} = ok -> {:cont, ok}
|
||||
error -> {:halt, error}
|
||||
if MapSet.member?(seen_acc, dep) do
|
||||
{:cont, {:ok, {seen_acc, list_acc}}}
|
||||
else
|
||||
seen_acc = MapSet.put(seen_acc, dep)
|
||||
case collect(dep, seen_acc, [dep | list_acc]) do
|
||||
{:ok, _} = ok -> {:cont, ok}
|
||||
error -> {:halt, error}
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
error ->
|
||||
error
|
||||
end
|
||||
|
||||
@@ -329,7 +329,7 @@ defmodule BDS.Projects do
|
||||
end
|
||||
|
||||
defp private_app_dir do
|
||||
case :filename.basedir(:user_config, "bds") do
|
||||
case :filename.basedir(:user_config, "BDS2") do
|
||||
path when is_list(path) -> List.to_string(path)
|
||||
path -> path
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user