idea: fallback to TUI when GUI can't be initialized #33
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
this is mostly for linux servers - if the GUI can't be initialized due to missing display, the TUI should be automatically selected and opened instead. That way it doesn't matter where the app is, when I start it, it will open an UI, either graphical or text oriented.
Implemented in
381deb4.Desktop mode now falls back to the TUI when no graphical display is available:
BDS.Server.effective_mode/3: whenBDS_MODEresolves to desktop on a non-Darwin unix system and neitherDISPLAYnorWAYLAND_DISPLAYis set (or they are empty), the app boots in tui mode instead — headless server + SSH daemon + a TUI on the launching terminal — rather than crashing wx. Starting the app anywhere now always opens a UI, graphical or text.BDS_MODE=server/tuiare never rewritten, and macOS/Windows always keep desktop mode (a launched app has a graphical session there).Covered by tests in test/bds/server_test.exs (effective_mode/3 describe block), spec updated in specs/server.allium (ModeResolution rule, allium check clean). Build, full test suite, credo, deps.audit and dialyzer are all clean.
Follow-up fix in
59333ac— the first implementation checked the display too late: the :desktop dependency application boots wx inside its own Application.start, before any BDS code runs, so the VM crashed on hermes before the fallback could fire.Two changes:
config/runtime.exsnow callsBDS.Server.prepare_boot_env()— runtime config is the only hook that runs before dependency applications start (bothmix runand releases). For every non-desktop effective mode it setsNO_WX=1, elixir-desktop's own switch that turns all of its wx calls into no-ops, so the :desktop app starts inert and the TUI fallback can actually boot. This also fixes explicitBDS_MODE=server/tuion display-less machines, which crashed the same way.DISPLAY/WAYLAND_DISPLAY(plain ssh is covered by that;ssh -Xwith a forwarded display keeps the GUI). macOS never setsDISPLAY, so there an ssh session (SSH_CONNECTION/SSH_CLIENT/SSH_TTY) is the headless signal — local launches on Mac always get the GUI. Windows always boots the GUI.So: GUI on a proper graphical session, TUI when there is none — including ssh into a Mac or Linux box.
Please retry
mix run --no-halton hermes. Tests cover the new env preparation and all platform/ssh combinations; spec, build, full test suite, credo, deps.audit and dialyzer are clean.