Skip to content

Ctrl+C bypasses the app's exit path, leaving the terminal cursor hidden after the process terminates #110

Description

@matt-edmondson

What's wrong

SpectreConsoleProvider.ReadInputAsync() has a branch that special-cases ConsoleKey.C + ConsoleModifiers.Control as if it will come back as ordinary input from Console.ReadKey(true). By default it won't: .NET's Console treats Ctrl+C as a process interrupt (SIGINT / CancelKeyPress) and terminates the process before Console.ReadKey ever sees it, unless Console.TreatControlCAsInput has been set to true.

Neither Console.TreatControlCAsInput = true nor a Console.CancelKeyPress handler exists anywhere in TUI.Core, TUI.App, or TUI.CLI.

Failure scenario

UIApplication.RunAsync() hides the cursor on startup and only restores it (ConsoleProvider.SetCursorVisibility(true)) in its finally block on normal shutdown. Pressing Ctrl+C — the near-universal terminal "quit" convention — terminates the process at the runtime/OS level, skipping RunAsync's finally entirely. The user is left with an invisible cursor in their terminal after the process exits, until they run another program that resets terminal state or manually reset it.

Suggested fix

Either:

  • Set Console.TreatControlCAsInput = true while the app runs (so the existing Ctrl+C branch in ReadInputAsync becomes reachable) and restore the previous value in finally, or
  • Register a Console.CancelKeyPress handler that sets e.Cancel = true, restores terminal state (cursor visibility, etc.), and triggers Shutdown().

Acceptance criteria

Pressing Ctrl+C while the app is running exits cleanly through the normal shutdown path, and the terminal cursor is visible again after the process ends.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions