Skip to content

Hybrid (WinExe) hosts need a first-class way to force non-interactive viewer rendering #40

Description

@tig

Context

Full diagnosis in #38 (comments). Summary: in a GUI-subsystem (WinExe) host that attaches to the parent console, dispatching a Viewer command without --cat launches the interactive Terminal.Gui session on a console the shell never stopped owning; shells do not wait for GUI-subsystem exes, so the TUI and the shell fight over the same input queue while the TUI paints frames over the prompt.

Ask

  1. CliHostOptions.NonInteractive (or ForceCat): when set, viewer commands always render via RenderCatAsync and input commands without --initial fail with a clear message instead of launching a TUI. Hybrid hosts set it once instead of rewriting args.
  2. Docs: a "Hosting from a GUI app" section covering the three requirements discovered while wiring TG.Cli into a WinForms app (tig/mcec#252): AttachConsole + enable VT via CONOUT$ (Docs: hosting CliHost from a GUI-subsystem (WinExe) app leaks literal ANSI; AttachConsole alone is not enough #38), force non-interactive viewers (this issue), and the inherent caveat that the shell prompt returns before the output (GUI exes are not waited on; the classic cure is a console-subsystem .com shim, worth mentioning).

Our working host-side workaround, for reference:

// Viewer commands default to an interactive TG session; force headless rendering.
if (args.Length > 0 && viewerAliases.Contains(args[0], StringComparer.OrdinalIgnoreCase) &&
    !args.Contains("--cat", StringComparer.OrdinalIgnoreCase)) {
    args = [.. args, "--cat"];
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions