Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions elixir/lib/symphony_elixir/status_dashboard.ex
Original file line number Diff line number Diff line change
Expand Up @@ -1174,6 +1174,7 @@ defmodule SymphonyElixir.StatusDashboard do
payload
|> inspect(pretty: true, limit: 30)
|> String.replace("\n", " ")
|> sanitize_ansi_and_control_bytes()
|> String.trim()
end
end
Expand All @@ -1182,16 +1183,25 @@ defmodule SymphonyElixir.StatusDashboard do
defp humanize_codex_payload(payload) when is_binary(payload) do
payload
|> String.replace("\n", " ")
|> sanitize_ansi_and_control_bytes()
|> String.trim()
end

defp humanize_codex_payload(payload) do
payload
|> inspect(pretty: true, limit: 20)
|> String.replace("\n", " ")
|> sanitize_ansi_and_control_bytes()
|> String.trim()
end

defp sanitize_ansi_and_control_bytes(value) when is_binary(value) do
value
|> String.replace(~r/\x1B\[[0-9;]*[A-Za-z]/, "")
|> String.replace(~r/\x1B./, "")
|> String.replace(~r/[\x00-\x1F\x7F]/, "")
end

defp humanize_codex_method("thread/started", payload) do
thread_id = map_path(payload, ["params", "thread", "id"]) || map_path(payload, [:params, :thread, :id])

Expand Down
29 changes: 29 additions & 0 deletions elixir/test/symphony_elixir/orchestrator_status_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -1296,6 +1296,35 @@ defmodule SymphonyElixir.OrchestratorStatusTest do
refute plain =~ " notification "
end

test "status dashboard strips ANSI and control bytes from last codex message" do
payload =
"cmd: " <>
<<27>> <>
"[31mRED" <>
<<27>> <>
"[0m" <>
<<0>> <>
" after\nline"

row =
StatusDashboard.format_running_summary_for_test(%{
identifier: "MT-898",
state: "running",
session_id: "thread-1234567890",
codex_app_server_pid: "4242",
codex_total_tokens: 12,
runtime_seconds: 15,
last_codex_event: :notification,
last_codex_message: payload
})

plain = Regex.replace(~r/\e\[[0-9;]*m/, row, "")

assert plain =~ "cmd: RED after line"
refute plain =~ <<27>>
refute plain =~ <<0>>
end

test "status dashboard expands running row to requested terminal width" do
terminal_columns = 140

Expand Down