Skip to content

Show a numbered menu off Windows instead of crashing [patch] - #170

Merged
matt-edmondson merged 1 commit into
mainfrom
fix/menu-non-windows
Sep 28, 2026
Merged

matt-edmondson merged 1 commit into
mainfrom
fix/menu-non-windows

Conversation

@matt-edmondson

Copy link
Copy Markdown
Contributor

Fixes #165

What changed

Menu is the default verb. It displays a DustInTheWind ScrollMenu, which reads Console.CursorVisible, and .NET only supports that on Windows. So ImageDescriber with no arguments, or with an unknown verb, died with PlatformNotSupportedException (exit 134) on Linux and macOS.

  • Windows: unchanged. It still uses the ScrollMenu.
  • Other platforms: a numbered prompt menu (Menu.RunPromptMenu) lists the other verbs plus Exit and reads the choice from standard input:
    • it runs the chosen verb, then shows the menu again;
    • it rejects anything that isn't a number in range;
    • it stops at end of input, so piped or closed stdin can't loop forever.
  • Building the item text and the verb instance is split out of CreateMenuItem, so both menus share it.

On Linux, the built binary with no arguments now shows:

1. Configure - Configure the Ollama endpoint and model settings.
...
6. Stats - Show database statistics.
7. Exit
Choose an option:

Tests

New MenuTests.cs:

  • RunWithoutArgumentsOffersMenuOffWindows runs the real Menu verb with stdin and stdout redirected. With Menu.cs reverted, it fails with System.PlatformNotSupportedException: Operation is not supported on this platform. With the fix, it passes. It is Inconclusive on Windows, where the ScrollMenu needs a real console.
  • PromptMenuRunsTheChosenItemUntilExit, PromptMenuRejectsInvalidChoices and PromptMenuStopsAtEndOfInput cover the prompt loop.

Full suite: 50 passed.

The triage note links this to #167 (non-zero exit codes). This PR doesn't touch exit codes; the menu path has no error exit of its own.

🤖 Generated with Claude Code

https://claude.ai/code/session_01QtRTdtw1SbV7ugjz5wPFgc


Generated by Claude Code

The default Menu verb displays a DustInTheWind ScrollMenu, which reads
Console.CursorVisible. .NET only supports that on Windows, so running
ImageDescriber with no arguments, or an unknown verb, crashed with
PlatformNotSupportedException on Linux and macOS. Off Windows, list the
verbs as numbered choices read from standard input, and stop at end of
input.

Fixes #165

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QtRTdtw1SbV7ugjz5wPFgc
@sonarqubecloud

Copy link
Copy Markdown

@matt-edmondson
matt-edmondson merged commit 32ce97a into main Sep 28, 2026
12 checks passed
@matt-edmondson
matt-edmondson deleted the fix/menu-non-windows branch September 28, 2026 08:58
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.

Running ImageDescriber with no arguments crashes with PlatformNotSupportedException on Linux and macOS

2 participants