Skip to content

Fix interactive TUI startup crash and blank rendering - #12

Open
mparrett wants to merge 4 commits into
mbbsemu:masterfrom
mparrett:fix/tui-startup-crash
Open

Fix interactive TUI startup crash and blank rendering#12
mparrett wants to merge 4 commits into
mbbsemu:masterfrom
mparrett:fix/tui-startup-crash

Conversation

@mparrett

@mparrett mparrett commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

Launching MBBSDASM with no arguments (the interactive Terminal.Gui mode) crashed immediately:

Unhandled exception. System.ArgumentException: Height must be greater or equal to 0.
   at MBBSDASM.UI.impl.InteractiveUI..ctor() in MBBSDASM/UI/impl/InteractiveUI.cs:line 30

Fixing that surfaced two more defects behind it; all are needed to make the TUI usable end to end:

  • The constructor sized its views with absolute Rects computed from Application.Top.Frame, but the top-level frame isn't laid out until Application.Run(), so Height was 0 and the Rect constructor threw. Switched to computed layout (Dim.Fill/Pos.AnchorEnd), which also makes the UI adapt to terminal resizes.

  • On macOS the curses driver reports a 0x0 terminal, which left the whole UI blank and crashed OpenDialog with width cannot be negative. Switched to the portable .NET console driver (Application.UseSystemConsole = true), which renders correctly on every platform dotnet runs on.

  • DoDisassembly runs on a background task but ran the completion dialog's event loop from that thread, so the dialog never received input and could not be dismissed — the app had to be killed after every disassembly. The dialog now runs via Application.MainLoop.Invoke, and the status/progress updates are marshaled the same way.

  • On exit, the driver leaves mouse tracking enabled — every mouse movement after quitting typed SGR report fragments (35;12;6M...) into the shell — and can leave the terminal on the alternate screen. The TUI now shuts the Application down and resets those modes explicitly.

Also suspended NLog console logging while the TUI owns the screen — the disassembly pipeline's progress log lines were drawing over the UI.

Verified by driving the full interactive flow on macOS (in tmux and in a regular terminal): launch → File → Disassemble → file dialog → options dialog → disassembly of a real-world module DLL → completion dialog → OK → back to a responsive menu → clean exit, with a clean screen throughout and the output file written. Existing suite green.

Independent of #9/#11 — based directly on master.

Visual verification

TUI loads, can decompile and exit.

image

🤖 Generated with Claude Code

mparrett and others added 4 commits August 19, 2026 13:23
The TUI crashed immediately on launch: the constructor sized its views
with absolute Rects computed from Application.Top.Frame, which isn't
laid out until Application.Run(), so Height was 0 and the Rect ctor
threw. Beyond that, the curses driver reports a 0x0 terminal on macOS,
leaving the UI blank and crashing OpenDialog with a negative width.

Switch to computed layout (Dim.Fill/Pos.AnchorEnd), which also makes
the UI resize-aware, and use the portable .NET console driver instead
of curses. Suspend NLog console logging while the TUI owns the screen
so disassembly progress lines no longer draw over the UI.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
DoDisassembly runs on a background task but ran the completion dialog's
event loop from that thread, so the dialog never received input and
could not be dismissed. Run the dialog via Application.MainLoop.Invoke
and route the status/progress updates through it as well.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The .NET console driver doesn't reset terminal modes on shutdown:
mouse tracking stayed enabled after exit, so every mouse movement
typed SGR report fragments into the shell, and the terminal could be
left on the alternate screen. Shut the Application down properly and
reset the mouse/alternate-screen/cursor modes explicitly.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The .NET console driver paints directly onto the main screen, so the
TUI's last frame (file listings, blank window area) was left behind in
the shell after exit. Enter the alternate screen before init so exiting
restores whatever the terminal showed before launch. Also reset DECCKM
(application cursor keys), which the driver enables but never turns off.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant