Simplify os_description trim; rebase on main#75
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces Desktop.Platform.System.os_description/0 as a backend-safe replacement for :wx_misc.getOsDescription/0, implementing it across the Browser, Json, and Wx backends along with corresponding tests. Feedback suggests simplifying the nested case statements in os_description/0 for better readability, and removing a redundant Process.delete/1 call inside the test's on_exit/1 callback since it runs in a separate process.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| case raw do | ||
| nil -> | ||
| nil | ||
|
|
||
| str -> | ||
| case String.trim(str) do | ||
| "" -> nil | ||
| trimmed -> trimmed | ||
| end | ||
| end |
| previous = Application.get_env(:desktop, :backend, :auto) | ||
| Application.put_env(:desktop, :backend, StubBackend) | ||
|
|
||
| on_exit(fn -> |
There was a problem hiding this comment.
In ExUnit, on_exit/1 callbacks run in a separate process, not the test process. Therefore, calling Process.delete(:stub_os_description) inside on_exit is a no-op as it deletes the key from the cleanup process's dictionary rather than the test process's dictionary. Since the test process terminates and its process dictionary is automatically garbage collected, you can safely remove this line.
on_exit(fn ->
Application.put_env(:desktop, :backend, previous)
end)
|
@cursoragent rebase this on master and fix the gemini comments |
|
Rebased onto
Related tests, guards, and wx tests passed. |
Use a single if/case for blank normalization per review feedback, and remove Process.delete from on_exit (runs in a different process). Co-authored-by: Dominic Letz <dominicletz@users.noreply.github.com>
dac0db9 to
a71b3b5
Compare


Summary
main(PR Add Platform.System.os_description/0 #74 already merged)caseinDesktop.Platform.System.os_description/0toif raw do … end(Gemini feedback)Process.delete/1fromon_exitinplatform_system_test.exs(cleanup runs in a separate process)Test plan
mix test test/desktop/platform_system_test.exs test/desktop/backend/json_test.exs test/desktop/backend/browser_test.exs test/desktop/regression/beam_wx_calls_test.exs --exclude wxmix test.guardxvfb-run -a mix test test/desktop/backend/wx_test.exs --only wx