✨ fix(stdio): hide console window on windows - #91
Conversation
Erlang open_port with spawn_executable opens a visible console window for each spawned process on Windows. Pass hide: true in port options on win32 to suppress these background windows. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
WalkthroughAdds Windows-specific process hiding to the stdio transport by prepending Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Review NotesP0 – Correctness: Verify P1 – Safety: The implementation prepends the tuple, preserving other options; confirm order has no side effects for any existing options. P2 – Tests / CI: Consider a small platform-conditioned test or CI matrix note to ensure behavior on Windows remains covered. P3 – Commit message: Add a brief rationale (e.g., suppress console on Windows) for future readers. Nice and tidy change — looks idiomatic Elixir and OTP-friendly. 😎 🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Erlang open_port with spawn_executable opens a visible console window for each spawned process on Windows. Pass hide: true in port options on win32 to suppress these background windows.
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@lib/anubis/transport/stdio.ex`:
- Line 279: The Windows hide option is being passed as the tuple {:hide, true}
which is invalid for open_port; update the pipeline call (the expression using
then/&if in lib/anubis/transport/stdio.ex) to insert the bare atom :hide when
:os.type() == {:win32, :nt} so the options list contains :hide (not {:hide,
true}), ensuring open_port/2 receives the correct option; adjust any surrounding
variable names or the open_port invocation if needed to use the corrected
options list.
…m/matteing/anubis-mcp into users/sergiomattei/FixHideWindows
There was a problem hiding this comment.
♻️ Duplicate comments (1)
lib/anubis/transport/stdio.ex (1)
274-281:⚠️ Potential issue | 🔴 CriticalP0: Remove invalid
{:hide, true}— bare:hideatom is the only valid format.
Erlang'sopen_port/2accepts:hideas a bare atom only; the tuple form{:hide, true}is undocumented and will trigger:badargon Windows. Since you already have:hidein the initial list and it's ignored on non-Windows systems anyway, drop the Windows-specific conditional entirely.✅ Proposed fix
opts = [:hide, :binary] |> then(&if is_nil(state.args), do: &1, else: Enum.concat(&1, args: state.args)) |> then(&if is_nil(state.env), do: &1, else: Enum.concat(&1, env: env)) |> then(&if is_nil(state.cwd), do: &1, else: Enum.concat(&1, cd: state.cwd)) - |> then(&if :os.type() == {:win32, :nt}, do: [{:hide, true} | &1], else: &1)🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@lib/anubis/transport/stdio.ex` around lines 274 - 281, The opts building adds an undocumented {:hide, true} tuple for Windows which is invalid for Erlang's open_port/2; remove the final then branch that checks :os.type() and prepends {:hide, true} so opts only contains the bare :hide atom and any args/env/cd built from state (refer to the opts variable and the state.args, state.env, state.cwd transformations), ensuring open_port/2 is only given :hide as the atom.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Duplicate comments:
In `@lib/anubis/transport/stdio.ex`:
- Around line 274-281: The opts building adds an undocumented {:hide, true}
tuple for Windows which is invalid for Erlang's open_port/2; remove the final
then branch that checks :os.type() and prepends {:hide, true} so opts only
contains the bare :hide atom and any args/env/cd built from state (refer to the
opts variable and the state.args, state.env, state.cwd transformations),
ensuring open_port/2 is only given :hide as the atom.
|
oh, thanks |
Hi! Thank you for creating this project, it's been a lifesaver for implementing MCP on my personal coding agent, Opal.
A little quirk on Windows: when running stdio MCP tools, open_port with spawn_executable opens a visible console window for each spawned process on Windows, which is a bit awkward.
This PR adds the optional hide flag which suppresses this problem.
Thank you and cheers!
Summary by CodeRabbit