···5566 @doc """
77 Initialize output mode. When debug is true, uses simple line-by-line output.
88- When false, uses Owl.LiveScreen for in-place updates.
88+ When false, uses Owl.LiveScreen for in-place updates (if TTY is available).
99 """
1010 def init(opts \\ []) do
1111- if opts[:debug] do
1111+ if opts[:debug] or not tty?() do
1212 Process.put(:output_mode, :simple)
1313 else
1414 Application.ensure_all_started(:owl)
1515 Process.put(:output_mode, :live)
1616+ end
1717+ end
1818+1919+ defp tty? do
2020+ # Check if stdout is a TTY
2121+ case :io.getopts(:standard_io) do
2222+ {:ok, _} ->
2323+ # Also check if we're in a CI environment
2424+ System.get_env("CI") not in ["true", "1"]
2525+2626+ _ ->
2727+ false
1628 end
1729 end
1830···5668 state: {action, name, :pending},
5769 render: &render_item/1
5870 )
7171+5972 Owl.LiveScreen.await_render()
6073 else
6174 IO.puts(" #{IO.ANSI.yellow()}⋯#{IO.ANSI.reset()} #{action} #{name}")